Skip to content

Commit 3d72dd0

Browse files
committed
update swc and mdx-rs
1 parent 40ebdcd commit 3d72dd0

File tree

19 files changed

+540
-574
lines changed

19 files changed

+540
-574
lines changed

Cargo.lock

Lines changed: 453 additions & 465 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/macros/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ napi = ["dep:napi", "dep:napi-derive", "dep:crossbeam-channel"]
99

1010
[dependencies]
1111
indexmap = "1.9.2"
12-
swc_core = { version = "9", features = [
12+
swc_core = { version = "21", features = [
1313
"common",
14-
"common_ahash",
1514
"common_sourcemap",
1615
"ecma_ast",
1716
"ecma_parser",

crates/macros/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use swc_core::{
1212
common::{sync::Lrc, util::take::Take, SourceMap, Span, DUMMY_SP},
1313
ecma::{
1414
ast::*,
15-
atoms::{js_word, JsWord},
15+
atoms::Atom as JsWord,
1616
parser::{error::Error, lexer::Lexer, Parser, StringInput},
1717
visit::{Fold, FoldWith},
1818
},
@@ -102,7 +102,7 @@ impl<'a> Macros<'a> {
102102
default.local.to_id(),
103103
MacroImport {
104104
src: import.src.value.clone(),
105-
imported: Some(js_word!("default")),
105+
imported: Some("default".into()),
106106
span: import.span,
107107
},
108108
);
@@ -707,7 +707,7 @@ impl<'a> Evaluator<'a> {
707707
pub fn value_to_expr(&self, value: JsValue) -> Result<Expr, MacroError> {
708708
Ok(match value {
709709
JsValue::Null => Expr::Lit(Lit::Null(Null::dummy())),
710-
JsValue::Undefined => Expr::Ident(Ident::new_no_ctxt(js_word!("undefined"), DUMMY_SP)),
710+
JsValue::Undefined => Expr::Ident(Ident::new_no_ctxt("undefined".into(), DUMMY_SP)),
711711
JsValue::Bool(b) => Expr::Lit(Lit::Bool(Bool {
712712
value: b,
713713
span: DUMMY_SP,

crates/parcel-resolver/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,14 @@ parking_lot = "0.12"
1818
percent-encoding = "2.2.0"
1919
serde = { version = "1.0.152", features = ["derive"] }
2020
serde_json = "1.0.91"
21-
url = "2.3.1"
21+
url = "2.5.4"
2222
rustc-hash = "2.0.0"
2323

2424
[dev-dependencies]
2525
assert_fs = "1.0"
2626
oxc_resolver = "2"
27-
node_resolver = "0.15.0"
27+
# node_resolver = "0.15.0"
2828
criterion = { version = "*", features = ["html_reports"] }
29-
url = "*"
3029
deno_package_json = "0.1.2"
3130
rspack_resolver = "*"
3231

packages/core/integration-tests/test/scope-hoisting.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ describe('scope hoisting', function () {
201201
b.getBundles()[0].filePath,
202202
'utf8',
203203
);
204-
assert(/let \S* = Symbol.toStringTag;/.test(contents));
204+
assert(/Symbol.toStringTag/.test(contents));
205205

206206
let output = await run(b);
207207
assert.deepEqual(output, ['1', '2']);

packages/transformers/js/core/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ edition = "2021"
88
crate-type = ["rlib"]
99

1010
[dependencies]
11-
swc_core = { version = "9", features = [
11+
swc_core = { version = "21", features = [
1212
"common",
13-
"common_ahash",
1413
"common_sourcemap",
1514
"ecma_ast",
1615
"ecma_codegen",
@@ -39,5 +38,6 @@ indexmap = "1.9.2"
3938
parcel-macros = { path = "../../../../crates/macros" }
4039
parking_lot = "0.12"
4140
bitflags = "1.3.2"
42-
mdxjs = { version = "0.2.4", git = "https://github.com/devongovett/mdxjs-rs", branch = "export_phases" }
43-
markdown = { version = "1.0.0-alpha.21", features = ["serde"] }
41+
mdxjs = "0.3.4"
42+
markdown = { version = "1.0.0-alpha.22", features = ["serde"] }
43+
rustc-hash = "2"

packages/transformers/js/core/src/collect.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use swc_core::{
55
common::{sync::Lrc, Mark, Span, DUMMY_SP},
66
ecma::{
77
ast::*,
8-
atoms::{js_word, JsWord},
8+
atoms::Atom as JsWord,
99
utils::stack_size::maybe_grow_default,
1010
visit::{noop_visit_type, Visit, VisitWith},
1111
},
@@ -350,7 +350,7 @@ impl Visit for Collect {
350350
id!(default.local),
351351
Import {
352352
source: node.src.value.clone(),
353-
specifier: js_word!("default"),
353+
specifier: "default".into(),
354354
kind: ImportKind::Import,
355355
loc: SourceLocation::from(&self.source_map, default.span),
356356
},
@@ -411,7 +411,7 @@ impl Visit for Collect {
411411
}
412412
ExportSpecifier::Default(default) => {
413413
self.exports.insert(
414-
js_word!("default"),
414+
"default".into(),
415415
Export {
416416
specifier: default.exported.sym.clone(),
417417
loc: SourceLocation::from(&self.source_map, default.exported.span),
@@ -423,7 +423,7 @@ impl Visit for Collect {
423423
self
424424
.exports_locals
425425
.entry(id!(default.exported))
426-
.or_insert_with(|| js_word!("default"));
426+
.or_insert_with(|| "default".into());
427427
}
428428
}
429429
ExportSpecifier::Namespace(namespace) => {
@@ -493,20 +493,20 @@ impl Visit for Collect {
493493
DefaultDecl::Class(class) => {
494494
if let Some(ident) = &class.ident {
495495
self.exports.insert(
496-
js_word!("default"),
496+
"default".into(),
497497
Export {
498498
specifier: ident.sym.clone(),
499499
loc: SourceLocation::from(&self.source_map, node.span),
500500
source: None,
501501
is_esm: true,
502502
},
503503
);
504-
self.exports_locals.insert(id!(ident), js_word!("default"));
504+
self.exports_locals.insert(id!(ident), "default".into());
505505
} else {
506506
self.exports.insert(
507-
js_word!("default"),
507+
"default".into(),
508508
Export {
509-
specifier: js_word!("default"),
509+
specifier: "default".into(),
510510
loc: SourceLocation::from(&self.source_map, node.span),
511511
source: None,
512512
is_esm: true,
@@ -517,20 +517,20 @@ impl Visit for Collect {
517517
DefaultDecl::Fn(func) => {
518518
if let Some(ident) = &func.ident {
519519
self.exports.insert(
520-
js_word!("default"),
520+
"default".into(),
521521
Export {
522522
specifier: ident.sym.clone(),
523523
loc: SourceLocation::from(&self.source_map, node.span),
524524
source: None,
525525
is_esm: true,
526526
},
527527
);
528-
self.exports_locals.insert(id!(ident), js_word!("default"));
528+
self.exports_locals.insert(id!(ident), "default".into());
529529
} else {
530530
self.exports.insert(
531-
js_word!("default"),
531+
"default".into(),
532532
Export {
533-
specifier: js_word!("default"),
533+
specifier: "default".into(),
534534
loc: SourceLocation::from(&self.source_map, node.span),
535535
source: None,
536536
is_esm: true,
@@ -548,9 +548,9 @@ impl Visit for Collect {
548548

549549
fn visit_export_default_expr(&mut self, node: &ExportDefaultExpr) {
550550
self.exports.insert(
551-
js_word!("default"),
551+
"default".into(),
552552
Export {
553-
specifier: js_word!("default"),
553+
specifier: "default".into(),
554554
loc: SourceLocation::from(&self.source_map, node.span),
555555
source: None,
556556
is_esm: true,
@@ -679,7 +679,7 @@ impl Visit for Collect {
679679
Expr::Ident(ident) => {
680680
if &*ident.sym == "exports" && is_unresolved(&ident, self.unresolved_mark) {
681681
handle_export!();
682-
} else if ident.sym == js_word!("module") && is_unresolved(&ident, self.unresolved_mark) {
682+
} else if ident.sym == "module" && is_unresolved(&ident, self.unresolved_mark) {
683683
self.has_cjs_exports = true;
684684
self.static_cjs_exports = false;
685685
self.should_wrap = true;
@@ -718,7 +718,7 @@ impl Visit for Collect {
718718
if node.op == UnaryOp::TypeOf {
719719
match &*node.arg {
720720
Expr::Ident(ident)
721-
if ident.sym == js_word!("module") && is_unresolved(&ident, self.unresolved_mark) =>
721+
if ident.sym == "module" && is_unresolved(&ident, self.unresolved_mark) =>
722722
{
723723
// Do nothing to avoid the ident visitor from marking the module as non-static.
724724
}
@@ -754,7 +754,7 @@ impl Visit for Collect {
754754
match node {
755755
Expr::Ident(ident) => {
756756
// Bail if `module` or `exports` are accessed non-statically.
757-
let is_module = ident.sym == js_word!("module");
757+
let is_module = ident.sym == "module";
758758
let is_exports = &*ident.sym == "exports";
759759
if (is_module || is_exports) && is_unresolved(&ident, self.unresolved_mark) {
760760
self.has_cjs_exports = true;
@@ -913,7 +913,7 @@ impl Visit for Collect {
913913
if let Callee::Expr(expr) = &node.callee {
914914
match &**expr {
915915
Expr::Ident(ident) => {
916-
if ident.sym == js_word!("eval") && is_unresolved(&ident, self.unresolved_mark) {
916+
if ident.sym == "eval" && is_unresolved(&ident, self.unresolved_mark) {
917917
self.should_wrap = true;
918918
self.add_bailout(node.span, BailoutReason::Eval);
919919
}

packages/transformers/js/core/src/constant_module.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::collections::HashSet;
22

33
use swc_core::ecma::{
44
ast::{Decl, Expr, Lit, Module, ModuleDecl, ModuleItem, Stmt, VarDeclKind, VarDeclarator},
5-
atoms::JsWord,
5+
atoms::Atom as JsWord,
66
visit::Visit,
77
};
88

packages/transformers/js/core/src/dependency_collector.rs

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use swc_core::{
1313
common::{sync::Lrc, Mark, SourceMap, Span, SyntaxContext, DUMMY_SP},
1414
ecma::{
1515
ast::{self, Callee, MemberProp, Module},
16-
atoms::{js_word, JsWord},
16+
atoms::Atom as JsWord,
1717
utils::{member_expr, stack_size::maybe_grow_default},
1818
visit::{Fold, FoldWith},
1919
},
@@ -140,7 +140,7 @@ pub struct DependencyDescriptor {
140140
pub kind: DependencyKind,
141141
pub loc: SourceLocation,
142142
/// The text specifier associated with the import/export statement.
143-
pub specifier: swc_core::ecma::atoms::JsWord,
143+
pub specifier: JsWord,
144144
pub attributes: Option<JsValue>,
145145
pub flags: DependencyFlags,
146146
pub source_type: Option<SourceType>,
@@ -896,7 +896,7 @@ impl<'a> Fold for DependencyCollector<'a> {
896896
} = &node
897897
{
898898
if let ast::Expr::Ident(ident) = &**arg {
899-
if ident.sym == js_word!("require") && is_unresolved(&ident, self.unresolved_mark) {
899+
if ident.sym == "require" && is_unresolved(&ident, self.unresolved_mark) {
900900
return node;
901901
}
902902
}
@@ -1043,7 +1043,7 @@ impl<'a> Fold for DependencyCollector<'a> {
10431043
if !self.config.is_library && !self.config.standalone {
10441044
return Expr::New(NewExpr {
10451045
span: DUMMY_SP,
1046-
callee: Box::new(Expr::Ident(Ident::new_no_ctxt(js_word!("URL"), DUMMY_SP))),
1046+
callee: Box::new(Expr::Ident(Ident::new_no_ctxt("URL".into(), DUMMY_SP))),
10471047
ctxt: SyntaxContext::empty(),
10481048
args: Some(vec![ExprOrSpread {
10491049
expr: Box::new(url),
@@ -1062,12 +1062,12 @@ impl<'a> Fold for DependencyCollector<'a> {
10621062
return ast::Expr::Ident("import".into());
10631063
}
10641064
// Free `require` -> undefined
1065-
ident.sym == js_word!("require") && is_unresolved(&ident, self.unresolved_mark)
1065+
ident.sym == "require" && is_unresolved(&ident, self.unresolved_mark)
10661066
}
10671067
Expr::Member(MemberExpr { obj: expr, .. }) => {
10681068
// e.g. `require.extensions` -> undefined
10691069
if let Expr::Ident(ident) = &**expr {
1070-
ident.sym == js_word!("require") && is_unresolved(&ident, self.unresolved_mark)
1070+
ident.sym == "require" && is_unresolved(&ident, self.unresolved_mark)
10711071
} else {
10721072
false
10731073
}
@@ -1266,7 +1266,7 @@ fn create_url_constructor(url: ast::Expr, use_import_meta: bool) -> ast::Expr {
12661266
kind: MetaPropKind::ImportMeta,
12671267
span: DUMMY_SP,
12681268
})),
1269-
prop: MemberProp::Ident(IdentName::new(js_word!("url"), DUMMY_SP)),
1269+
prop: MemberProp::Ident(IdentName::new("url".into(), DUMMY_SP)),
12701270
})
12711271
} else {
12721272
// CJS output: "file:" + __filename
@@ -1284,7 +1284,7 @@ fn create_url_constructor(url: ast::Expr, use_import_meta: bool) -> ast::Expr {
12841284
Expr::New(NewExpr {
12851285
span: DUMMY_SP,
12861286
ctxt: SyntaxContext::empty(),
1287-
callee: Box::new(Expr::Ident(Ident::new_no_ctxt(js_word!("URL"), DUMMY_SP))),
1287+
callee: Box::new(Expr::Ident(Ident::new_no_ctxt("URL".into(), DUMMY_SP))),
12881288
args: Some(vec![
12891289
ExprOrSpread {
12901290
expr: Box::new(url),
@@ -1356,7 +1356,7 @@ impl<'a> DependencyCollector<'a> {
13561356

13571357
if let Expr::New(new) = expr {
13581358
let is_url = match &*new.callee {
1359-
Expr::Ident(id) => id.sym == js_word!("URL") && is_unresolved(&id, self.unresolved_mark),
1359+
Expr::Ident(id) => id.sym == "URL" && is_unresolved(&id, self.unresolved_mark),
13601360
_ => false,
13611361
};
13621362

@@ -1426,7 +1426,7 @@ impl<'a> DependencyCollector<'a> {
14261426
let name = match_property_name(member);
14271427

14281428
if let Some((name, _)) = name {
1429-
name == js_word!("url")
1429+
name == "url"
14301430
} else {
14311431
false
14321432
}
@@ -1641,21 +1641,15 @@ impl<'a> DependencyCollector<'a> {
16411641
name: Pat::Ident(BindingIdent::from(ident.clone())),
16421642
init: Some(Box::new(Expr::Call(CallExpr {
16431643
callee: Callee::Expr(Box::new(Expr::Member(MemberExpr {
1644-
obj: Box::new(Expr::Ident(Ident::new_no_ctxt(
1645-
js_word!("Object"),
1646-
DUMMY_SP,
1647-
))),
1644+
obj: Box::new(Expr::Ident(Ident::new_no_ctxt("Object".into(), DUMMY_SP))),
16481645
prop: MemberProp::Ident(IdentName::new("assign".into(), DUMMY_SP)),
16491646
span: DUMMY_SP,
16501647
}))),
16511648
args: vec![
16521649
ExprOrSpread {
16531650
expr: Box::new(Expr::Call(CallExpr {
16541651
callee: Callee::Expr(Box::new(Expr::Member(MemberExpr {
1655-
obj: (Box::new(Expr::Ident(Ident::new_no_ctxt(
1656-
js_word!("Object"),
1657-
DUMMY_SP,
1658-
)))),
1652+
obj: (Box::new(Expr::Ident(Ident::new_no_ctxt("Object".into(), DUMMY_SP)))),
16591653
prop: MemberProp::Ident(IdentName::new("create".into(), DUMMY_SP)),
16601654
span: DUMMY_SP,
16611655
}))),
@@ -1672,7 +1666,7 @@ impl<'a> DependencyCollector<'a> {
16721666
ExprOrSpread {
16731667
expr: Box::new(Expr::Object(ObjectLit {
16741668
props: vec![PropOrSpread::Prop(Box::new(Prop::KeyValue(KeyValueProp {
1675-
key: PropName::Ident(IdentName::new(js_word!("url"), DUMMY_SP)),
1669+
key: PropName::Ident(IdentName::new("url".into(), DUMMY_SP)),
16761670
value: Box::new(self.get_import_meta_url()),
16771671
})))],
16781672
span: DUMMY_SP,

packages/transformers/js/core/src/env_replacer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use swc_core::{
88
common::{sync::Lrc, Mark, DUMMY_SP},
99
ecma::{
1010
ast,
11-
atoms::JsWord,
11+
atoms::Atom as JsWord,
1212
visit::{VisitMut, VisitMutWith},
1313
},
1414
};

packages/transformers/js/core/src/fs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use swc_core::{
55
common::{Mark, Span, SyntaxContext, DUMMY_SP},
66
ecma::{
77
ast::*,
8-
atoms::JsWord,
8+
atoms::Atom as JsWord,
99
utils::stack_size::maybe_grow_default,
1010
visit::{Fold, FoldWith, VisitWith},
1111
},

0 commit comments

Comments
 (0)