Skip to content

Commit 0b13d2e

Browse files
CPunisherJSerFeng
andauthored
chore(deps)!: bump swc_core to v46 (#12032)
* Bump * Fix ts_collector and import * Fix visitor.rs * Fix lazy_barrel_artifact.rs * Fix concatenated_module.rs * Update ts_collector * Fix some js plugins * Fix JSXAttrValue::Lit * Fix JavaScriptParserPlugin * Fix Ts collect * Fix rspack_plugin_esm_library * Fix rspack_plugin_rstest * Fix rspack_plugin_library * Cargo shear * Cargo codegen * Cargo clippy * Cargo clippy * Fix * fix: should use ordered map to store module outgoing refs * Update snap * Bump swc plugin * Update enum string combination --------- Co-authored-by: jserfeng <[email protected]>
1 parent 19bf3f5 commit 0b13d2e

File tree

34 files changed

+1485
-1449
lines changed

34 files changed

+1485
-1449
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,15 @@ rkyv = { version = "=0.8.8", default-features = false, features = ["std", "
135135

136136
# Must be pinned with the same swc versions
137137
pnp = { version = "0.12.1", default-features = false }
138-
swc = { version = "43.0.0", default-features = false }
138+
swc = { version = "44.0.0", default-features = false }
139139
swc_config = { version = "3.1.2", default-features = false }
140-
swc_core = { version = "45.0.1", default-features = false, features = ["parallel_rayon"] }
141-
swc_ecma_lexer = { version = "=24.0.0", default-features = false }
142-
swc_ecma_minifier = { version = "34.0.1", default-features = false }
143-
swc_error_reporters = { version = "17.0.0", default-features = false }
144-
swc_html = { version = "27.0.0", default-features = false }
145-
swc_html_minifier = { version = "34.0.0", default-features = false }
146-
swc_node_comments = { version = "15.0.0", default-features = false }
147-
swc_plugin_runner = { version = "20.0.0", default-features = false }
140+
swc_core = { version = "46.0.2", default-features = false, features = ["parallel_rayon"] }
141+
swc_ecma_minifier = { version = "35.0.0", default-features = false }
142+
swc_error_reporters = { version = "18.0.0", default-features = false }
143+
swc_html = { version = "28.0.0", default-features = false }
144+
swc_html_minifier = { version = "35.0.0", default-features = false }
145+
swc_node_comments = { version = "16.0.0", default-features = false }
146+
swc_plugin_runner = { version = "21.0.0", default-features = false }
148147

149148
wasi-common = { version = "35.0.0", default-features = false }
150149
wasmtime = { version = "35.0.0", default-features = false }

crates/rspack_core/src/cache/persistent/build_dependencies/helper/visitor.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ pub struct DependencyVisitor {
1212
impl Visit for DependencyVisitor {
1313
/// handle `import .. from "..."`
1414
fn visit_import_decl(&mut self, node: &ImportDecl) {
15-
self.requests.push(node.src.value.to_string());
15+
self
16+
.requests
17+
.push(node.src.value.to_string_lossy().to_string());
1618
}
1719

1820
/// handle `import("...")` and `require("...")`
@@ -28,19 +30,21 @@ impl Visit for DependencyVisitor {
2830
&& let Some(args) = node.args.first()
2931
&& let Expr::Lit(Lit::Str(s)) = args.expr.as_ref()
3032
{
31-
self.requests.push(s.value.to_string());
33+
self.requests.push(s.value.to_string_lossy().to_string());
3234
}
3335
}
3436

3537
/// handle `export * from "..."`
3638
fn visit_export_all(&mut self, node: &ExportAll) {
37-
self.requests.push(node.src.value.to_string());
39+
self
40+
.requests
41+
.push(node.src.value.to_string_lossy().to_string());
3842
}
3943

4044
/// handle `export .. from "..."`
4145
fn visit_named_export(&mut self, node: &swc_core::ecma::ast::NamedExport) {
4246
if let Some(src) = &node.src {
43-
self.requests.push(src.value.to_string());
47+
self.requests.push(src.value.to_string_lossy().to_string());
4448
}
4549
}
4650
}

crates/rspack_core/src/compilation/make/lazy_barrel_artifact.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl LazyDependencies {
137137
ForwardedIdSet::All => self.all_lazy_dependencies().collect(),
138138
ForwardedIdSet::IdSet(set) => set
139139
.iter()
140-
.filter(|forward_id| !self.terminal_forward_ids.contains(forward_id))
140+
.filter(|forward_id| !self.terminal_forward_ids.contains(*forward_id))
141141
.flat_map(|forward_id| {
142142
self
143143
.forward_id_to_request

crates/rspack_core/src/concatenated_module.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{
22
borrow::Cow,
3-
collections::{BTreeMap, hash_map::Entry},
3+
collections::BTreeMap,
44
fmt::Debug,
55
hash::{BuildHasherDefault, Hasher},
66
sync::{Arc, LazyLock},
@@ -22,7 +22,8 @@ use rspack_sources::{
2222
BoxSource, CachedSource, ConcatSource, RawStringSource, ReplaceSource, Source, SourceExt,
2323
};
2424
use rspack_util::{
25-
SpanExt, ext::DynHash, itoa, json_stringify, source_map::SourceMapKind, swc::join_atom,
25+
SpanExt, ext::DynHash, fx_hash::FxIndexMap, itoa, json_stringify, source_map::SourceMapKind,
26+
swc::join_atom,
2627
};
2728
use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet, FxHasher};
2829
use swc_core::{
@@ -204,7 +205,7 @@ pub struct ConcatenatedModuleInfo {
204205
pub global_scope_ident: Vec<ConcatenatedModuleIdent>,
205206
pub idents: Vec<ConcatenatedModuleIdent>,
206207
pub all_used_names: HashSet<Atom>,
207-
pub binding_to_ref: HashMap<(Atom, SyntaxContext), Vec<ConcatenatedModuleIdent>>,
208+
pub binding_to_ref: FxIndexMap<(Atom, SyntaxContext), Vec<ConcatenatedModuleIdent>>,
208209

209210
pub public_path_auto_replacement: Option<bool>,
210211
pub static_url_replacement: bool,
@@ -217,7 +218,7 @@ impl ConcatenatedModuleInfo {
217218
}
218219

219220
if atom.as_str() == "default" {
220-
return self.internal_names.get(&DEFAULT_EXPORT_ATOM);
221+
return self.internal_names.get(&*DEFAULT_EXPORT_ATOM);
221222
}
222223

223224
if let Some(name) = &self.namespace_export_symbol
@@ -2319,15 +2320,15 @@ impl ConcatenatedModule {
23192320
}
23202321
module_info.all_used_names = all_used_names;
23212322

2322-
let mut binding_to_ref: HashMap<(Atom, SyntaxContext), Vec<ConcatenatedModuleIdent>> =
2323-
HashMap::default();
2323+
let mut binding_to_ref: FxIndexMap<(Atom, SyntaxContext), Vec<ConcatenatedModuleIdent>> =
2324+
Default::default();
23242325

23252326
for ident in module_info.idents.iter() {
23262327
match binding_to_ref.entry((ident.id.sym.clone(), ident.id.ctxt)) {
2327-
Entry::Occupied(mut occ) => {
2328+
indexmap::map::Entry::Occupied(mut occ) => {
23282329
occ.get_mut().push(ident.clone());
23292330
}
2330-
Entry::Vacant(vac) => {
2331+
indexmap::map::Entry::Vacant(vac) => {
23312332
vac.insert(vec![ident.clone()]);
23322333
}
23332334
};

crates/rspack_javascript_compiler/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ swc_core = { workspace = true, features = [
3636
"swc_ecma_codegen",
3737
"swc_ecma_visit",
3838
] }
39-
swc_ecma_lexer = { workspace = true }
4039
swc_ecma_minifier = { workspace = true, features = ["concurrent"] }
4140
swc_error_reporters = { workspace = true }
4241
swc_node_comments = { workspace = true }

crates/rspack_javascript_compiler/src/compiler/parse.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ fn parse_with_lexer(
124124
is_module: IsModule,
125125
with_tokens: bool,
126126
) -> Result<(SwcProgram, Option<Vec<TokenAndSpan>>), Vec<parser::error::Error>> {
127-
use swc_ecma_lexer::common::parser::{Parser as _, buffer::Buffer};
128127
let inner = || {
129128
// don't call capturing when with_tokens is false to avoid performance cost
130129
let (tokens, program_result, mut errors) = if with_tokens {

crates/rspack_loader_swc/src/collect_ts_info.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use rspack_swc_plugin_ts_collector::{
33
EnumMemberValue, ExportedEnumCollector, TypeExportsCollector,
44
};
55
use rustc_hash::FxHashMap;
6-
use swc::atoms::Atom;
6+
use swc::atoms::{Atom, Wtf8Atom};
77
use swc_core::{
88
common::SyntaxContext,
99
ecma::{ast::Program, visit::VisitWith},
@@ -20,7 +20,8 @@ pub fn collect_typescript_info(
2020
if options.type_exports.unwrap_or_default() {
2121
program.visit_with(&mut TypeExportsCollector::new(&mut type_exports));
2222
}
23-
let mut exported_enums: FxHashMap<Atom, FxHashMap<Atom, EnumMemberValue>> = Default::default();
23+
let mut exported_enums: FxHashMap<Atom, FxHashMap<Wtf8Atom, EnumMemberValue>> =
24+
Default::default();
2425
if let Some(kind) = &options.exported_enum {
2526
program.visit_with(&mut ExportedEnumCollector::new(
2627
matches!(kind, CollectingEnumKind::ConstOnly),
@@ -39,10 +40,12 @@ pub fn collect_typescript_info(
3940
.map(|(id, v)| {
4041
let value = match v {
4142
EnumMemberValue::Number(n) => Some(EvaluatedInlinableValue::new_number(n)),
42-
EnumMemberValue::String(s) => Some(EvaluatedInlinableValue::new_string(s)),
43+
EnumMemberValue::String(s) => Some(EvaluatedInlinableValue::new_string(
44+
s.to_atom_lossy().into_owned(),
45+
)),
4346
EnumMemberValue::Unknown => None,
4447
};
45-
(id, value)
48+
(id.to_atom_lossy().into_owned(), value)
4649
})
4750
.collect(),
4851
);

crates/rspack_plugin_esm_library/src/chunk_link.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,10 @@ impl ExternalInterop {
8787
if let Some(namespace_object) = &self.namespace_object {
8888
namespace_object.clone()
8989
} else {
90-
let mut new_name = format!(
90+
let mut new_name = Atom::new(format!(
9191
"{}_namespace",
9292
self.required_symbol.as_ref().expect("already set")
93-
)
94-
.into();
93+
));
9594

9695
if used_names.contains(&new_name) {
9796
new_name = find_new_name(new_name.as_str(), used_names, &vec![]);
@@ -112,11 +111,10 @@ impl ExternalInterop {
112111
if let Some(namespace_object) = &self.namespace_object2 {
113112
namespace_object.clone()
114113
} else {
115-
let mut new_name = format!(
114+
let mut new_name = Atom::new(format!(
116115
"{}_namespace2",
117116
self.required_symbol.as_ref().expect("already set")
118-
)
119-
.into();
117+
));
120118

121119
if used_names.contains(&new_name) {
122120
new_name = find_new_name(new_name.as_str(), used_names, &vec![]);
@@ -137,11 +135,10 @@ impl ExternalInterop {
137135
if let Some(default_access) = &self.default_access {
138136
default_access.clone()
139137
} else {
140-
let mut new_name = format!(
138+
let mut new_name = Atom::new(format!(
141139
"{}_default",
142140
self.required_symbol.as_ref().expect("already set")
143-
)
144-
.into();
141+
));
145142

146143
if used_names.contains(&new_name) {
147144
new_name = find_new_name(new_name.as_str(), used_names, &vec![]);

crates/rspack_plugin_esm_library/src/link.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::{
2-
collections::{self, hash_map::Entry},
2+
collections::{self},
33
hash::BuildHasher,
44
sync::Arc,
55
};
@@ -27,7 +27,7 @@ use rspack_plugin_javascript::{
2727
};
2828
use rspack_util::{
2929
atom::Atom,
30-
fx_hash::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet},
30+
fx_hash::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet, indexmap},
3131
swc::join_atom,
3232
};
3333
use swc_core::{
@@ -128,7 +128,7 @@ impl EsmLibraryPlugin {
128128

129129
// we find another name to export this symbol
130130
let mut idx = 0;
131-
let mut new_export = format!("{exported}_{idx}").into();
131+
let mut new_export = Atom::new(format!("{exported}_{idx}"));
132132
while ctx.exported_symbols.contains_key(&new_export) {
133133
idx += 1;
134134
new_export = format!("{exported}_{idx}").into();
@@ -820,17 +820,17 @@ impl EsmLibraryPlugin {
820820
idents.push(ident);
821821
}
822822

823-
let mut binding_to_ref: FxHashMap<
823+
let mut binding_to_ref: FxIndexMap<
824824
(Atom, SyntaxContext),
825825
Vec<ConcatenatedModuleIdent>,
826-
> = FxHashMap::default();
826+
> = Default::default();
827827

828828
for ident in &idents {
829829
match binding_to_ref.entry((ident.id.sym.clone(), ident.id.ctxt)) {
830-
Entry::Occupied(mut occ) => {
830+
indexmap::map::Entry::Occupied(mut occ) => {
831831
occ.get_mut().push(ident.clone());
832832
}
833-
Entry::Vacant(vac) => {
833+
indexmap::map::Entry::Vacant(vac) => {
834834
vac.insert(vec![ident.clone()]);
835835
}
836836
};
@@ -1516,7 +1516,14 @@ impl EsmLibraryPlugin {
15161516

15171517
// link entry direct exports
15181518
if let Some(preserve_modules) = &self.preserve_modules {
1519-
for module_id in module_graph.modules().keys() {
1519+
let modules = module_graph.modules();
1520+
let mut modules = modules.keys().collect::<Vec<_>>();
1521+
modules.sort_by(|a, b| {
1522+
let ad = module_graph.get_depth(a);
1523+
let bd = module_graph.get_depth(b);
1524+
ad.cmp(&bd)
1525+
});
1526+
for module_id in modules {
15201527
if compilation.entry_modules().contains(module_id) {
15211528
continue;
15221529
}

0 commit comments

Comments
 (0)