From 29ecac40d2fd28e414c469d9d14948796a8fec02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Fri, 28 Mar 2025 19:31:46 +0900 Subject: [PATCH 01/12] Dep --- Cargo.lock | 1 + crates/swc/src/lib.rs | 5 +-- crates/swc_compiler_base/src/lib.rs | 2 +- crates/swc_plugin_runner/Cargo.toml | 1 + .../src/imported_fn/handler.rs | 16 ++++++++++ .../swc_plugin_runner/src/imported_fn/mod.rs | 3 +- .../tests/ecma_integration.rs | 11 +++++-- .../fixture/swc_internal_plugin/Cargo.lock | 12 +++++++ .../fixture/swc_internal_plugin/Cargo.toml | 1 + .../fixture/swc_internal_plugin/src/lib.rs | 5 +++ crates/swc_transform_common/src/output.rs | 31 ++++++++++++++++--- 11 files changed, 75 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b40b93270ab1..74525b8f1a72 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6283,6 +6283,7 @@ dependencies = [ "swc_ecma_visit", "swc_malloc", "swc_plugin_proxy", + "swc_transform_common", "testing", "tokio", "tracing", diff --git a/crates/swc/src/lib.rs b/crates/swc/src/lib.rs index 41596002db6b..edf171a69dcd 100644 --- a/crates/swc/src/lib.rs +++ b/crates/swc/src/lib.rs @@ -1022,10 +1022,7 @@ impl Compiler { let pass = config.pass; let (program, output) = swc_transform_common::output::capture(|| { if let Some(dts_code) = dts_code { - emit( - "__swc_isolated_declarations__".into(), - serde_json::Value::String(dts_code), - ); + emit("__swc_isolated_declarations__".into(), dts_code); } helpers::HELPERS.set(&Helpers::new(config.external_helpers), || { diff --git a/crates/swc_compiler_base/src/lib.rs b/crates/swc_compiler_base/src/lib.rs index 69c20fa629a0..9f60bbeb55d2 100644 --- a/crates/swc_compiler_base/src/lib.rs +++ b/crates/swc_compiler_base/src/lib.rs @@ -118,7 +118,7 @@ pub struct PrintArgs<'a> { pub emit_source_map_columns: bool, pub preamble: &'a str, pub codegen_config: swc_ecma_codegen::Config, - pub output: Option>, + pub output: Option>, } impl Default for PrintArgs<'_> { diff --git a/crates/swc_plugin_runner/Cargo.toml b/crates/swc_plugin_runner/Cargo.toml index a7081c4dd72b..287fc4e07c30 100644 --- a/crates/swc_plugin_runner/Cargo.toml +++ b/crates/swc_plugin_runner/Cargo.toml @@ -70,6 +70,7 @@ swc_common = { version = "8.0.1", path = "../swc_common", features = [ swc_css_ast = { version = "8.0.0", path = "../swc_css_ast", optional = true } swc_ecma_ast = { version = "8.1.0", path = "../swc_ecma_ast", optional = true } swc_plugin_proxy = { version = "8.0.0", path = "../swc_plugin_proxy" } +swc_transform_common = { version = "1.0.1", path = "../swc_transform_common" } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] wasmer-cache = { version = "=5.0.5-rc1", optional = true } diff --git a/crates/swc_plugin_runner/src/imported_fn/handler.rs b/crates/swc_plugin_runner/src/imported_fn/handler.rs index c4836c6490af..d03d07a821a3 100644 --- a/crates/swc_plugin_runner/src/imported_fn/handler.rs +++ b/crates/swc_plugin_runner/src/imported_fn/handler.rs @@ -2,6 +2,7 @@ use swc_common::{ errors::{Diagnostic, HANDLER}, plugin::serialized::PluginSerializedBytes, }; +use swc_transform_common::output::emit; use wasmer::FunctionEnvMut; use crate::{host_environment::BaseHostEnvironment, memory_interop::copy_bytes_into_host}; @@ -34,3 +35,18 @@ pub fn emit_diagnostics( }) } } + +pub fn emit_output(env: FunctionEnvMut, output_ptr: i32, output_len: i32) { + let memory = env + .data() + .memory + .as_ref() + .expect("Memory instance should be available, check initialization"); + + let output_bytes = copy_bytes_into_host(&memory.view(&env), output_ptr, output_len); + let serialized = PluginSerializedBytes::from_slice(&output_bytes[..]); + let output = PluginSerializedBytes::deserialize::<(String, String)>(&serialized) + .expect("Should able to be deserialized into string"); + + emit(output.0 .0, output.0 .1); +} diff --git a/crates/swc_plugin_runner/src/imported_fn/mod.rs b/crates/swc_plugin_runner/src/imported_fn/mod.rs index 39fd79055d9b..4d4590b0fc91 100644 --- a/crates/swc_plugin_runner/src/imported_fn/mod.rs +++ b/crates/swc_plugin_runner/src/imported_fn/mod.rs @@ -129,7 +129,7 @@ pub(crate) fn build_import_object( // handler let emit_diagnostics_fn_decl = Function::new_typed_with_env(wasmer_store, base_env, emit_diagnostics); - + let emit_output_fn_decl = Function::new_typed_with_env(wasmer_store, base_env, emit_output); // hygiene let mark_fresh_fn_decl = Function::new_typed(wasmer_store, mark_fresh_proxy); let mark_parent_fn_decl = Function::new_typed(wasmer_store, mark_parent_proxy); @@ -249,6 +249,7 @@ pub(crate) fn build_import_object( "__set_transform_result" => set_transform_result_fn_decl, // handler "__emit_diagnostics" => emit_diagnostics_fn_decl, + "__emit_output" => emit_output_fn_decl, // hygiene "__mark_fresh_proxy" => mark_fresh_fn_decl, "__mark_parent_proxy" => mark_parent_fn_decl, diff --git a/crates/swc_plugin_runner/tests/ecma_integration.rs b/crates/swc_plugin_runner/tests/ecma_integration.rs index eedda42cfed3..442851eb12a1 100644 --- a/crates/swc_plugin_runner/tests/ecma_integration.rs +++ b/crates/swc_plugin_runner/tests/ecma_integration.rs @@ -101,6 +101,7 @@ static PLUGIN_BYTES: Lazy>); +scoped_tls!(static OUTPUT: RefCell>); /// (Experimental) Captures output. /// /// This is not stable and may be removed in the future. -pub fn capture(f: impl FnOnce() -> Ret) -> (Ret, FxHashMap) { +pub fn capture(f: impl FnOnce() -> Ret) -> (Ret, FxHashMap) { let output = RefCell::new(Default::default()); let ret = OUTPUT.set(&output, f); @@ -21,10 +20,34 @@ pub fn capture(f: impl FnOnce() -> Ret) -> (Ret, FxHashMap Date: Sat, 29 Mar 2025 13:36:42 +0900 Subject: [PATCH 02/12] Create slow-bees-hope.md --- .changeset/slow-bees-hope.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/slow-bees-hope.md diff --git a/.changeset/slow-bees-hope.md b/.changeset/slow-bees-hope.md new file mode 100644 index 000000000000..712ffc6c362a --- /dev/null +++ b/.changeset/slow-bees-hope.md @@ -0,0 +1,6 @@ +--- +swc_core: minor +swc_transform_common: major +--- + +feat(plugin): Refactor extra output API and expose it to Wasm plugin From 4668cdd27cf87d473dda820436bb5a13e5051b69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Mon, 31 Mar 2025 14:17:52 +0900 Subject: [PATCH 03/12] feat(es): Add JS API for analysis (#10296) **Description:** A JS API is required to use it from JS world. ```js import { experimental_analyze } as '@swc/core'; const result = await analyze( `console.log('boo')`, { plugins: [[getPluginAbsolutePath(feature), {}]], } ); expect(result).toMatchInlineSnapshot( `"{"test":"test"}"` ); ``` Wasm plugin code: ```rust use swc_core::{ ecma::ast::Program, plugin::{plugin_transform, proxies::TransformPluginProgramMetadata}, transform_common::output::experimental_emit, }; #[plugin_transform] pub fn process(program: Program, _metadata: TransformPluginProgramMetadata) -> Program { experimental_emit("test".into(), "test".into()); program } ``` --- Cargo.lock | 1 + bindings/binding_core_node/src/analyze.rs | 72 + bindings/binding_core_node/src/lib.rs | 1 + crates/swc/src/config/mod.rs | 48 +- crates/swc/src/lib.rs | 6 +- crates/swc/src/plugin.rs | 52 + crates/swc/src/wasm_analysis.rs | 160 +- crates/swc_core/Cargo.toml | 10 +- crates/swc_core/src/lib.rs | 4 +- crates/swc_plugin_runner/src/cache.rs | 6 +- .../src/imported_fn/handler.rs | 4 +- crates/swc_transform_common/Cargo.toml | 1 + crates/swc_transform_common/src/output.rs | 8 +- packages/core/binding.d.ts | 3 + packages/core/binding.js | 131 +- .../e2e/fixtures/plugin_analyze/Cargo.lock | 2324 +++++++++++++++++ .../e2e/fixtures/plugin_analyze/Cargo.toml | 17 + .../e2e/fixtures/plugin_analyze/src/lib.rs | 12 + .../core/e2e/plugins/plugins.analyze.test.js | 135 + packages/core/src/index.ts | 9 + packages/types/index.ts | 67 +- 21 files changed, 2871 insertions(+), 200 deletions(-) create mode 100644 bindings/binding_core_node/src/analyze.rs create mode 100644 packages/core/e2e/fixtures/plugin_analyze/Cargo.lock create mode 100644 packages/core/e2e/fixtures/plugin_analyze/Cargo.toml create mode 100644 packages/core/e2e/fixtures/plugin_analyze/src/lib.rs create mode 100644 packages/core/e2e/plugins/plugins.analyze.test.js diff --git a/Cargo.lock b/Cargo.lock index 74525b8f1a72..70c944f13365 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6325,6 +6325,7 @@ dependencies = [ "rustc-hash 2.1.0", "serde", "serde_json", + "swc_common", ] [[package]] diff --git a/bindings/binding_core_node/src/analyze.rs b/bindings/binding_core_node/src/analyze.rs new file mode 100644 index 000000000000..e98f48fc5a70 --- /dev/null +++ b/bindings/binding_core_node/src/analyze.rs @@ -0,0 +1,72 @@ +use std::sync::Arc; + +use napi::{ + bindgen_prelude::{AbortSignal, AsyncTask}, + Env, JsBuffer, JsBufferValue, Ref, Task, +}; +use swc_core::{ + base::{wasm_analysis::WasmAnalysisOptions, Compiler}, + common::{comments::SingleThreadedComments, FileName}, + node::MapErr, +}; +use tracing::instrument; + +use crate::{get_fresh_compiler, util::try_with}; + +pub struct AnalyzeTask { + pub c: Arc, + pub input: Option, + pub options: Ref, +} + +#[napi] +impl Task for AnalyzeTask { + type JsValue = String; + type Output = String; + + #[instrument(level = "trace", skip_all)] + fn compute(&mut self) -> napi::Result { + let options: WasmAnalysisOptions = serde_json::from_slice(self.options.as_ref())?; + + try_with(self.c.cm.clone(), false, options.error_format, |handler| { + let comments = SingleThreadedComments::default(); + + let fm = self.c.cm.new_source_file( + if let Some(filename) = options.filename.as_deref() { + FileName::Real(filename.into()).into() + } else { + FileName::Anon.into() + }, + self.input.take().unwrap(), + ); + + self.c.run_wasm_analysis(fm, handler, &options, &comments) + }) + .convert_err() + } + + fn resolve(&mut self, _env: Env, result: Self::Output) -> napi::Result { + Ok(result) + } + + fn finally(&mut self, env: Env) -> napi::Result<()> { + self.options.unref(env)?; + Ok(()) + } +} + +#[napi] +pub fn analyze( + src: String, + options: JsBuffer, + signal: Option, +) -> napi::Result> { + crate::util::init_default_trace_subscriber(); + + let task = AnalyzeTask { + c: get_fresh_compiler(), + input: Some(src), + options: options.into_ref()?, + }; + Ok(AsyncTask::with_optional_signal(task, signal)) +} diff --git a/bindings/binding_core_node/src/lib.rs b/bindings/binding_core_node/src/lib.rs index 02ed410a3ac8..0165896a3273 100644 --- a/bindings/binding_core_node/src/lib.rs +++ b/bindings/binding_core_node/src/lib.rs @@ -14,6 +14,7 @@ use swc_core::{ common::{sync::Lazy, FilePathMapping, SourceMap}, }; +mod analyze; mod bundle; mod minify; mod parse; diff --git a/crates/swc/src/config/mod.rs b/crates/swc/src/config/mod.rs index c9c134b3ede5..6c32aa884d51 100644 --- a/crates/swc/src/config/mod.rs +++ b/crates/swc/src/config/mod.rs @@ -92,7 +92,7 @@ pub static PLUGIN_MODULE_CACHE: Lazy, + fs_cache_store_root: Option<&str>, ) { PLUGIN_MODULE_CACHE.inner.get_or_init(|| { parking_lot::Mutex::new(swc_plugin_runner::cache::PluginModuleCache::create_inner( @@ -598,48 +598,12 @@ impl Options { // 2. embedded runtime can compiles & execute wasm #[cfg(all(feature = "plugin", not(target_arch = "wasm32")))] { - use swc_ecma_loader::resolve::Resolve; - - let plugin_resolver = CachingResolver::new( - 40, - NodeModulesResolver::new( - swc_ecma_loader::TargetEnv::Node, - Default::default(), - true, - ), - ); - if let Some(plugins) = &experimental.plugins { - // Currently swc enables filesystemcache by default on Embedded runtime plugin - // target. - init_plugin_module_cache_once(true, &experimental.cache_root); - - let mut inner_cache = PLUGIN_MODULE_CACHE - .inner - .get() - .expect("Cache should be available") - .lock(); - - // Populate cache to the plugin modules if not loaded - for plugin_config in plugins.iter() { - let plugin_name = &plugin_config.0; - - if !inner_cache.contains(plugin_name) { - let resolved_path = plugin_resolver.resolve( - &FileName::Real(PathBuf::from(plugin_name)), - plugin_name, - )?; - - let path = if let FileName::Real(value) = resolved_path.filename { - value - } else { - anyhow::bail!("Failed to resolve plugin path: {:?}", resolved_path); - }; - - inner_cache.store_bytes_from_path(&path, plugin_name)?; - tracing::debug!("Initialized WASM plugin {plugin_name}"); - } - } + crate::plugin::compile_wasm_plugins( + experimental.cache_root.as_deref(), + plugins, + ) + .context("Failed to compile wasm plugins")?; } Box::new(crate::plugin::plugins( diff --git a/crates/swc/src/lib.rs b/crates/swc/src/lib.rs index edf171a69dcd..c2ba72f855c3 100644 --- a/crates/swc/src/lib.rs +++ b/crates/swc/src/lib.rs @@ -155,7 +155,7 @@ use swc_ecma_visit::{FoldWith, VisitMutWith, VisitWith}; pub use swc_error_reporters::handler::{try_with_handler, HandlerOpts}; pub use swc_node_comments::SwcComments; use swc_timer::timer; -use swc_transform_common::output::emit; +use swc_transform_common::output::experimental_emit; use swc_typescript::fast_dts::FastDts; use tracing::warn; use url::Url; @@ -170,7 +170,7 @@ mod builder; pub mod config; mod dropped_comments_preserver; mod plugin; -mod wasm_analysis; +pub mod wasm_analysis; pub mod resolver { use std::path::PathBuf; @@ -1022,7 +1022,7 @@ impl Compiler { let pass = config.pass; let (program, output) = swc_transform_common::output::capture(|| { if let Some(dts_code) = dts_code { - emit("__swc_isolated_declarations__".into(), dts_code); + experimental_emit("__swc_isolated_declarations__".into(), dts_code); } helpers::HELPERS.set(&Helpers::new(config.external_helpers), || { diff --git a/crates/swc/src/plugin.rs b/crates/swc/src/plugin.rs index 34fc1386b031..a3b8ab62dead 100644 --- a/crates/swc/src/plugin.rs +++ b/crates/swc/src/plugin.rs @@ -6,13 +6,23 @@ allow(unused) )] +use std::path::PathBuf; + +use anyhow::{Context, Result}; +use common::FileName; use serde::{Deserialize, Serialize}; use swc_common::errors::HANDLER; use swc_ecma_ast::Pass; #[cfg(feature = "plugin")] use swc_ecma_ast::*; +use swc_ecma_loader::{ + resolve::Resolve, + resolvers::{lru::CachingResolver, node::NodeModulesResolver}, +}; use swc_ecma_visit::{fold_pass, noop_fold_type, Fold}; +use crate::config::{init_plugin_module_cache_once, PLUGIN_MODULE_CACHE}; + /// A tuple represents a plugin. /// /// First element is a resolvable name to the plugin, second is a JSON object @@ -190,3 +200,45 @@ impl Fold for RustPlugins { } } } + +pub(crate) fn compile_wasm_plugins( + cache_root: Option<&str>, + plugins: &[PluginConfig], +) -> Result<()> { + let plugin_resolver = CachingResolver::new( + 40, + NodeModulesResolver::new(swc_ecma_loader::TargetEnv::Node, Default::default(), true), + ); + + // Currently swc enables filesystemcache by default on Embedded runtime plugin + // target. + init_plugin_module_cache_once(true, cache_root); + + let mut inner_cache = PLUGIN_MODULE_CACHE + .inner + .get() + .expect("Cache should be available") + .lock(); + + // Populate cache to the plugin modules if not loaded + for plugin_config in plugins.iter() { + let plugin_name = &plugin_config.0; + + if !inner_cache.contains(plugin_name) { + let resolved_path = plugin_resolver + .resolve(&FileName::Real(PathBuf::from(plugin_name)), plugin_name) + .with_context(|| format!("failed to resolve plugin path: {plugin_name}"))?; + + let path = if let FileName::Real(value) = resolved_path.filename { + value + } else { + anyhow::bail!("Failed to resolve plugin path: {:?}", resolved_path); + }; + + inner_cache.store_bytes_from_path(&path, plugin_name)?; + tracing::debug!("Initialized WASM plugin {plugin_name}"); + } + } + + Ok(()) +} diff --git a/crates/swc/src/wasm_analysis.rs b/crates/swc/src/wasm_analysis.rs index 4c6681e2699e..681189f45a61 100644 --- a/crates/swc/src/wasm_analysis.rs +++ b/crates/swc/src/wasm_analysis.rs @@ -4,19 +4,24 @@ use std::sync::Arc; use anyhow::{Context, Result}; use common::{ - comments::SingleThreadedComments, + comments::Comments, errors::Handler, plugin::{metadata::TransformPluginMetadataContext, serialized::PluginSerializedBytes}, Mark, SourceFile, GLOBALS, }; -use par_iter::iter::{IntoParallelRefIterator, ParallelIterator}; +use par_iter::iter::{IndexedParallelIterator, IntoParallelRefIterator, ParallelIterator}; +use rustc_hash::FxHashMap; use serde::Deserialize; use swc_config::IsModule; use swc_ecma_ast::EsVersion; use swc_ecma_parser::Syntax; use swc_ecma_transforms::resolver; -use crate::{plugin::PluginConfig, Compiler}; +use crate::{ + config::ErrorFormat, + plugin::{compile_wasm_plugins, PluginConfig}, + Compiler, +}; impl Compiler { /// Run analysis using Wasm plugins. @@ -25,8 +30,32 @@ impl Compiler { fm: Arc, handler: &Handler, opts: &WasmAnalysisOptions, - comments: SingleThreadedComments, + comments: &dyn Comments, + ) -> Result { + if cfg!(feature = "manual-tokio-runtime") { + self.run_wasm_analysis_inner(fm.clone(), handler, opts, comments) + } else { + let fm = fm.clone(); + + let fut = async move { self.run_wasm_analysis_inner(fm, handler, opts, comments) }; + if let Ok(handle) = tokio::runtime::Handle::try_current() { + handle.block_on(fut) + } else { + tokio::runtime::Runtime::new().unwrap().block_on(fut) + } + } + .with_context(|| format!("failed to analyze '{:?}'", fm.name)) + } + + fn run_wasm_analysis_inner( + &self, + fm: Arc, + handler: &Handler, + opts: &WasmAnalysisOptions, + comments: &dyn Comments, ) -> Result { + compile_wasm_plugins(opts.cache_root.as_deref(), &opts.plugins)?; + self.run(|| { GLOBALS.with(|globals| { let unresolved_mark = Mark::new(); @@ -63,74 +92,101 @@ impl Compiler { let result = opts .plugins .par_iter() + .with_min_len(1) .map(|p| { GLOBALS.set(globals, || { - let plugin_module_bytes = crate::config::PLUGIN_MODULE_CACHE - .inner - .get() - .unwrap() - .lock() - .get(&p.0) - .expect("plugin module should be loaded"); - - let plugin_name = plugin_module_bytes.get_module_name().to_string(); - let runtime = swc_plugin_runner::wasix_runtime::build_wasi_runtime( - crate::config::PLUGIN_MODULE_CACHE - .inner - .get() - .unwrap() - .lock() - .get_fs_cache_root() - .map(std::path::PathBuf::from), - ); - let mut transform_plugin_executor = - swc_plugin_runner::create_plugin_transform_executor( - &self.cm, - &unresolved_mark, - &transform_metadata_context, - plugin_module_bytes, - Some(p.1.clone()), - runtime, - ); - - let span = tracing::span!( - tracing::Level::INFO, - "execute_plugin_runner", - plugin_module = p.0.as_str() + self.inovke_wasm_analysis_plugin( + &serialized, + unresolved_mark, + &transform_metadata_context, + p, ) - .entered(); - - let (result, output) = swc_transform_common::output::capture(|| { - transform_plugin_executor - .transform(&serialized, Some(true)) - .with_context(|| { - format!( - "failed to invoke `{}` as js analysis plugin at {}", - &p.0, plugin_name - ) - }) - }); - result?; - drop(span); - - Ok(output) }) }) .collect::>>()?; + let result = result.into_iter().flatten().collect::>(); + serde_json::to_string(&result) .map_err(|e| anyhow::anyhow!("Failed to serialize output: {e}")) }) }) } + + fn inovke_wasm_analysis_plugin( + &self, + serialized: &PluginSerializedBytes, + unresolved_mark: Mark, + transform_metadata_context: &Arc, + p: &PluginConfig, + ) -> Result> { + let plugin_module_bytes = crate::config::PLUGIN_MODULE_CACHE + .inner + .get() + .unwrap() + .lock() + .get(&p.0) + .expect("plugin module should be loaded"); + + let plugin_name = plugin_module_bytes.get_module_name().to_string(); + let runtime = swc_plugin_runner::wasix_runtime::build_wasi_runtime( + crate::config::PLUGIN_MODULE_CACHE + .inner + .get() + .unwrap() + .lock() + .get_fs_cache_root() + .map(std::path::PathBuf::from), + ); + let mut transform_plugin_executor = swc_plugin_runner::create_plugin_transform_executor( + &self.cm, + &unresolved_mark, + transform_metadata_context, + plugin_module_bytes, + Some(p.1.clone()), + runtime, + ); + + let span = tracing::span!( + tracing::Level::INFO, + "execute_plugin_runner", + plugin_module = p.0.as_str() + ) + .entered(); + + let (result, output) = swc_transform_common::output::capture(|| { + transform_plugin_executor + .transform(serialized, Some(true)) + .with_context(|| { + format!( + "failed to invoke `{}` as js analysis plugin at {}", + &p.0, plugin_name + ) + }) + }); + result?; + drop(span); + + Ok(output) + } } #[derive(Debug, Deserialize)] +#[serde(rename_all = "camelCase")] pub struct WasmAnalysisOptions { #[serde(default)] pub parser: Syntax, #[serde(default)] pub module: IsModule, + #[serde(default)] + pub filename: Option, + + #[serde(default)] + pub error_format: ErrorFormat, + pub plugins: Vec, + + #[serde(default)] + pub cache_root: Option, } diff --git a/crates/swc_core/Cargo.toml b/crates/swc_core/Cargo.toml index 0ca87c20d02e..f3c7a61ff680 100644 --- a/crates/swc_core/Cargo.toml +++ b/crates/swc_core/Cargo.toml @@ -40,7 +40,7 @@ doctest = false nightly = ["swc_allocator/nightly"] -transform_common = [] +transform_common = ["dep:swc_transform_common"] # swc_ecma_loader/cache* ecma_loader_lru = ["swc_ecma_loader/lru"] @@ -187,8 +187,12 @@ common_plugin_transform = [ "__testing_transform", ] -css_plugin_transform = ["common_plugin_transform", "__css_plugin_transform"] -ecma_plugin_transform = ["common_plugin_transform", "__ecma_plugin_transform"] +css_plugin_transform = ["common_plugin_transform", "__css_plugin_transform"] +ecma_plugin_transform = [ + "common_plugin_transform", + "transform_common", + "__ecma_plugin_transform", +] # Use `stacker` to avoid stack overflow. stacker = ["swc_ecma_parser/stacker", "swc_ecma_utils/stacker"] diff --git a/crates/swc_core/src/lib.rs b/crates/swc_core/src/lib.rs index 1439bc9e790d..3b26d58d0be8 100644 --- a/crates/swc_core/src/lib.rs +++ b/crates/swc_core/src/lib.rs @@ -180,9 +180,7 @@ pub mod trace_macro { #[cfg(feature = "transform_common")] #[cfg_attr(docsrs, doc(cfg(feature = "transform_common")))] -pub mod transform_common { - pub use swc_transform_common::*; -} +pub extern crate swc_transform_common as transform_common; #[cfg(feature = "typescript")] #[cfg_attr(docsrs, doc(cfg(feature = "typescript")))] diff --git a/crates/swc_plugin_runner/src/cache.rs b/crates/swc_plugin_runner/src/cache.rs index cc5ce7321128..31900afedd7e 100644 --- a/crates/swc_plugin_runner/src/cache.rs +++ b/crates/swc_plugin_runner/src/cache.rs @@ -196,11 +196,11 @@ pub struct PluginModuleCache { impl PluginModuleCache { pub fn create_inner( enable_fs_cache_store: bool, - fs_cache_store_root: &Option, + fs_cache_store_root: Option<&str>, ) -> PluginModuleCacheInner { PluginModuleCacheInner { #[cfg(all(not(target_arch = "wasm32"), feature = "filesystem_cache"))] - fs_cache_root: fs_cache_store_root.clone(), + fs_cache_root: fs_cache_store_root.map(|s| s.to_string()), #[cfg(all(not(target_arch = "wasm32"), feature = "filesystem_cache"))] fs_cache_store: if enable_fs_cache_store { create_filesystem_cache(fs_cache_store_root) @@ -217,7 +217,7 @@ impl PluginModuleCache { #[cfg(all(not(target_arch = "wasm32"), feature = "filesystem_cache"))] #[tracing::instrument(level = "info", skip_all)] -fn create_filesystem_cache(filesystem_cache_root: &Option) -> Option { +fn create_filesystem_cache(filesystem_cache_root: Option<&str>) -> Option { let mut root_path = if let Some(root) = filesystem_cache_root { Some(PathBuf::from(root)) } else if let Ok(cwd) = current_dir() { diff --git a/crates/swc_plugin_runner/src/imported_fn/handler.rs b/crates/swc_plugin_runner/src/imported_fn/handler.rs index d03d07a821a3..ada243ca32f6 100644 --- a/crates/swc_plugin_runner/src/imported_fn/handler.rs +++ b/crates/swc_plugin_runner/src/imported_fn/handler.rs @@ -2,7 +2,7 @@ use swc_common::{ errors::{Diagnostic, HANDLER}, plugin::serialized::PluginSerializedBytes, }; -use swc_transform_common::output::emit; +use swc_transform_common::output::experimental_emit; use wasmer::FunctionEnvMut; use crate::{host_environment::BaseHostEnvironment, memory_interop::copy_bytes_into_host}; @@ -48,5 +48,5 @@ pub fn emit_output(env: FunctionEnvMut, output_ptr: i32, ou let output = PluginSerializedBytes::deserialize::<(String, String)>(&serialized) .expect("Should able to be deserialized into string"); - emit(output.0 .0, output.0 .1); + experimental_emit(output.0 .0, output.0 .1); } diff --git a/crates/swc_transform_common/Cargo.toml b/crates/swc_transform_common/Cargo.toml index 6568d7150a99..77059822f326 100644 --- a/crates/swc_transform_common/Cargo.toml +++ b/crates/swc_transform_common/Cargo.toml @@ -19,3 +19,4 @@ serde = { workspace = true } serde_json = { workspace = true } better_scoped_tls = { version = "1.0.0", path = "../better_scoped_tls" } +swc_common = { version = "8.0.1", path = "../swc_common" } diff --git a/crates/swc_transform_common/src/output.rs b/crates/swc_transform_common/src/output.rs index eacff6b29779..97c62720bf8a 100644 --- a/crates/swc_transform_common/src/output.rs +++ b/crates/swc_transform_common/src/output.rs @@ -29,11 +29,11 @@ extern "C" { /// /// This is not stable and may be removed in the future. #[cfg(target_arch = "wasm32")] -pub fn emit(key: String, value: String) { +pub fn experimental_emit(key: String, value: String) { let output = (key, value); - let diag = swc_core::common::plugin::serialized::PluginSerializedBytes::try_serialize( - &swc_core::common::plugin::serialized::VersionedSerializable::new(output), + let diag = swc_common::plugin::serialized::PluginSerializedBytes::try_serialize( + &swc_common::plugin::serialized::VersionedSerializable::new(output), ) .expect("Should able to serialize String"); let (ptr, len) = diag.as_ptr(); @@ -47,7 +47,7 @@ pub fn emit(key: String, value: String) { /// /// This is not stable and may be removed in the future. #[cfg(not(target_arch = "wasm32"))] -pub fn emit(key: String, value: String) { +pub fn experimental_emit(key: String, value: String) { OUTPUT.with(|output| { let previous = output.borrow_mut().insert(key, value); diff --git a/packages/core/binding.d.ts b/packages/core/binding.d.ts index 84b19e4899db..a6959bc8889c 100644 --- a/packages/core/binding.d.ts +++ b/packages/core/binding.d.ts @@ -6,6 +6,8 @@ export class Compiler { } export type JsCompiler = Compiler +export declare function analyze(src: string, options: Buffer, signal?: AbortSignal | undefined | null): Promise + export declare function bundle(confItems: Buffer, signal?: AbortSignal | undefined | null): Promise<{ [index: string]: { code: string, map?: string } }> export declare function getTargetTriple(): string @@ -44,6 +46,7 @@ export interface TransformOutput { code: string map?: string output?: string + diagnostics: Array } /** Hack for `Type Generation` */ diff --git a/packages/core/binding.js b/packages/core/binding.js index 8317e0cd84e8..a4ccc92a8133 100644 --- a/packages/core/binding.js +++ b/packages/core/binding.js @@ -127,15 +127,15 @@ function requireNative() { } } else if (process.platform === 'darwin') { try { - return require('./swc.darwin-universal.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@swc/core-darwin-universal') - } catch (e) { - loadErrors.push(e) - } + return require('./swc.darwin-universal.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@swc/core-darwin-universal') + } catch (e) { + loadErrors.push(e) + } if (process.arch === 'x64') { try { @@ -196,53 +196,53 @@ function requireNative() { if (process.arch === 'x64') { if (isMusl()) { try { - return require('./swc.linux-x64-musl.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@swc/core-linux-x64-musl') - } catch (e) { - loadErrors.push(e) - } + return require('./swc.linux-x64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@swc/core-linux-x64-musl') + } catch (e) { + loadErrors.push(e) + } } else { try { - return require('./swc.linux-x64-gnu.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@swc/core-linux-x64-gnu') - } catch (e) { - loadErrors.push(e) - } + return require('./swc.linux-x64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@swc/core-linux-x64-gnu') + } catch (e) { + loadErrors.push(e) + } } } else if (process.arch === 'arm64') { if (isMusl()) { try { - return require('./swc.linux-arm64-musl.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@swc/core-linux-arm64-musl') - } catch (e) { - loadErrors.push(e) - } + return require('./swc.linux-arm64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@swc/core-linux-arm64-musl') + } catch (e) { + loadErrors.push(e) + } } else { try { - return require('./swc.linux-arm64-gnu.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@swc/core-linux-arm64-gnu') - } catch (e) { - loadErrors.push(e) - } + return require('./swc.linux-arm64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@swc/core-linux-arm64-gnu') + } catch (e) { + loadErrors.push(e) + } } } else if (process.arch === 'arm') { @@ -256,29 +256,32 @@ function requireNative() { } catch (e) { loadErrors.push(e) } + } else if (process.arch === 'riscv64') { if (isMusl()) { try { - return require('./swc.linux-riscv64-musl.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@swc/core-linux-riscv64-musl') - } catch (e) { - loadErrors.push(e) - } + return require('./swc.linux-riscv64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@swc/core-linux-riscv64-musl') + } catch (e) { + loadErrors.push(e) + } + } else { try { - return require('./swc.linux-riscv64-gnu.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@swc/core-linux-riscv64-gnu') - } catch (e) { - loadErrors.push(e) - } + return require('./swc.linux-riscv64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@swc/core-linux-riscv64-gnu') + } catch (e) { + loadErrors.push(e) + } + } } else if (process.arch === 's390x') { try { @@ -291,6 +294,7 @@ function requireNative() { } catch (e) { loadErrors.push(e) } + } else { loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`)) } @@ -333,6 +337,7 @@ if (!nativeBinding) { module.exports.Compiler = nativeBinding.Compiler module.exports.JsCompiler = nativeBinding.JsCompiler +module.exports.analyze = nativeBinding.analyze module.exports.bundle = nativeBinding.bundle module.exports.getTargetTriple = nativeBinding.getTargetTriple module.exports.initCustomTraceSubscriber = nativeBinding.initCustomTraceSubscriber diff --git a/packages/core/e2e/fixtures/plugin_analyze/Cargo.lock b/packages/core/e2e/fixtures/plugin_analyze/Cargo.lock new file mode 100644 index 000000000000..ae9e18df3f86 --- /dev/null +++ b/packages/core/e2e/fixtures/plugin_analyze/Cargo.lock @@ -0,0 +1,2324 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + +[[package]] +name = "anyhow" +version = "1.0.97" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f" + +[[package]] +name = "ascii" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d92bec98840b8f03a5ff5413de5293bfcd8bf96467cf5452609f939ec6f5de16" + +[[package]] +name = "ast_node" +version = "3.0.0" +dependencies = [ + "proc-macro2", + "quote", + "swc_macros_common", + "syn", +] + +[[package]] +name = "autocfg" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "base64-simd" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "781dd20c3aff0bd194fe7d2a977dd92f21c173891f3a03b677359e5fa457e5d5" +dependencies = [ + "simd-abstraction", +] + +[[package]] +name = "better_scoped_tls" +version = "1.0.0" +dependencies = [ + "scoped-tls", +] + +[[package]] +name = "bitflags" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bumpalo" +version = "3.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" +dependencies = [ + "allocator-api2", +] + +[[package]] +name = "bytecheck" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50690fb3370fb9fe3550372746084c46f2ac8c9685c583d2be10eefd89d3d1a3" +dependencies = [ + "bytecheck_derive", + "ptr_meta", + "rancor", + "simdutf8", +] + +[[package]] +name = "bytecheck_derive" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efb7846e0cb180355c2dec69e721edafa36919850f1a9f52ffba4ebc0393cb71" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "bytes" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" + +[[package]] +name = "camino" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b96ec4966b5813e2c0507c1f86115c8c5abaadc3980879c3424042a02fd1ad3" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-platform" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e35af189006b9c0f00a064685c727031e3ed2d8020f7ba284d78cc2671bd36ea" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" +dependencies = [ + "camino", + "cargo-platform", + "semver 1.0.26", + "serde", + "serde_json", + "thiserror 1.0.69", +] + +[[package]] +name = "cargo_metadata" +version = "0.19.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd5eb614ed4c27c5d706420e4320fbe3216ab31fa1c33cd8246ac36dae4479ba" +dependencies = [ + "camino", + "cargo-platform", + "semver 1.0.26", + "serde", + "serde_json", + "thiserror 2.0.12", +] + +[[package]] +name = "castaway" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0abae9be0aaf9ea96a3b1b8b1b55c602ca751eba1b1500220cea4ecbafe7c0d5" +dependencies = [ + "rustversion", +] + +[[package]] +name = "cc" +version = "1.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fcb57c740ae1daf453ae85f16e37396f672b039e00d9d866e07ddb24e328e3a" +dependencies = [ + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "compact_str" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f86b9c4c00838774a6d902ef931eff7470720c51d90c2e32cfe15dc304737b3f" +dependencies = [ + "castaway", + "cfg-if", + "itoa", + "ryu", + "static_assertions", +] + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "darling" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" +dependencies = [ + "darling_core", + "quote", + "syn", +] + +[[package]] +name = "data-encoding" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "575f75dfd25738df5b91b8e43e14d44bda14637a58fae779fd2b064f8bf3e010" + +[[package]] +name = "debugid" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef552e6f588e446098f6ba40d89ac146c8c7b64aade83c051ee00bb5d2bc18d" +dependencies = [ + "serde", + "uuid", +] + +[[package]] +name = "derive_builder" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "507dfb09ea8b7fa618fcf76e953f4f5e192547945816d5358edffe39f6f94947" +dependencies = [ + "derive_builder_macro", +] + +[[package]] +name = "derive_builder_core" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d5bcf7b024d6835cfb3d473887cd966994907effbe9227e8c8219824d06c4e8" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "derive_builder_macro" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" +dependencies = [ + "derive_builder_core", + "syn", +] + +[[package]] +name = "diff" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" + +[[package]] +name = "difference" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "either" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "from_variant" +version = "2.0.0" +dependencies = [ + "proc-macro2", + "swc_macros_common", + "syn", +] + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasi", +] + +[[package]] +name = "glob" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash", + "allocator-api2", +] + +[[package]] +name = "hashbrown" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hstr" +version = "1.0.0" +dependencies = [ + "hashbrown 0.14.5", + "new_debug_unreachable", + "once_cell", + "phf", + "rustc-hash 2.1.1", + "triomphe", +] + +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7515e6d781098bf9f7205ab3fc7e9709d34554ae0b21ddbcb5febfa4bc7df11d" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5e8338228bdc8ab83303f16b797e177953730f601a96c25d10cb3ab0daa0cb7" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85fb8799753b75aee8d2a21d7c14d9f38921b54b3dbda10f5a3c7a7b82dba5e2" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "idna" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "if_chain" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb56e1aa765b4b4f3aadfab769793b7087bb03a4ea4920644a6d238e2df5b9ed" + +[[package]] +name = "indexmap" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058" +dependencies = [ + "equivalent", + "hashbrown 0.15.2", +] + +[[package]] +name = "is-macro" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d57a3e447e24c22647738e4607f1df1e0ec6f72e16182c4cd199f647cdfb0e4" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "itoa" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.171" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" + +[[package]] +name = "linux-raw-sys" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe7db12097d22ec582439daf8618b8fdd1a7bef6270e9af3b1ebcd30893cf413" + +[[package]] +name = "litemap" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23fb14cb19457329c82206317a5663005a4d404783dc74f4252769b0d5f42856" + +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" + +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "miette" +version = "7.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a955165f87b37fd1862df2a59547ac542c77ef6d17c666f619d1ad22dd89484" +dependencies = [ + "cfg-if", + "miette-derive", + "owo-colors", + "textwrap", + "thiserror 1.0.69", + "unicode-width 0.1.14", +] + +[[package]] +name = "miette-derive" +version = "7.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf45bf44ab49be92fd1227a3be6fc6f617f1a337c06af54981048574d8783147" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "munge" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0091202c98cf06da46c279fdf50cccb6b1c43b4521abdf6a27b4c7e71d5d9d7" +dependencies = [ + "munge_macro", +] + +[[package]] +name = "munge_macro" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "734799cf91479720b2f970c61a22850940dd91e27d4f02b1c6fc792778df2459" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "new_debug_unreachable" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" + +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", + "serde", +] + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "outref" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f222829ae9293e33a9f5e9f440c6760a3d450a64affe1846486b140db81c1f4" + +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + +[[package]] +name = "owo-colors" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1036865bb9422d3300cf723f657c2851d0e9ab12567854b1f4eba3d77decf564" + +[[package]] +name = "par-core" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b506ab63a8bd3cd38858c7bfc2d078a189dc3210c7f8c9be1bbaf50c082a0ae" +dependencies = [ + "once_cell", +] + +[[package]] +name = "par-iter" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a5b20f31e9ba82bfcbbb54a67aa40be6cebec9f668ba5753be138f9523c531a" +dependencies = [ + "either", + "par-core", +] + +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets", +] + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "phf" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078" +dependencies = [ + "phf_macros", + "phf_shared", +] + +[[package]] +name = "phf_generator" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d" +dependencies = [ + "phf_shared", + "rand", +] + +[[package]] +name = "phf_macros" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f84ac04429c13a7ff43785d75ad27569f2951ce0ffd30a3321230db2fc727216" +dependencies = [ + "phf_generator", + "phf_shared", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "phf_shared" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" +dependencies = [ + "siphasher 1.0.1", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" + +[[package]] +name = "plugin_analyze" +version = "0.1.0" +dependencies = [ + "serde", + "swc_core", +] + +[[package]] +name = "pretty_assertions" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ae130e2f271fbc2ac3a40fb1d07180839cdbbe443c7a27e1e3c13c5cac0116d" +dependencies = [ + "diff", + "yansi", +] + +[[package]] +name = "proc-macro2" +version = "1.0.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "psm" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f58e5423e24c18cc840e1c98370b3993c6649cd1678b4d24318bcf0a083cbe88" +dependencies = [ + "cc", +] + +[[package]] +name = "ptr_meta" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe9e76f66d3f9606f44e45598d155cb13ecf09f4a28199e48daf8c8fc937ea90" +dependencies = [ + "ptr_meta_derive", +] + +[[package]] +name = "ptr_meta_derive" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca414edb151b4c8d125c12566ab0d74dc9cdba36fb80eb7b848c15f495fd32d1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "quote" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rancor" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caf5f7161924b9d1cea0e4cabc97c372cea92b5f927fc13c6bca67157a0ad947" +dependencies = [ + "ptr_meta", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" + +[[package]] +name = "redox_syscall" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b8c0c260b63a8219631167be35e6a988e9554dbd323f8bd08439c8ed1302bd1" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata 0.4.9", + "regex-syntax 0.8.5", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", +] + +[[package]] +name = "regex-automata" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.8.5", +] + +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + +[[package]] +name = "relative-path" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba39f3699c378cd8970968dcbff9c43159ea4cfbd88d43c00b22f2ef10a435d2" + +[[package]] +name = "rend" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a35e8a6bf28cd121053a66aa2e6a2e3eaffad4a60012179f0e864aa5ffeff215" +dependencies = [ + "bytecheck", +] + +[[package]] +name = "rkyv" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e147371c75553e1e2fcdb483944a8540b8438c31426279553b9a8182a9b7b65" +dependencies = [ + "bytecheck", + "bytes", + "hashbrown 0.15.2", + "indexmap", + "munge", + "ptr_meta", + "rancor", + "rend", + "rkyv_derive", + "tinyvec", + "uuid", +] + +[[package]] +name = "rkyv_derive" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "246b40ac189af6c675d124b802e8ef6d5246c53e17367ce9501f8f66a81abb7a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc-hash" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver 0.9.0", +] + +[[package]] +name = "rustix" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e56a18552996ac8d29ecc3b190b4fdbb2d91ca4ec396de7bbffaf43f3d637e96" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "rustversion" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" + +[[package]] +name = "ryu" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" + +[[package]] +name = "ryu-js" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd29631678d6fb0903b69223673e122c32e9ae559d0960a38d574695ebc0ea15" + +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" +dependencies = [ + "serde", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + +[[package]] +name = "serde" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.140" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "simd-abstraction" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cadb29c57caadc51ff8346233b5cec1d240b68ce55cf1afc764818791876987" +dependencies = [ + "outref", +] + +[[package]] +name = "simdutf8" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" + +[[package]] +name = "siphasher" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" + +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + +[[package]] +name = "smallvec" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd" + +[[package]] +name = "smartstring" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fb72c633efbaa2dd666986505016c32c3044395ceaf881518399d2f4127ee29" +dependencies = [ + "autocfg", + "static_assertions", + "version_check", +] + +[[package]] +name = "sourcemap" +version = "9.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27c4ea7042fd1a155ad95335b5d505ab00d5124ea0332a06c8390d200bb1a76a" +dependencies = [ + "base64-simd", + "bitvec", + "data-encoding", + "debugid", + "if_chain", + "rustc-hash 1.1.0", + "rustc_version", + "serde", + "serde_json", + "unicode-id-start", + "url", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "stacker" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "601f9201feb9b09c00266478bf459952b9ef9a6b94edb2f21eba14ab681a60a9" +dependencies = [ + "cc", + "cfg-if", + "libc", + "psm", + "windows-sys", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "string_enum" +version = "1.0.0" +dependencies = [ + "proc-macro2", + "quote", + "swc_macros_common", + "syn", +] + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "swc_allocator" +version = "4.0.0" +dependencies = [ + "allocator-api2", + "bumpalo", + "hashbrown 0.14.5", + "ptr_meta", + "rustc-hash 2.1.1", + "triomphe", +] + +[[package]] +name = "swc_atoms" +version = "5.0.0" +dependencies = [ + "bytecheck", + "hstr", + "once_cell", + "rancor", + "rkyv", + "rustc-hash 2.1.1", + "serde", +] + +[[package]] +name = "swc_common" +version = "8.0.1" +dependencies = [ + "anyhow", + "ast_node", + "better_scoped_tls", + "bytecheck", + "cfg-if", + "either", + "from_variant", + "new_debug_unreachable", + "num-bigint", + "once_cell", + "parking_lot", + "rancor", + "rkyv", + "rustc-hash 2.1.1", + "serde", + "siphasher 0.3.11", + "sourcemap", + "swc_allocator", + "swc_atoms", + "swc_eq_ignore_macros", + "swc_visit", + "termcolor", + "tracing", + "unicode-width 0.1.14", + "url", +] + +[[package]] +name = "swc_core" +version = "17.0.0" +dependencies = [ + "once_cell", + "swc_allocator", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_transforms_base", + "swc_ecma_transforms_testing", + "swc_ecma_visit", + "swc_plugin", + "swc_plugin_macro", + "swc_plugin_proxy", + "swc_transform_common", + "vergen", +] + +[[package]] +name = "swc_ecma_ast" +version = "8.1.0" +dependencies = [ + "bitflags", + "bytecheck", + "is-macro", + "num-bigint", + "phf", + "rancor", + "rkyv", + "scoped-tls", + "string_enum", + "swc_atoms", + "swc_common", + "swc_visit", + "unicode-id-start", +] + +[[package]] +name = "swc_ecma_codegen" +version = "8.0.2" +dependencies = [ + "ascii", + "compact_str", + "memchr", + "num-bigint", + "once_cell", + "regex", + "rustc-hash 2.1.1", + "serde", + "sourcemap", + "swc_allocator", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_codegen_macros", + "tracing", +] + +[[package]] +name = "swc_ecma_codegen_macros" +version = "1.0.1" +dependencies = [ + "proc-macro2", + "quote", + "swc_macros_common", + "syn", +] + +[[package]] +name = "swc_ecma_parser" +version = "11.0.0" +dependencies = [ + "either", + "new_debug_unreachable", + "num-bigint", + "num-traits", + "phf", + "rustc-hash 2.1.1", + "serde", + "smallvec", + "smartstring", + "stacker", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "tracing", + "typed-arena", +] + +[[package]] +name = "swc_ecma_testing" +version = "8.0.0" +dependencies = [ + "anyhow", + "hex", + "sha2", + "testing", + "tracing", +] + +[[package]] +name = "swc_ecma_transforms_base" +version = "12.0.0" +dependencies = [ + "better_scoped_tls", + "bitflags", + "indexmap", + "once_cell", + "par-core", + "phf", + "rustc-hash 2.1.1", + "serde", + "smallvec", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_parser", + "swc_ecma_utils", + "swc_ecma_visit", + "tracing", +] + +[[package]] +name = "swc_ecma_transforms_testing" +version = "12.0.0" +dependencies = [ + "ansi_term", + "anyhow", + "base64", + "hex", + "serde", + "serde_json", + "sha2", + "sourcemap", + "swc_allocator", + "swc_common", + "swc_ecma_ast", + "swc_ecma_codegen", + "swc_ecma_parser", + "swc_ecma_testing", + "swc_ecma_transforms_base", + "swc_ecma_utils", + "swc_ecma_visit", + "tempfile", + "testing", +] + +[[package]] +name = "swc_ecma_utils" +version = "12.0.0" +dependencies = [ + "indexmap", + "num_cpus", + "once_cell", + "par-core", + "par-iter", + "rustc-hash 2.1.1", + "ryu-js", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_visit", + "tracing", + "unicode-id", +] + +[[package]] +name = "swc_ecma_visit" +version = "8.0.0" +dependencies = [ + "new_debug_unreachable", + "num-bigint", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_visit", + "tracing", +] + +[[package]] +name = "swc_eq_ignore_macros" +version = "1.0.0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "swc_error_reporters" +version = "9.1.1" +dependencies = [ + "anyhow", + "miette", + "once_cell", + "parking_lot", + "serde", + "serde_derive", + "serde_json", + "swc_common", +] + +[[package]] +name = "swc_macros_common" +version = "1.0.0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "swc_plugin" +version = "1.0.0" +dependencies = [ + "once_cell", +] + +[[package]] +name = "swc_plugin_macro" +version = "1.0.0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "swc_plugin_proxy" +version = "8.0.0" +dependencies = [ + "better_scoped_tls", + "bytecheck", + "rancor", + "rkyv", + "rustc-hash 2.1.1", + "swc_common", + "swc_ecma_ast", + "swc_trace_macro", + "tracing", +] + +[[package]] +name = "swc_trace_macro" +version = "2.0.0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "swc_transform_common" +version = "1.0.1" +dependencies = [ + "better_scoped_tls", + "once_cell", + "rustc-hash 2.1.1", + "serde", + "serde_json", + "swc_common", +] + +[[package]] +name = "swc_visit" +version = "2.0.0" +dependencies = [ + "either", + "new_debug_unreachable", +] + +[[package]] +name = "syn" +version = "2.0.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "tempfile" +version = "3.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7437ac7763b9b123ccf33c338a5cc1bac6f69b45a136c19bdd8a65e3916435bf" +dependencies = [ + "fastrand", + "getrandom", + "once_cell", + "rustix", + "windows-sys", +] + +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "testing" +version = "8.0.0" +dependencies = [ + "ansi_term", + "cargo_metadata 0.18.1", + "difference", + "once_cell", + "pretty_assertions", + "regex", + "rustc-hash 2.1.1", + "serde", + "serde_json", + "swc_common", + "swc_error_reporters", + "testing_macros", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "testing_macros" +version = "1.0.0" +dependencies = [ + "anyhow", + "glob", + "once_cell", + "proc-macro2", + "quote", + "regex", + "relative-path", + "syn", +] + +[[package]] +name = "textwrap" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c13547615a44dc9c452a8a534638acdf07120d4b6847c8178705da06306a3057" +dependencies = [ + "unicode-linebreak", + "unicode-width 0.2.0", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" +dependencies = [ + "thiserror-impl 2.0.12", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thread_local" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +dependencies = [ + "cfg-if", + "once_cell", +] + +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tinyvec" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09b3661f17e86524eccd4371ab0429194e0d7c008abb45f7a7495b1719463c71" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tracing" +version = "0.1.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "triomphe" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef8f7726da4807b58ea5c96fdc122f80702030edc33b35aff9190a51148ccc85" +dependencies = [ + "serde", + "stable_deref_trait", +] + +[[package]] +name = "typed-arena" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a" + +[[package]] +name = "typenum" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" + +[[package]] +name = "unicode-id" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10103c57044730945224467c09f71a4db0071c123a0648cc3e818913bde6b561" + +[[package]] +name = "unicode-id-start" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f322b60f6b9736017344fa0635d64be2f458fbc04eef65f6be22976dd1ffd5b" + +[[package]] +name = "unicode-ident" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" + +[[package]] +name = "unicode-linebreak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" + +[[package]] +name = "unicode-width" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" + +[[package]] +name = "unicode-width" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" + +[[package]] +name = "url" +version = "2.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "uuid" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "458f7a779bf54acc9f347480ac654f68407d3aab21269a6e3c9f922acd9e2da9" + +[[package]] +name = "valuable" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" + +[[package]] +name = "vergen" +version = "9.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0d2f179f8075b805a43a2a21728a46f0cc2921b3c58695b28fa8817e103cd9a" +dependencies = [ + "anyhow", + "cargo_metadata 0.19.2", + "derive_builder", + "regex", + "rustversion", + "vergen-lib", +] + +[[package]] +name = "vergen-lib" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b07e6010c0f3e59fcb164e0163834597da68d1f864e2b8ca49f74de01e9c166" +dependencies = [ + "anyhow", + "derive_builder", + "rustversion", +] + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wasi" +version = "0.14.2+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" +dependencies = [ + "wit-bindgen-rt", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "wit-bindgen-rt" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" +dependencies = [ + "bitflags", +] + +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + +[[package]] +name = "yansi" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" + +[[package]] +name = "yoke" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zerofrom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/packages/core/e2e/fixtures/plugin_analyze/Cargo.toml b/packages/core/e2e/fixtures/plugin_analyze/Cargo.toml new file mode 100644 index 000000000000..e94652856535 --- /dev/null +++ b/packages/core/e2e/fixtures/plugin_analyze/Cargo.toml @@ -0,0 +1,17 @@ +[workspace] + +[package] +edition = "2021" +name = "plugin_analyze" +publish = false +version = "0.1.0" + +[lib] +crate-type = ["cdylib"] + +[dependencies] +serde = "1.0.140" +# Intentionally referencing published version, known to not contain new AST struct changes. +# Be careful to change this dependency version. Unless there isn't explicit reason to do so, +# do not change. +swc_core = { path = "../../../../../crates/swc_core",features = ["ecma_plugin_transform"] } diff --git a/packages/core/e2e/fixtures/plugin_analyze/src/lib.rs b/packages/core/e2e/fixtures/plugin_analyze/src/lib.rs new file mode 100644 index 000000000000..9abbb21c2014 --- /dev/null +++ b/packages/core/e2e/fixtures/plugin_analyze/src/lib.rs @@ -0,0 +1,12 @@ +use swc_core::{ + ecma::ast::Program, + plugin::{plugin_transform, proxies::TransformPluginProgramMetadata}, + transform_common::output::experimental_emit, +}; + +#[plugin_transform] +pub fn process(program: Program, _metadata: TransformPluginProgramMetadata) -> Program { + experimental_emit("test".into(), "test".into()); + + program +} diff --git a/packages/core/e2e/plugins/plugins.analyze.test.js b/packages/core/e2e/plugins/plugins.analyze.test.js new file mode 100644 index 000000000000..103dc3927ec7 --- /dev/null +++ b/packages/core/e2e/plugins/plugins.analyze.test.js @@ -0,0 +1,135 @@ +/// +const { getPkgRoot } = require("../utils"); +const { spawn } = require("child_process"); +const path = require("path"); + +const waitProcessAsync = async (proc) => + new Promise((resolve, reject) => { + proc.on("exit", (code) => { + if (code === 0) { + resolve(code); + } else { + reject(code); + } + }); + }); + +const getPluginAbsolutePath = (feature) => + path.join( + getPkgRoot(), + `e2e/fixtures/${feature}/target/wasm32-wasi/debug/${feature}.wasm` + ); + +/** + * Build host bindings with specific schema version flag. + */ +const buildHost = async (feature) => { + const args = [ + "build", + "--cargo-name", + "binding_core_node", + "--cargo-cwd", + "./bindings/binding_core_node", + `--cargo-flags=--no-default-features --features swc_v1 --features ${feature}`, + "--config", + `./node-swc/e2e/fixtures/napi.host.${feature}.config.js`, + ]; + + const options = { cwd: getPkgRoot(), stdio: "inherit" }; + + const proc = + process.platform == "win32" + ? spawn("cmd", ["/s", "/c", "napi", ...args], options) + : spawn("napi", args, options); + await waitProcessAsync(proc); +}; + +const buildPlugin = async (feature) => { + const args = [ + "build", + "--manifest-path", + `./e2e/fixtures/${feature}/Cargo.toml`, + "--target", + "wasm32-wasi", + ]; + + const options = { cwd: getPkgRoot(), stdio: "inherit" }; + + console.log(`Building plugins: ${feature}: ${args}`); + const proc = + process.platform == "win32" + ? spawn("cmd", ["/s", "/c", "cargo", ...args], options) + : spawn("cargo", args, options); + await waitProcessAsync(proc); +}; + +describe("Analysis Plugins", () => { + describe("Emits output with plugin", () => { + const versionMatrix = [ + { + host: "plugin_transform_schema_v1", + plugin: ["plugin_analyze"], + }, + ]; + + describe.each(versionMatrix)( + "Host schema version '$host'", + ({ host, plugin: pluginVersions }) => { + // For v1 struct, we use published, prebuilt bindings as-is. + // Note this relies on devDependencies in package.json to pick up last known version - + // Do not update its version unless explicitly required. + const shouldUsePrebuiltHost = host.includes( + "plugin_transform_schema_v1" + ); + + // Put arbitrary large number for timeout to ensure test doesn't timeout due to native binaries build time. + beforeAll(async () => { + if (!shouldUsePrebuiltHost) { + await buildHost(host); + } + await Promise.all( + pluginVersions.map((p) => buildPlugin(p)) + ); + }, 10000000); + + const analyze = async (code, feature) => { + const options = { + plugins: [[getPluginAbsolutePath(feature), {}]], + }; + + if (shouldUsePrebuiltHost) { + const { experimental_analyze } = require("@swc/core"); + + return await experimental_analyze(code, options); + } else { + const { analyze } = require(path.resolve( + getPkgRoot(), + `swc_host_${host}.node` + )); + + return analyze( + code, + Buffer.from(JSON.stringify(options)) + ); + } + }; + + it.each(pluginVersions)( + `Should work with plugin schema version %s`, + async (pluginVersion) => { + const result = await analyze( + `console.log('boo')`, + pluginVersion + ); + + // Consider test passes if plugin transform is successful. + expect(result).toMatchInlineSnapshot( + `"{"test":"test"}"` + ); + }, + 60000 + ); + } + ); + }); +}); diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 5c7b5ecb0c4e..e06f409dbc1a 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -8,6 +8,7 @@ import type { Script, Program, JsMinifyOptions, + WasmAnalysisOptions, } from "@swc/types"; export type * from "@swc/types"; // @ts-ignore @@ -393,6 +394,14 @@ export class Compiler { const compiler = new Compiler(); + +export function experimental_analyze( + src: string, + options?: WasmAnalysisOptions +): Promise { + return bindings.analyze(src, toBuffer(options)); +} + /** * @deprecated Use Rust instead. */ diff --git a/packages/types/index.ts b/packages/types/index.ts index dd443f69242f..fbb2b86a0e81 100644 --- a/packages/types/index.ts +++ b/packages/types/index.ts @@ -351,7 +351,7 @@ export interface TerserMangleOptions { reserved?: string[]; } -export interface TerserManglePropertiesOptions {} +export interface TerserManglePropertiesOptions { } /** * Programmatic options. @@ -665,7 +665,7 @@ export interface JscConfig { * * Second parameter of tuple is JSON based configuration for the plugin. */ - plugins?: Array<[string, Record]>; + plugins?: WasmPlugin[]; /** * Run Wasm plugins before stripping TypeScript or decorators. @@ -910,27 +910,27 @@ export interface ReactConfig { * Enable fast refresh feature for React app */ refresh?: - | boolean - | { - /** - * Identifier for the `react-refresh` register function. - * - * Defaults to `$RefreshReg$` - */ - refreshReg?: string; - /** - * Identifier for the `react-refresh` signature function. - * - * Defaults to `$RefreshSig$` - */ - refreshSig?: string; - /** - * Flag to emit full signatures. - * - * Defaults to `false` - */ - emitFullSignatures?: boolean; - }; + | boolean + | { + /** + * Identifier for the `react-refresh` register function. + * + * Defaults to `$RefreshReg$` + */ + refreshReg?: string; + /** + * Identifier for the `react-refresh` signature function. + * + * Defaults to `$RefreshSig$` + */ + refreshSig?: string; + /** + * Flag to emit full signatures. + * + * Defaults to `false` + */ + emitFullSignatures?: boolean; + }; /** * jsx runtime @@ -1213,7 +1213,7 @@ export interface Output { map?: string; } -export interface MatchPattern {} +export interface MatchPattern { } // ------------------------------- // ---------- Ast nodes ---------- @@ -1445,7 +1445,7 @@ export type Expression = | OptionalChainingExpression | Invalid; -interface ExpressionBase extends Node, HasSpan {} +interface ExpressionBase extends Node, HasSpan { } export interface Identifier extends ExpressionBase { type: "Identifier"; @@ -2912,3 +2912,20 @@ export type Accessibility = "public" | "protected" | "private"; export interface Invalid extends Node, HasSpan { type: "Invalid"; } + + +export type WasmAnalysisOptions = { + parser?: ParserConfig, + + module?: true | false | 'unknown' + + filename?: string; + + errorFormat?: 'json' | 'normal' + + cacheRoot?: string; + + plugins: WasmPlugin[] +} + +export type WasmPlugin = [wasmPackage: string, config: Record] \ No newline at end of file From c7a11bbba6a2a67bfa21dda128012dbd6eda1580 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Mon, 31 Mar 2025 14:26:47 +0900 Subject: [PATCH 04/12] fix import issue --- crates/swc/src/plugin.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/swc/src/plugin.rs b/crates/swc/src/plugin.rs index a3b8ab62dead..1644f12dbea3 100644 --- a/crates/swc/src/plugin.rs +++ b/crates/swc/src/plugin.rs @@ -21,8 +21,6 @@ use swc_ecma_loader::{ }; use swc_ecma_visit::{fold_pass, noop_fold_type, Fold}; -use crate::config::{init_plugin_module_cache_once, PLUGIN_MODULE_CACHE}; - /// A tuple represents a plugin. /// /// First element is a resolvable name to the plugin, second is a JSON object @@ -212,9 +210,9 @@ pub(crate) fn compile_wasm_plugins( // Currently swc enables filesystemcache by default on Embedded runtime plugin // target. - init_plugin_module_cache_once(true, cache_root); + crate::config::init_plugin_module_cache_once(true, cache_root); - let mut inner_cache = PLUGIN_MODULE_CACHE + let mut inner_cache = crate::config::PLUGIN_MODULE_CACHE .inner .get() .expect("Cache should be available") From 607ae564cc1e903bfdfd5ee24a8c73a2fd1b21aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Mon, 31 Mar 2025 14:32:12 +0900 Subject: [PATCH 05/12] #[cfg(feature = "plugin")] --- crates/swc/src/plugin.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/swc/src/plugin.rs b/crates/swc/src/plugin.rs index 1644f12dbea3..598b280a45cc 100644 --- a/crates/swc/src/plugin.rs +++ b/crates/swc/src/plugin.rs @@ -199,6 +199,7 @@ impl Fold for RustPlugins { } } +#[cfg(feature = "plugin")] pub(crate) fn compile_wasm_plugins( cache_root: Option<&str>, plugins: &[PluginConfig], From bc84b2e22e676273bbe68e290b8f696feaadbaf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Mon, 31 Mar 2025 14:40:37 +0900 Subject: [PATCH 06/12] feature flag --- crates/swc_transform_common/Cargo.toml | 3 +++ crates/swc_transform_common/src/output.rs | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/swc_transform_common/Cargo.toml b/crates/swc_transform_common/Cargo.toml index 77059822f326..36af3179ee1d 100644 --- a/crates/swc_transform_common/Cargo.toml +++ b/crates/swc_transform_common/Cargo.toml @@ -12,6 +12,9 @@ version = "1.0.1" all-features = true rustdoc-args = ["--cfg", "docsrs"] +[features] +plugin-mode = [] + [dependencies] once_cell = { workspace = true } rustc-hash = { workspace = true } diff --git a/crates/swc_transform_common/src/output.rs b/crates/swc_transform_common/src/output.rs index 97c62720bf8a..04eec85bba90 100644 --- a/crates/swc_transform_common/src/output.rs +++ b/crates/swc_transform_common/src/output.rs @@ -20,7 +20,7 @@ pub fn capture(f: impl FnOnce() -> Ret) -> (Ret, FxHashMap) (ret, output.into_inner()) } -#[cfg(target_arch = "wasm32")] +#[cfg(feature = "plugin-mode")] extern "C" { fn __emit_output(output_ptr: u32, output_len: u32); } @@ -28,7 +28,7 @@ extern "C" { /// (Experimental) Emits a value to the JS caller. /// /// This is not stable and may be removed in the future. -#[cfg(target_arch = "wasm32")] +#[cfg(feature = "plugin-mode")] pub fn experimental_emit(key: String, value: String) { let output = (key, value); @@ -46,7 +46,7 @@ pub fn experimental_emit(key: String, value: String) { /// (Experimental) Emits a value to the JS caller. /// /// This is not stable and may be removed in the future. -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(feature = "plugin-mode"))] pub fn experimental_emit(key: String, value: String) { OUTPUT.with(|output| { let previous = output.borrow_mut().insert(key, value); From 869d3f5db7727b1757e91dc60cb7a0cc4cf561f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Mon, 31 Mar 2025 14:40:58 +0900 Subject: [PATCH 07/12] target_arch --- crates/swc_transform_common/src/output.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/swc_transform_common/src/output.rs b/crates/swc_transform_common/src/output.rs index 04eec85bba90..9774408d54e1 100644 --- a/crates/swc_transform_common/src/output.rs +++ b/crates/swc_transform_common/src/output.rs @@ -20,7 +20,7 @@ pub fn capture(f: impl FnOnce() -> Ret) -> (Ret, FxHashMap) (ret, output.into_inner()) } -#[cfg(feature = "plugin-mode")] +#[cfg(all(feature = "plugin-mode", target_arch = "wasm32"))] extern "C" { fn __emit_output(output_ptr: u32, output_len: u32); } @@ -28,7 +28,7 @@ extern "C" { /// (Experimental) Emits a value to the JS caller. /// /// This is not stable and may be removed in the future. -#[cfg(feature = "plugin-mode")] +#[cfg(all(feature = "plugin-mode", target_arch = "wasm32"))] pub fn experimental_emit(key: String, value: String) { let output = (key, value); @@ -46,7 +46,7 @@ pub fn experimental_emit(key: String, value: String) { /// (Experimental) Emits a value to the JS caller. /// /// This is not stable and may be removed in the future. -#[cfg(not(feature = "plugin-mode"))] +#[cfg(not(all(feature = "plugin-mode", target_arch = "wasm32")))] pub fn experimental_emit(key: String, value: String) { OUTPUT.with(|output| { let previous = output.borrow_mut().insert(key, value); From 6a5e31145f8ab8730d4694e48640bd1231fb8be7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Mon, 31 Mar 2025 14:41:33 +0900 Subject: [PATCH 08/12] plugin mode --- crates/swc_core/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/swc_core/Cargo.toml b/crates/swc_core/Cargo.toml index f3c7a61ff680..acc582d24988 100644 --- a/crates/swc_core/Cargo.toml +++ b/crates/swc_core/Cargo.toml @@ -191,6 +191,7 @@ css_plugin_transform = ["common_plugin_transform", "__css_plugin_transform"] ecma_plugin_transform = [ "common_plugin_transform", "transform_common", + "transform_common/plugin-mode", "__ecma_plugin_transform", ] From 3b9874b9768656e3988e7ce729be81459b32a96d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Mon, 31 Mar 2025 14:41:50 +0900 Subject: [PATCH 09/12] fix --- crates/swc_core/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/swc_core/Cargo.toml b/crates/swc_core/Cargo.toml index acc582d24988..48489e9b89a9 100644 --- a/crates/swc_core/Cargo.toml +++ b/crates/swc_core/Cargo.toml @@ -191,7 +191,7 @@ css_plugin_transform = ["common_plugin_transform", "__css_plugin_transform"] ecma_plugin_transform = [ "common_plugin_transform", "transform_common", - "transform_common/plugin-mode", + "swc_transform_common/plugin-mode", "__ecma_plugin_transform", ] From 353a36a455aa9838db49e953a6e8be54ba1d3d1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Mon, 31 Mar 2025 15:20:10 +0900 Subject: [PATCH 10/12] wasm32-wasip1 --- packages/core/e2e/plugins/plugins.analyze.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/e2e/plugins/plugins.analyze.test.js b/packages/core/e2e/plugins/plugins.analyze.test.js index 103dc3927ec7..bf17a3b79850 100644 --- a/packages/core/e2e/plugins/plugins.analyze.test.js +++ b/packages/core/e2e/plugins/plugins.analyze.test.js @@ -17,7 +17,7 @@ const waitProcessAsync = async (proc) => const getPluginAbsolutePath = (feature) => path.join( getPkgRoot(), - `e2e/fixtures/${feature}/target/wasm32-wasi/debug/${feature}.wasm` + `e2e/fixtures/${feature}/target/wasm32-wasip1/debug/${feature}.wasm` ); /** @@ -50,7 +50,7 @@ const buildPlugin = async (feature) => { "--manifest-path", `./e2e/fixtures/${feature}/Cargo.toml`, "--target", - "wasm32-wasi", + "wasm32-wasip1", ]; const options = { cwd: getPkgRoot(), stdio: "inherit" }; From cc71d4efda084e58898c573a9140ac63c8e35c1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Mon, 31 Mar 2025 15:21:46 +0900 Subject: [PATCH 11/12] fix plugin --- .../tests/fixture/swc_internal_plugin/Cargo.lock | 2 ++ .../tests/fixture/swc_internal_plugin/src/lib.rs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/swc_plugin_runner/tests/fixture/swc_internal_plugin/Cargo.lock b/crates/swc_plugin_runner/tests/fixture/swc_internal_plugin/Cargo.lock index 4a90388dfb6a..15789405625f 100644 --- a/crates/swc_plugin_runner/tests/fixture/swc_internal_plugin/Cargo.lock +++ b/crates/swc_plugin_runner/tests/fixture/swc_internal_plugin/Cargo.lock @@ -1437,6 +1437,7 @@ dependencies = [ "swc_plugin", "swc_plugin_macro", "swc_plugin_proxy", + "swc_transform_common", "vergen", ] @@ -1707,6 +1708,7 @@ dependencies = [ "rustc-hash 2.1.1", "serde", "serde_json", + "swc_common", ] [[package]] diff --git a/crates/swc_plugin_runner/tests/fixture/swc_internal_plugin/src/lib.rs b/crates/swc_plugin_runner/tests/fixture/swc_internal_plugin/src/lib.rs index 816dc5c7af40..5e8e06ec5dbd 100644 --- a/crates/swc_plugin_runner/tests/fixture/swc_internal_plugin/src/lib.rs +++ b/crates/swc_plugin_runner/tests/fixture/swc_internal_plugin/src/lib.rs @@ -8,7 +8,7 @@ use swc_core::{ }, quote, }; -use swc_transform_common::output::emit; +use swc_transform_common::output::experimental_emit; struct ConsoleOutputReplacer { metadata: TransformPluginProgramMetadata, @@ -135,7 +135,7 @@ pub fn process(mut program: Program, metadata: TransformPluginProgramMetadata) - dbg!(); - emit("foo".into(), "bar".into()); + experimental_emit("foo".into(), "bar".into()); dbg!(); From dedc6efa9aed60800152ed58c555a7f2ca528e9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Mon, 31 Mar 2025 15:52:38 +0900 Subject: [PATCH 12/12] fix --- crates/swc_plugin_runner/tests/ecma_integration.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/swc_plugin_runner/tests/ecma_integration.rs b/crates/swc_plugin_runner/tests/ecma_integration.rs index 442851eb12a1..7e4be49ba4ee 100644 --- a/crates/swc_plugin_runner/tests/ecma_integration.rs +++ b/crates/swc_plugin_runner/tests/ecma_integration.rs @@ -219,9 +219,12 @@ fn internal() { None, ); - plugin_transform_executor - .transform(&program, Some(false)) - .expect("Plugin should apply transform") + capture(|| { + plugin_transform_executor + .transform(&program, Some(false)) + .expect("Plugin should apply transform") + }) + .1 }); eprintln!("Second run retured");