Skip to content

Commit

Permalink
Fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic committed May 6, 2022
1 parent 6fb8e21 commit e74a989
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 7 additions & 3 deletions packages/transformers/js/core/src/global_replacer.rs
Expand Up @@ -3,7 +3,7 @@ use std::collections::{HashMap, HashSet};
use std::path::Path;

use swc_atoms::JsWord;
use swc_common::{SourceMap, SyntaxContext, DUMMY_SP};
use swc_common::{Mark, SourceMap, SyntaxContext, DUMMY_SP};
use swc_ecmascript::ast::{self, ComputedPropName};
use swc_ecmascript::utils::ident::IdentLike;
use swc_ecmascript::visit::{Fold, FoldWith};
Expand Down Expand Up @@ -155,7 +155,10 @@ fn create_decl_stmt(
global_mark: swc_common::Mark,
init: ast::Expr,
) -> (ast::Stmt, SyntaxContext) {
let span = DUMMY_SP.apply_mark(global_mark);
let span = DUMMY_SP
.apply_mark(global_mark)
.apply_mark(Mark::fresh(Mark::root()));

(
ast::Stmt::Decl(ast::Decl::Var(ast::VarDecl {
kind: ast::VarDeclKind::Var,
Expand Down Expand Up @@ -183,10 +186,11 @@ impl GlobalReplacer<'_> {
} else {
let (decl, ctxt) = create_decl_stmt(id.sym.clone(), self.global_mark, expr(self));

id.span.ctxt = ctxt;

self.globals.insert(id.sym.clone(), (ctxt, decl));
self.decls.insert(id.to_id());

id.span.ctxt = ctxt;
true
}
}
Expand Down
10 changes: 7 additions & 3 deletions packages/transformers/js/core/src/node_replacer.rs
Expand Up @@ -3,7 +3,7 @@ use std::ffi::OsStr;
use std::path::Path;

use swc_atoms::JsWord;
use swc_common::{SourceMap, SyntaxContext, DUMMY_SP};
use swc_common::{Mark, SourceMap, SyntaxContext, DUMMY_SP};
use swc_ecmascript::ast::{self};
use swc_ecmascript::utils::ident::IdentLike;
use swc_ecmascript::visit::{Fold, FoldWith};
Expand Down Expand Up @@ -191,7 +191,10 @@ fn create_decl_stmt(
global_mark: swc_common::Mark,
init: ast::Expr,
) -> (ast::Stmt, SyntaxContext) {
let span = DUMMY_SP.apply_mark(global_mark);
let span = DUMMY_SP
.apply_mark(global_mark)
.apply_mark(Mark::fresh(Mark::root()));

(
ast::Stmt::Decl(ast::Decl::Var(ast::VarDecl {
kind: ast::VarDeclKind::Var,
Expand Down Expand Up @@ -219,10 +222,11 @@ impl NodeReplacer<'_> {
} else {
let (decl, ctxt) = create_decl_stmt(id.sym.clone(), self.global_mark, expr(self));

id.span.ctxt = ctxt;

self.globals.insert(id.sym.clone(), (ctxt, decl));
self.decls.insert(id.to_id());

id.span.ctxt = ctxt;
true
}
}
Expand Down

0 comments on commit e74a989

Please sign in to comment.