Skip to content

Commit 08e5b06

Browse files
authored
Bump swc to 35 (#82237)
To pull in a minifier bugfix: swc-project/swc#10950 Fixes error locations again: swc-project/swc#10930 https://vercel.slack.com/archives/C02HY34AKME/p1753429211338319 Blocked on swc-project/plugins#514
1 parent 1180a6e commit 08e5b06

File tree

11 files changed

+173
-173
lines changed

11 files changed

+173
-173
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -299,23 +299,24 @@ turbopack-trace-utils = { path = "turbopack/crates/turbopack-trace-utils" }
299299
turbopack-wasm = { path = "turbopack/crates/turbopack-wasm" }
300300

301301
# SWC crates
302-
swc_core = { version = "34", features = [
302+
swc_core = { version = "35.0.0", features = [
303303
"ecma_loader_lru",
304304
"ecma_loader_parking_lot",
305305
"parallel_rayon",
306306
] }
307+
swc_plugin_backend_wasmer = { version = "1.0.0" }
307308
testing = "15.0.0"
308309

309310
# Keep consistent with preset_env_base through swc_core
310311
browserslist-rs = "0.19.0"
311312
mdxjs = "1.0.3"
312-
modularize_imports = "0.93.0"
313-
styled_components = "0.121.0"
314-
styled_jsx = "0.97.0"
315-
swc_emotion = "0.97.0"
316-
swc_relay = "0.67.0"
317-
react_remove_properties = "0.47.0"
318-
remove_console = "0.48.0"
313+
modularize_imports = "0.93.1"
314+
styled_components = "0.121.1"
315+
styled_jsx = "0.97.1"
316+
swc_emotion = "0.97.1"
317+
swc_relay = "0.67.1"
318+
react_remove_properties = "0.47.1"
319+
remove_console = "0.48.1"
319320
preset_env_base = "5.0.0"
320321

321322

crates/napi/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ plugin = [
1717
"swc_core/plugin_transform_host_native",
1818
"swc_core/plugin_transform_host_native_filesystem_cache",
1919
"swc_core/plugin_transform_host_native_shared_runtime",
20+
"swc_core/plugin_backend_wasmer",
2021
"next-custom-transforms/plugin",
2122
"next-core/plugin",
2223
"turbopack-ecmascript-plugins",

crates/next-core/src/next_shared/transforms/modularize_imports.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ impl ModularizeImportsTransformer {
100100
skip_default_conversion: v.skip_default_conversion,
101101
handle_default_import: false,
102102
handle_namespace_import: false,
103+
style: None,
103104
}),
104105
)
105106
})

crates/next-custom-transforms/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,5 @@ remove_console = { workspace = true }
7272
preset_env_base = { workspace = true }
7373

7474
[dev-dependencies]
75-
swc_core = { workspace = true, features = ["testing_transform"] }
75+
swc_core = { workspace = true, features = ["testing_transform", "plugin_backend_wasmer"] }
7676
testing = { workspace = true }

