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