diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 0def6c4e7097..c100e6278ef7 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -660,7 +660,7 @@ jobs: - name: Run cargo test (plugin) if: matrix.settings.crate == 'swc_plugin_runner' run: | - cargo test -p swc_plugin_runner --release --features plugin_transform_schema_v1 --features rkyv-impl + cargo test -p swc_plugin_runner --release --features plugin_transform_schema_v1 --features rkyv-impl --features ecma --features css - name: Run cargo test (swc_ecma_minifier) if: matrix.settings.crate == 'swc_ecma_minifier' diff --git a/Cargo.lock b/Cargo.lock index d524e429ca94..5b02b6ec2e2b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4371,6 +4371,7 @@ dependencies = [ "serde_json", "swc_atoms", "swc_common", + "swc_css_ast", "swc_ecma_ast", "swc_ecma_loader", "swc_ecma_parser", diff --git a/crates/swc/Cargo.toml b/crates/swc/Cargo.toml index 7c73ba1fc3e6..2842b2c29b61 100644 --- a/crates/swc/Cargo.toml +++ b/crates/swc/Cargo.toml @@ -28,7 +28,11 @@ debug = ["swc_ecma_visit/debug"] default = ["es3"] es3 = [] node = ["napi", "napi-derive"] -plugin = ["swc_plugin_runner/rkyv-impl", "swc_plugin_proxy/plugin-rt"] +plugin = [ + "swc_plugin_runner/ecma", + "swc_plugin_runner/rkyv-impl", + "swc_plugin_proxy/plugin-rt", +] plugin-bytecheck = [ "swc_plugin_runner/rkyv-bytecheck-impl", "swc_plugin_proxy/plugin-bytecheck-rt", diff --git a/crates/swc_plugin_runner/Cargo.toml b/crates/swc_plugin_runner/Cargo.toml index b6270bd02bbb..f03cc426f2be 100644 --- a/crates/swc_plugin_runner/Cargo.toml +++ b/crates/swc_plugin_runner/Cargo.toml @@ -22,19 +22,18 @@ memory_cache = [] plugin_transform_schema_v1 = ["swc_common/plugin_transform_schema_v1"] plugin_transform_schema_vtest = ["swc_common/plugin_transform_schema_vtest"] +# Enable ECMASCript support +ecma = ["swc_ecma_ast/rkyv-impl"] +# Enable CSS support +css = ["swc_css_ast/rkyv-impl"] + __rkyv = [] rkyv-bytecheck-impl = [ "__rkyv", "swc_common/plugin-bytecheck-rt", "swc_plugin_proxy/plugin-bytecheck-rt", - "swc_ecma_ast/rkyv-bytecheck-impl", -] -rkyv-impl = [ - "__rkyv", - "swc_common/plugin-rt", - "swc_plugin_proxy/plugin-rt", - "swc_ecma_ast/rkyv-impl", ] +rkyv-impl = ["__rkyv", "swc_common/plugin-rt", "swc_plugin_proxy/plugin-rt"] [dependencies] anyhow = "1.0.42" @@ -46,11 +45,11 @@ serde_json = "1.0.64" swc_common = { version = "0.29.17", path = "../swc_common", features = [ "concurrent", ] } -swc_ecma_ast = { version = "0.95.1", path = "../swc_ecma_ast" } -swc_plugin_proxy = { version = "0.23.1", path = "../swc_plugin_proxy" } - -tracing = "0.1.32" -wasmer = { version = "2.3.0", default-features = false } +swc_css_ast = { version = "0.128.1", path = "../swc_css_ast", optional = true } +swc_ecma_ast = { version = "0.95.1", path = "../swc_ecma_ast", optional = true } +swc_plugin_proxy = { version = "0.23.0", path = "../swc_plugin_proxy" } +tracing = "0.1.32" +wasmer = { version = "2.3.0", default-features = false } wasmer-wasi = { version = "2.3.0", default-features = false } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] @@ -67,9 +66,12 @@ swc_ecma_visit = { version = "0.81.1", path = "../swc_ecma_visit" } swc_node_base = { version = "0.5.8", path = "../swc_node_base" } testing = { version = "0.31.18", path = "../testing" } # This allows we can run non-wasm32 target build command while some pkg select features for wasmer/js omits its transitive deps -wasmer = "2.3.0" +swc_ecma_ast = { version = "0.95.1", path = "../swc_ecma_ast", feature = [ + "rkyv-impl", +] } +wasmer = "2.3.0" wasmer-wasi = "2.3.0" [[bench]] harness = false -name = "invoke" +name = "ecma_invoke" diff --git a/crates/swc_plugin_runner/benches/invoke.rs b/crates/swc_plugin_runner/benches/ecma_invoke.rs similarity index 100% rename from crates/swc_plugin_runner/benches/invoke.rs rename to crates/swc_plugin_runner/benches/ecma_invoke.rs diff --git a/crates/swc_plugin_runner/tests/integration.rs b/crates/swc_plugin_runner/tests/ecma_integration.rs similarity index 100% rename from crates/swc_plugin_runner/tests/integration.rs rename to crates/swc_plugin_runner/tests/ecma_integration.rs diff --git a/crates/swc_plugin_runner/tests/rkyv.rs b/crates/swc_plugin_runner/tests/ecma_rkyv.rs similarity index 100% rename from crates/swc_plugin_runner/tests/rkyv.rs rename to crates/swc_plugin_runner/tests/ecma_rkyv.rs