test/development/acceptance-app/error-recovery.test.ts

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,10 @@ describe('Error recovery app', () => {
142142
"description": "Parsing ecmascript source code failed",
143143
"environmentLabel": null,
144144
"label": "Build Error",
145-
"source": "./app/server/page.js (2:26)
145+
"source": "./app/server/page.js (2:28)
146146
Parsing ecmascript source code failed
147147
> 2 | return <p>Hello world</p>
148-
| ^",
148+
| ^",
149149
"stack": [],
150150
}
151151
`)
@@ -160,7 +160,6 @@ describe('Error recovery app', () => {
160160
,-[2:1]
161161
1 | export default function Page() {
162162
2 | return <p>Hello world</p>
163-
: ^
164163
\`----
165164
Caused by:
166165
Syntax Error
@@ -206,10 +205,10 @@ describe('Error recovery app', () => {
206205
"description": "Parsing ecmascript source code failed",
207206
"environmentLabel": null,
208207
"label": "Build Error",
209-
"source": "./app/client/page.js (2:26)
208+
"source": "./app/client/page.js (2:28)
210209
Parsing ecmascript source code failed
211210
> 2 | return <p>Hello world</p>
212-
| ^",
211+
| ^",
213212
"stack": [],
214213
}
215214
`)
@@ -224,7 +223,6 @@ describe('Error recovery app', () => {
224223
,-[2:1]
225224
1 | export default function Page() {
226225
2 | return <p>Hello world</p>
227-
: ^
228226
\`----
229227
Caused by:
230228
Syntax Error
@@ -623,10 +621,10 @@ describe('Error recovery app', () => {
623621
"description": "Parsing ecmascript source code failed",
624622
"environmentLabel": null,
625623
"label": "Build Error",
626-
"source": "./index.js (10:39)
624+
"source": "./index.js (10:42)
627625
Parsing ecmascript source code failed
628626
> 10 | export default function FunctionNamed() {
629-
| ^",
627+
| ^",
630628
"stack": [],
631629
}
632630
`)
@@ -640,7 +638,6 @@ describe('Error recovery app', () => {
640638
Error: x Expected '}', got '<eof>'
641639
,-[10:1]
642640
10 | export default function FunctionNamed() {
643-
: ^
644641
\`----
645642
Caused by:
646643
Syntax Error
@@ -660,10 +657,10 @@ describe('Error recovery app', () => {
660657
"description": "Parsing ecmascript source code failed",
661658
"environmentLabel": null,
662659
"label": "Build Error",
663-
"source": "./index.js (10:39)
660+
"source": "./index.js (10:42)
664661
Parsing ecmascript source code failed
665662
> 10 | export default function FunctionNamed() {
666-
| ^",
663+
| ^",
667664
"stack": [],
668665
}
669666
`)
@@ -677,7 +674,6 @@ describe('Error recovery app', () => {
677674
Error: x Expected '}', got '<eof>'
678675
,-[10:1]
679676
10 | export default function FunctionNamed() {
680-
: ^
681677
\`----
682678
Caused by:
683679
Syntax Error
@@ -1016,10 +1012,10 @@ describe('Error recovery app', () => {
10161012
"description": "Parsing ecmascript source code failed",
10171013
"environmentLabel": null,
10181014
"label": "Build Error",
1019-
"source": "./app/page.js (1:2)
1015+
"source": "./app/page.js (1:4)
10201016
Parsing ecmascript source code failed
10211017
> 1 | {{{
1022-
| ^",
1018+
| ^",
10231019
"stack": [],
10241020
}
10251021
`)
@@ -1033,7 +1029,6 @@ describe('Error recovery app', () => {
10331029
Error: x Expected '}', got '<eof>'
10341030
,----
10351031
1 | {{{
1036-
: ^
10371032
\`----
10381033
Caused by:
10391034
Syntax Error",

test/development/acceptance/error-recovery.test.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -840,10 +840,10 @@ describe('pages/ error recovery', () => {
840840
"description": "Parsing ecmascript source code failed",
841841
"environmentLabel": null,
842842
"label": "Build Error",
843-
"source": "./index.js (7:39)
843+
"source": "./index.js (7:42)
844844
Parsing ecmascript source code failed
845845
> 7 | export default function FunctionNamed() {
846-
| ^",
846+
| ^",
847847
"stack": [],
848848
}
849849
`)
@@ -886,7 +886,6 @@ describe('pages/ error recovery', () => {
886886
5 | throw Error('no ' + i)
887887
6 | }, 1000)
888888
7 | export default function FunctionNamed() {
889-
: ^
890889
\`----
891890
Caused by:
892891
Syntax Error
@@ -908,10 +907,10 @@ describe('pages/ error recovery', () => {
908907
"description": "Parsing ecmascript source code failed",
909908
"environmentLabel": null,
910909
"label": "Build Error",
911-
"source": "./index.js (7:39)
910+
"source": "./index.js (7:42)
912911
Parsing ecmascript source code failed
913912
> 7 | export default function FunctionNamed() {
914-
| ^",
913+
| ^",
915914
"stack": [],
916915
}
917916
`)
@@ -954,7 +953,6 @@ describe('pages/ error recovery', () => {
954953
5 | throw Error('no ' + i)
955954
6 | }, 1000)
956955
7 | export default function FunctionNamed() {
957-
: ^
958956
\`----
959957
Caused by:
960958
Syntax Error

turbopack/crates/turbopack-ecmascript-plugins/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ transform_emotion = []
1616
swc_ecma_transform_plugin = [
1717
"swc_core/plugin_transform_host_native",
1818
"swc_core/plugin_transform_host_native_shared_runtime",
19+
"swc_plugin_backend_wasmer"
1920
]
2021

2122
[lints]
@@ -40,6 +41,7 @@ modularize_imports = { workspace = true }
4041
styled_components = { workspace = true }
4142
styled_jsx = { workspace = true }
4243
swc_core = { workspace = true, features = ["ecma_ast", "ecma_visit", "common"] }
44+
swc_plugin_backend_wasmer = { workspace = true, optional = true }
4345
swc_emotion = { workspace = true }
4446
swc_relay = { workspace = true }
4547

turbopack/crates/turbopack-ecmascript-plugins/src/transform/modularize_imports.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ impl ModularizeImportsTransformer {
4040
skip_default_conversion: v.skip_default_conversion,
4141
handle_default_import: false,
4242
handle_namespace_import: false,
43+
style: None,
4344
}),
4445
)
4546
})

turbopack/crates/turbopack-ecmascript-plugins/src/transform/swc_ecma_transform_plugins.rs

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use turbopack_ecmascript::{CustomTransformer, TransformContext};
1515
/// cost of the compilation.
1616
#[turbo_tasks::value(serialization = "none", eq = "manual", into = "new", cell = "new")]
1717
pub struct SwcPluginModule(
18-
#[turbo_tasks(trace_ignore)]
18+
#[turbo_tasks(trace_ignore, debug_ignore)]
1919
#[cfg(feature = "swc_ecma_transform_plugin")]
2020
pub swc_core::plugin_runner::plugin_module_bytes::CompiledPluginModuleBytes,
2121
// Dummy field to avoid turbo_tasks macro complaining about empty struct.
@@ -28,15 +28,15 @@ impl SwcPluginModule {
2828
pub fn new(plugin_name: &str, plugin_bytes: Vec<u8>) -> Self {
2929
#[cfg(feature = "swc_ecma_transform_plugin")]
3030
{
31-
Self({
32-
use swc_core::plugin_runner::plugin_module_bytes::{
33-
CompiledPluginModuleBytes, RawPluginModuleBytes,
34-
};
35-
CompiledPluginModuleBytes::from(RawPluginModuleBytes::new(
36-
plugin_name.to_string(),
37-
plugin_bytes,
38-
))
39-
})
31+
use swc_core::plugin_runner::plugin_module_bytes::{
32+
CompiledPluginModuleBytes, RawPluginModuleBytes,
33+
};
34+
use swc_plugin_backend_wasmer::WasmerRuntime;
35+
36+
Self(CompiledPluginModuleBytes::from_raw_module(
37+
&WasmerRuntime,
38+
RawPluginModuleBytes::new(plugin_name.to_string(), plugin_bytes),
39+
))
4040
}
4141

4242
#[cfg(not(feature = "swc_ecma_transform_plugin"))]
@@ -132,19 +132,22 @@ impl CustomTransformer for SwcEcmaTransformPluginsTransformer {
132132
},
133133
ecma::ast::Module,
134134
plugin::proxies::{COMMENTS, HostCommentsStorage},
135-
plugin_runner::plugin_module_bytes::PluginModuleBytes,
136135
};
137-
138-
let mut plugins = vec![];
139-
for (plugin_module, config) in &self.plugins {
140-
let plugin_module = &plugin_module.await?.0;
141-
142-
plugins.push((
143-
plugin_module.get_module_name().to_string(),
144-
config.clone(),
145-
Box::new(plugin_module.clone()),
146-
));
147-
}
136+
use swc_plugin_backend_wasmer::WasmerRuntime;
137+
use turbo_tasks::TryJoinIterExt;
138+
139+
let plugins = self
140+
.plugins
141+
.iter()
142+
.map(async |(plugin_module, config)| {
143+
let plugin_module = plugin_module.await?;
144+
Ok((
145+
config.clone(),
146+
Box::new(plugin_module.0.clone_module(&WasmerRuntime)),
147+
))
148+
})
149+
.try_join()
150+
.await?;
148151

149152
let should_enable_comments_proxy =
150153
!ctx.comments.leading.is_empty() && !ctx.comments.trailing.is_empty();
@@ -199,9 +202,7 @@ impl CustomTransformer for SwcEcmaTransformPluginsTransformer {
199202
// Note: This doesn't mean plugin won't perform any se/deserialization: it
200203
// still have to construct from raw bytes internally to perform actual
201204
// transform.
202-
for (_plugin_name, plugin_config, plugin_module) in plugins.drain(..) {
203-
let runtime =
204-
swc_core::plugin_runner::wasix_runtime::build_wasi_runtime(None);
205+
for (plugin_config, plugin_module) in plugins {
205206
let mut transform_plugin_executor =
206207
swc_core::plugin_runner::create_plugin_transform_executor(
207208
ctx.source_map,
@@ -210,7 +211,7 @@ impl CustomTransformer for SwcEcmaTransformPluginsTransformer {
210211
None,
211212
plugin_module,
212213
Some(plugin_config),
213-
runtime,
214+
Arc::new(WasmerRuntime),
214215
);
215216

216217
serialized_program = transform_plugin_executor

0 commit comments

Comments
 (0)