Unverified Commit 08e5b06b authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub
parent 1180a6ec
This diff is collapsed.
...@@ -299,23 +299,24 @@ turbopack-trace-utils = { path = "turbopack/crates/turbopack-trace-utils" } ...@@ -299,23 +299,24 @@ turbopack-trace-utils = { path = "turbopack/crates/turbopack-trace-utils" }
turbopack-wasm = { path = "turbopack/crates/turbopack-wasm" } turbopack-wasm = { path = "turbopack/crates/turbopack-wasm" }
# SWC crates # SWC crates
swc_core = { version = "34", features = [ swc_core = { version = "35.0.0", features = [
"ecma_loader_lru", "ecma_loader_lru",
"ecma_loader_parking_lot", "ecma_loader_parking_lot",
"parallel_rayon", "parallel_rayon",
] } ] }
swc_plugin_backend_wasmer = { version = "1.0.0" }
testing = "15.0.0" testing = "15.0.0"
# Keep consistent with preset_env_base through swc_core # Keep consistent with preset_env_base through swc_core
browserslist-rs = "0.19.0" browserslist-rs = "0.19.0"
mdxjs = "1.0.3" mdxjs = "1.0.3"
modularize_imports = "0.93.0" modularize_imports = "0.93.1"
styled_components = "0.121.0" styled_components = "0.121.1"
styled_jsx = "0.97.0" styled_jsx = "0.97.1"
swc_emotion = "0.97.0" swc_emotion = "0.97.1"
swc_relay = "0.67.0" swc_relay = "0.67.1"
react_remove_properties = "0.47.0" react_remove_properties = "0.47.1"
remove_console = "0.48.0" remove_console = "0.48.1"
preset_env_base = "5.0.0" preset_env_base = "5.0.0"
......
...@@ -17,6 +17,7 @@ plugin = [ ...@@ -17,6 +17,7 @@ plugin = [
"swc_core/plugin_transform_host_native", "swc_core/plugin_transform_host_native",
"swc_core/plugin_transform_host_native_filesystem_cache", "swc_core/plugin_transform_host_native_filesystem_cache",
"swc_core/plugin_transform_host_native_shared_runtime", "swc_core/plugin_transform_host_native_shared_runtime",
"swc_core/plugin_backend_wasmer",
"next-custom-transforms/plugin", "next-custom-transforms/plugin",
"next-core/plugin", "next-core/plugin",
"turbopack-ecmascript-plugins", "turbopack-ecmascript-plugins",
......
...@@ -100,6 +100,7 @@ impl ModularizeImportsTransformer { ...@@ -100,6 +100,7 @@ impl ModularizeImportsTransformer {
skip_default_conversion: v.skip_default_conversion, skip_default_conversion: v.skip_default_conversion,
handle_default_import: false, handle_default_import: false,
handle_namespace_import: false, handle_namespace_import: false,
style: None,
}), }),
) )
}) })
......
...@@ -72,5 +72,5 @@ remove_console = { workspace = true } ...@@ -72,5 +72,5 @@ remove_console = { workspace = true }
preset_env_base = { workspace = true } preset_env_base = { workspace = true }
[dev-dependencies] [dev-dependencies]
swc_core = { workspace = true, features = ["testing_transform"] } swc_core = { workspace = true, features = ["testing_transform", "plugin_backend_wasmer"] }
testing = { workspace = true } testing = { workspace = true }
...@@ -142,7 +142,7 @@ describe('Error recovery app', () => { ...@@ -142,7 +142,7 @@ describe('Error recovery app', () => {
"description": "Parsing ecmascript source code failed", "description": "Parsing ecmascript source code failed",
"environmentLabel": null, "environmentLabel": null,
"label": "Build Error", "label": "Build Error",
"source": "./app/server/page.js (2:26) "source": "./app/server/page.js (2:28)
Parsing ecmascript source code failed Parsing ecmascript source code failed
> 2 | return <p>Hello world</p> > 2 | return <p>Hello world</p>
| ^", | ^",
...@@ -160,7 +160,6 @@ describe('Error recovery app', () => { ...@@ -160,7 +160,6 @@ describe('Error recovery app', () => {
,-[2:1] ,-[2:1]
1 | export default function Page() { 1 | export default function Page() {
2 | return <p>Hello world</p> 2 | return <p>Hello world</p>
: ^
\`---- \`----
Caused by: Caused by:
Syntax Error Syntax Error
...@@ -206,7 +205,7 @@ describe('Error recovery app', () => { ...@@ -206,7 +205,7 @@ describe('Error recovery app', () => {
"description": "Parsing ecmascript source code failed", "description": "Parsing ecmascript source code failed",
"environmentLabel": null, "environmentLabel": null,
"label": "Build Error", "label": "Build Error",
"source": "./app/client/page.js (2:26) "source": "./app/client/page.js (2:28)
Parsing ecmascript source code failed Parsing ecmascript source code failed
> 2 | return <p>Hello world</p> > 2 | return <p>Hello world</p>
| ^", | ^",
...@@ -224,7 +223,6 @@ describe('Error recovery app', () => { ...@@ -224,7 +223,6 @@ describe('Error recovery app', () => {
,-[2:1] ,-[2:1]
1 | export default function Page() { 1 | export default function Page() {
2 | return <p>Hello world</p> 2 | return <p>Hello world</p>
: ^
\`---- \`----
Caused by: Caused by:
Syntax Error Syntax Error
...@@ -623,7 +621,7 @@ describe('Error recovery app', () => { ...@@ -623,7 +621,7 @@ describe('Error recovery app', () => {
"description": "Parsing ecmascript source code failed", "description": "Parsing ecmascript source code failed",
"environmentLabel": null, "environmentLabel": null,
"label": "Build Error", "label": "Build Error",
"source": "./index.js (10:39) "source": "./index.js (10:42)
Parsing ecmascript source code failed Parsing ecmascript source code failed
> 10 | export default function FunctionNamed() { > 10 | export default function FunctionNamed() {
| ^", | ^",
...@@ -640,7 +638,6 @@ describe('Error recovery app', () => { ...@@ -640,7 +638,6 @@ describe('Error recovery app', () => {
Error: x Expected '}', got '<eof>' Error: x Expected '}', got '<eof>'
,-[10:1] ,-[10:1]
10 | export default function FunctionNamed() { 10 | export default function FunctionNamed() {
: ^
\`---- \`----
Caused by: Caused by:
Syntax Error Syntax Error
...@@ -660,7 +657,7 @@ describe('Error recovery app', () => { ...@@ -660,7 +657,7 @@ describe('Error recovery app', () => {
"description": "Parsing ecmascript source code failed", "description": "Parsing ecmascript source code failed",
"environmentLabel": null, "environmentLabel": null,
"label": "Build Error", "label": "Build Error",
"source": "./index.js (10:39) "source": "./index.js (10:42)
Parsing ecmascript source code failed Parsing ecmascript source code failed
> 10 | export default function FunctionNamed() { > 10 | export default function FunctionNamed() {
| ^", | ^",
...@@ -677,7 +674,6 @@ describe('Error recovery app', () => { ...@@ -677,7 +674,6 @@ describe('Error recovery app', () => {
Error: x Expected '}', got '<eof>' Error: x Expected '}', got '<eof>'
,-[10:1] ,-[10:1]
10 | export default function FunctionNamed() { 10 | export default function FunctionNamed() {
: ^
\`---- \`----
Caused by: Caused by:
Syntax Error Syntax Error
...@@ -1016,7 +1012,7 @@ describe('Error recovery app', () => { ...@@ -1016,7 +1012,7 @@ describe('Error recovery app', () => {
"description": "Parsing ecmascript source code failed", "description": "Parsing ecmascript source code failed",
"environmentLabel": null, "environmentLabel": null,
"label": "Build Error", "label": "Build Error",
"source": "./app/page.js (1:2) "source": "./app/page.js (1:4)
Parsing ecmascript source code failed Parsing ecmascript source code failed
> 1 | {{{ > 1 | {{{
| ^", | ^",
...@@ -1033,7 +1029,6 @@ describe('Error recovery app', () => { ...@@ -1033,7 +1029,6 @@ describe('Error recovery app', () => {
Error: x Expected '}', got '<eof>' Error: x Expected '}', got '<eof>'
,---- ,----
1 | {{{ 1 | {{{
: ^
\`---- \`----
Caused by: Caused by:
Syntax Error", Syntax Error",
......
...@@ -840,7 +840,7 @@ describe('pages/ error recovery', () => { ...@@ -840,7 +840,7 @@ describe('pages/ error recovery', () => {
"description": "Parsing ecmascript source code failed", "description": "Parsing ecmascript source code failed",
"environmentLabel": null, "environmentLabel": null,
"label": "Build Error", "label": "Build Error",
"source": "./index.js (7:39) "source": "./index.js (7:42)
Parsing ecmascript source code failed Parsing ecmascript source code failed
> 7 | export default function FunctionNamed() { > 7 | export default function FunctionNamed() {
| ^", | ^",
...@@ -886,7 +886,6 @@ describe('pages/ error recovery', () => { ...@@ -886,7 +886,6 @@ describe('pages/ error recovery', () => {
5 | throw Error('no ' + i) 5 | throw Error('no ' + i)
6 | }, 1000) 6 | }, 1000)
7 | export default function FunctionNamed() { 7 | export default function FunctionNamed() {
: ^
\`---- \`----
Caused by: Caused by:
Syntax Error Syntax Error
...@@ -908,7 +907,7 @@ describe('pages/ error recovery', () => { ...@@ -908,7 +907,7 @@ describe('pages/ error recovery', () => {
"description": "Parsing ecmascript source code failed", "description": "Parsing ecmascript source code failed",
"environmentLabel": null, "environmentLabel": null,
"label": "Build Error", "label": "Build Error",
"source": "./index.js (7:39) "source": "./index.js (7:42)
Parsing ecmascript source code failed Parsing ecmascript source code failed
> 7 | export default function FunctionNamed() { > 7 | export default function FunctionNamed() {
| ^", | ^",
...@@ -954,7 +953,6 @@ describe('pages/ error recovery', () => { ...@@ -954,7 +953,6 @@ describe('pages/ error recovery', () => {
5 | throw Error('no ' + i) 5 | throw Error('no ' + i)
6 | }, 1000) 6 | }, 1000)
7 | export default function FunctionNamed() { 7 | export default function FunctionNamed() {
: ^
\`---- \`----
Caused by: Caused by:
Syntax Error Syntax Error
......
...@@ -16,6 +16,7 @@ transform_emotion = [] ...@@ -16,6 +16,7 @@ transform_emotion = []
swc_ecma_transform_plugin = [ swc_ecma_transform_plugin = [
"swc_core/plugin_transform_host_native", "swc_core/plugin_transform_host_native",
"swc_core/plugin_transform_host_native_shared_runtime", "swc_core/plugin_transform_host_native_shared_runtime",
"swc_plugin_backend_wasmer"
] ]
[lints] [lints]
...@@ -40,6 +41,7 @@ modularize_imports = { workspace = true } ...@@ -40,6 +41,7 @@ modularize_imports = { workspace = true }
styled_components = { workspace = true } styled_components = { workspace = true }
styled_jsx = { workspace = true } styled_jsx = { workspace = true }
swc_core = { workspace = true, features = ["ecma_ast", "ecma_visit", "common"] } swc_core = { workspace = true, features = ["ecma_ast", "ecma_visit", "common"] }
swc_plugin_backend_wasmer = { workspace = true, optional = true }
swc_emotion = { workspace = true } swc_emotion = { workspace = true }
swc_relay = { workspace = true } swc_relay = { workspace = true }
......
...@@ -40,6 +40,7 @@ impl ModularizeImportsTransformer { ...@@ -40,6 +40,7 @@ impl ModularizeImportsTransformer {
skip_default_conversion: v.skip_default_conversion, skip_default_conversion: v.skip_default_conversion,
handle_default_import: false, handle_default_import: false,
handle_namespace_import: false, handle_namespace_import: false,
style: None,
}), }),
) )
}) })
......
...@@ -15,7 +15,7 @@ use turbopack_ecmascript::{CustomTransformer, TransformContext}; ...@@ -15,7 +15,7 @@ use turbopack_ecmascript::{CustomTransformer, TransformContext};
/// cost of the compilation. /// cost of the compilation.
#[turbo_tasks::value(serialization = "none", eq = "manual", into = "new", cell = "new")] #[turbo_tasks::value(serialization = "none", eq = "manual", into = "new", cell = "new")]
pub struct SwcPluginModule( pub struct SwcPluginModule(
#[turbo_tasks(trace_ignore)] #[turbo_tasks(trace_ignore, debug_ignore)]
#[cfg(feature = "swc_ecma_transform_plugin")] #[cfg(feature = "swc_ecma_transform_plugin")]
pub swc_core::plugin_runner::plugin_module_bytes::CompiledPluginModuleBytes, pub swc_core::plugin_runner::plugin_module_bytes::CompiledPluginModuleBytes,
// Dummy field to avoid turbo_tasks macro complaining about empty struct. // Dummy field to avoid turbo_tasks macro complaining about empty struct.
...@@ -28,15 +28,15 @@ impl SwcPluginModule { ...@@ -28,15 +28,15 @@ impl SwcPluginModule {
pub fn new(plugin_name: &str, plugin_bytes: Vec<u8>) -> Self { pub fn new(plugin_name: &str, plugin_bytes: Vec<u8>) -> Self {
#[cfg(feature = "swc_ecma_transform_plugin")] #[cfg(feature = "swc_ecma_transform_plugin")]
{ {
Self({
use swc_core::plugin_runner::plugin_module_bytes::{ use swc_core::plugin_runner::plugin_module_bytes::{
CompiledPluginModuleBytes, RawPluginModuleBytes, CompiledPluginModuleBytes, RawPluginModuleBytes,
}; };
CompiledPluginModuleBytes::from(RawPluginModuleBytes::new( use swc_plugin_backend_wasmer::WasmerRuntime;
plugin_name.to_string(),
plugin_bytes, Self(CompiledPluginModuleBytes::from_raw_module(
&WasmerRuntime,
RawPluginModuleBytes::new(plugin_name.to_string(), plugin_bytes),
)) ))
})
} }
#[cfg(not(feature = "swc_ecma_transform_plugin"))] #[cfg(not(feature = "swc_ecma_transform_plugin"))]
...@@ -132,19 +132,22 @@ impl CustomTransformer for SwcEcmaTransformPluginsTransformer { ...@@ -132,19 +132,22 @@ impl CustomTransformer for SwcEcmaTransformPluginsTransformer {
}, },
ecma::ast::Module, ecma::ast::Module,
plugin::proxies::{COMMENTS, HostCommentsStorage}, plugin::proxies::{COMMENTS, HostCommentsStorage},
plugin_runner::plugin_module_bytes::PluginModuleBytes,
}; };
use swc_plugin_backend_wasmer::WasmerRuntime;
let mut plugins = vec![]; use turbo_tasks::TryJoinIterExt;
for (plugin_module, config) in &self.plugins {
let plugin_module = &plugin_module.await?.0; let plugins = self
.plugins
plugins.push(( .iter()
plugin_module.get_module_name().to_string(), .map(async |(plugin_module, config)| {
let plugin_module = plugin_module.await?;
Ok((
config.clone(), config.clone(),
Box::new(plugin_module.clone()), Box::new(plugin_module.0.clone_module(&WasmerRuntime)),
)); ))
} })
.try_join()
.await?;
let should_enable_comments_proxy = let should_enable_comments_proxy =
!ctx.comments.leading.is_empty() && !ctx.comments.trailing.is_empty(); !ctx.comments.leading.is_empty() && !ctx.comments.trailing.is_empty();
...@@ -199,9 +202,7 @@ impl CustomTransformer for SwcEcmaTransformPluginsTransformer { ...@@ -199,9 +202,7 @@ impl CustomTransformer for SwcEcmaTransformPluginsTransformer {
// Note: This doesn't mean plugin won't perform any se/deserialization: it // Note: This doesn't mean plugin won't perform any se/deserialization: it
// still have to construct from raw bytes internally to perform actual // still have to construct from raw bytes internally to perform actual
// transform. // transform.
for (_plugin_name, plugin_config, plugin_module) in plugins.drain(..) { for (plugin_config, plugin_module) in plugins {
let runtime =
swc_core::plugin_runner::wasix_runtime::build_wasi_runtime(None);
let mut transform_plugin_executor = let mut transform_plugin_executor =
swc_core::plugin_runner::create_plugin_transform_executor( swc_core::plugin_runner::create_plugin_transform_executor(
ctx.source_map, ctx.source_map,
...@@ -210,7 +211,7 @@ impl CustomTransformer for SwcEcmaTransformPluginsTransformer { ...@@ -210,7 +211,7 @@ impl CustomTransformer for SwcEcmaTransformPluginsTransformer {
None, None,
plugin_module, plugin_module,
Some(plugin_config), Some(plugin_config),
runtime, Arc::new(WasmerRuntime),
); );
serialized_program = transform_plugin_executor serialized_program = transform_plugin_executor
......
...@@ -972,7 +972,7 @@ impl Analyzer<'_> { ...@@ -972,7 +972,7 @@ impl Analyzer<'_> {
// We cannot analyze recursive IIFE // We cannot analyze recursive IIFE
if let Some(ident) = ident if let Some(ident) = ident
&& contains_ident_ref(&function.body, &ident.to_id()) && contains_ident_ref(&function.body, ident)
{ {
return false; return false;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment