diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index 06b43a24bd3..2b05c22e46b 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -32,7 +32,7 @@ jobs: yarn build - name: Print binary size - run: ls -al ./target/release/libnode* + run: ls -al ./target/release/libbinding* benchmark: name: Performance regression check @@ -71,7 +71,7 @@ jobs: yarn - name: Run benchmark - run: cargo bench --workspace --exclude swc_plugin --exclude wasm --exclude swc_cli --exclude node -- --output-format bencher | tee output.txt + run: cargo bench --workspace --exclude swc_plugin --exclude binding_core_wasm --exclude swc_cli --exclude binding_core_node -- --output-format bencher | tee output.txt - name: Download previous benchmark results run: mkdir raw-data && curl -o raw-data/benchmark-data.json https://raw.githubusercontent.com/swc-project/raw-data/gh-pages/benchmark-data.json diff --git a/.github/workflows/cargo.yml b/.github/workflows/cargo.yml index c0ce3a3b48a..4ec42fc3daf 100644 --- a/.github/workflows/cargo.yml +++ b/.github/workflows/cargo.yml @@ -100,17 +100,16 @@ jobs: os: ubuntu-latest - crate: better_scoped_tls os: ubuntu-latest + - crate: binding_core_node + os: ubuntu-latest + - crate: binding_core_wasm + os: ubuntu-latest - crate: enum_kind os: ubuntu-latest - crate: from_variant os: ubuntu-latest - crate: jsdoc os: ubuntu-latest - - crate: node - os: ubuntu-latest - check: | - cargo check --features plugin - cargo check --no-default-features --features plugin --features swc_v2 - crate: node_macro_deps os: ubuntu-latest - crate: preset_env_base @@ -162,6 +161,8 @@ jobs: os: ubuntu-latest - crate: swc_css_parser os: windows-latest + - crate: swc_css_prefixer + os: ubuntu-latest - crate: swc_css_utils os: ubuntu-latest - crate: swc_css_visit @@ -291,6 +292,8 @@ jobs: os: windows-latest - crate: swc_plugin_macro os: ubuntu-latest + - crate: swc_plugin_proxy + os: ubuntu-latest - crate: swc_plugin_runner os: ubuntu-latest - crate: swc_plugin_runner @@ -301,8 +304,6 @@ jobs: os: ubuntu-latest - crate: swc_plugin_testing os: windows-latest - - crate: swc_css_prefixer - os: ubuntu-latest - crate: swc_timer os: ubuntu-latest - crate: swc_trace_macro @@ -317,8 +318,6 @@ jobs: os: ubuntu-latest - crate: testing_macros os: ubuntu-latest - - crate: wasm - os: ubuntu-latest steps: - name: Handle line endings diff --git a/.github/workflows/publish-wasm.yml b/.github/workflows/publish-wasm.yml index f72eb57dd56..667faa12457 100644 --- a/.github/workflows/publish-wasm.yml +++ b/.github/workflows/publish-wasm.yml @@ -39,12 +39,12 @@ jobs: run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh - name: Build - run: (cd crates/wasm && wasm-pack build --release --scope=swc --target nodejs) + run: (cd crates/binding_core_wasm && wasm-pack build --release --scope=swc --target nodejs) - name: Publish run: | echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc - (cd crates/wasm/pkg && npm publish --access public) + (cd crates/binding_core_wasm/pkg && npm publish --access public) env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} @@ -77,17 +77,17 @@ jobs: run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh - name: Build - run: (cd crates/wasm && wasm-pack build --release --scope=swc --target web) + run: (cd crates/binding_core_wasm && wasm-pack build --release --scope=swc --target web) - name: Rename run: | sed -i'' -e 's/"name": "@swc\/wasm"/"name": "@swc\/wasm-web"/g' package.json - working-directory: crates/wasm/pkg + working-directory: crates/binding_core_wasm/pkg - name: Publish run: | echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc - (cd crates/wasm/pkg && npm publish --access public) + (cd crates/binding_core_wasm/pkg && npm publish --access public) env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 39ace11ae86..db6f39d49db 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -46,9 +46,9 @@ jobs: - name: Build run: | - (cd crates/wasm && yarn) - (cd crates/wasm && ./scripts/build.sh --features plugin) + (cd crates/binding_core_wasm && yarn) + (cd crates/binding_core_wasm && ./scripts/build.sh --features plugin) - name: Test run: | - (cd crates/wasm && ./scripts/test.sh) + (cd crates/binding_core_wasm && ./scripts/test.sh) diff --git a/Cargo.lock b/Cargo.lock index 73855703474..9db4e1a2262 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -166,6 +166,61 @@ dependencies = [ "scoped-tls", ] +[[package]] +name = "binding_core_node" +version = "0.1.0" +dependencies = [ + "anyhow", + "backtrace", + "napi", + "napi-build", + "napi-derive", + "node_macro_deps", + "path-clean", + "serde", + "serde_json", + "swc", + "swc_atoms", + "swc_bundler", + "swc_common", + "swc_ecma_ast", + "swc_ecma_lints", + "swc_ecma_loader", + "swc_ecma_parser", + "swc_node_base", + "swc_node_bundler", + "swc_plugin_runner", + "tracing", + "tracing-chrome", + "tracing-futures", + "tracing-subscriber", + "wasmer", + "wasmer-wasi", +] + +[[package]] +name = "binding_core_wasm" +version = "1.2.165" +dependencies = [ + "anyhow", + "console_error_panic_hook", + "js-sys", + "once_cell", + "parking_lot_core", + "path-clean", + "serde", + "serde_json", + "swc", + "swc_common", + "swc_ecma_lints", + "swc_ecmascript", + "swc_plugin_runner", + "tracing", + "wasm-bindgen", + "wasmer", + "wasmer-wasi", +] + [[package]] name = "bitflags" version = "1.3.2" @@ -1592,38 +1647,6 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" -[[package]] -name = "node" -version = "0.1.0" -dependencies = [ - "anyhow", - "backtrace", - "napi", - "napi-build", - "napi-derive", - "node_macro_deps", - "path-clean", - "serde", - "serde_json", - "swc", - "swc_atoms", - "swc_bundler", - "swc_common", - "swc_ecma_ast", - "swc_ecma_lints", - "swc_ecma_loader", - "swc_ecma_parser", - "swc_node_base", - "swc_node_bundler", - "swc_plugin_runner", - "tracing", - "tracing-chrome", - "tracing-futures", - "tracing-subscriber", - "wasmer", - "wasmer-wasi", -] - [[package]] name = "node_macro_deps" version = "0.1.0" @@ -4455,29 +4478,6 @@ version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" -[[package]] -name = "wasm" -version = "1.2.165" -dependencies = [ - "anyhow", - "console_error_panic_hook", - "js-sys", - "once_cell", - "parking_lot_core", - "path-clean", - "serde", - "serde_json", - "swc", - "swc_common", - "swc_ecma_lints", - "swc_ecmascript", - "swc_plugin_runner", - "tracing", - "wasm-bindgen", - "wasmer", - "wasmer-wasi", -] - [[package]] name = "wasm-bindgen" version = "0.2.79" diff --git a/Cargo.toml b/Cargo.toml index ad0bbbf317f..6169e96582b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,8 @@ [workspace] members = [ "crates/jsdoc", - "crates/node", + "crates/binding_core_node", + "crates/binding_core_wasm", "crates/swc_cli", "crates/swc_css", "crates/swc_css_lints", @@ -18,25 +19,6 @@ members = [ "crates/swc_plugin_proxy", "crates/swc_timer", "crates/swc_webpack_ast", - "crates/wasm", -] - -default-members = [ - "crates/jsdoc", - "crates/swc_cli", - "crates/swc_css", - "crates/swc_css_lints", - "crates/swc_css_prefixer", - "crates/swc_ecmascript", - "crates/swc_ecma_lints", - "crates/swc_ecma_quote", - "crates/swc_estree_compat", - "crates/swc_plugin", - "crates/swc_plugin_macro", - "crates/swc_plugin_runner", - "crates/swc_plugin_testing", - "crates/swc_timer", - "crates/swc_webpack_ast", ] [profile.release] diff --git a/crates/node/Cargo.toml b/crates/binding_core_node/Cargo.toml similarity index 98% rename from crates/node/Cargo.toml rename to crates/binding_core_node/Cargo.toml index cc98b419751..2ac21db3738 100644 --- a/crates/node/Cargo.toml +++ b/crates/binding_core_node/Cargo.toml @@ -4,7 +4,7 @@ build = "build.rs" edition = "2021" exclude = ["artifacts.json", "index.node"] license = "Apache-2.0" -name = "node" +name = "binding_core_node" publish = false version = "0.1.0" diff --git a/crates/node/build.rs b/crates/binding_core_node/build.rs similarity index 100% rename from crates/node/build.rs rename to crates/binding_core_node/build.rs diff --git a/crates/node/src/bundle.rs b/crates/binding_core_node/src/bundle.rs similarity index 100% rename from crates/node/src/bundle.rs rename to crates/binding_core_node/src/bundle.rs diff --git a/crates/node/src/lib.rs b/crates/binding_core_node/src/lib.rs similarity index 100% rename from crates/node/src/lib.rs rename to crates/binding_core_node/src/lib.rs diff --git a/crates/node/src/minify.rs b/crates/binding_core_node/src/minify.rs similarity index 100% rename from crates/node/src/minify.rs rename to crates/binding_core_node/src/minify.rs diff --git a/crates/node/src/parse.rs b/crates/binding_core_node/src/parse.rs similarity index 100% rename from crates/node/src/parse.rs rename to crates/binding_core_node/src/parse.rs diff --git a/crates/node/src/print.rs b/crates/binding_core_node/src/print.rs similarity index 100% rename from crates/node/src/print.rs rename to crates/binding_core_node/src/print.rs diff --git a/crates/node/src/transform.rs b/crates/binding_core_node/src/transform.rs similarity index 100% rename from crates/node/src/transform.rs rename to crates/binding_core_node/src/transform.rs diff --git a/crates/node/src/util.rs b/crates/binding_core_node/src/util.rs similarity index 100% rename from crates/node/src/util.rs rename to crates/binding_core_node/src/util.rs diff --git a/crates/wasm/Cargo.toml b/crates/binding_core_wasm/Cargo.toml similarity index 50% rename from crates/wasm/Cargo.toml rename to crates/binding_core_wasm/Cargo.toml index f8af5fe69fe..f888b34bd31 100644 --- a/crates/wasm/Cargo.toml +++ b/crates/binding_core_wasm/Cargo.toml @@ -3,7 +3,7 @@ authors = ["강동윤 "] description = "wasm module for swc" edition = "2021" license = "Apache-2.0" -name = "wasm" +name = "binding_core_wasm" publish = false repository = "https://github.com/swc-project/swc.git" version = "1.2.165" @@ -30,20 +30,20 @@ plugin = [ [dependencies] anyhow = "1.0.42" console_error_panic_hook = "0.1.6" -js-sys = { version = "0.3.56", optional = true } +js-sys = {version = "0.3.56", optional = true} once_cell = "1.10.0" parking_lot_core = "0.9.1" path-clean = "0.1" -serde = { version = "1", features = ["derive"] } +serde = {version = "1", features = ["derive"]} serde_json = "1" -swc = { path = "../swc" } -swc_common = { path = "../swc_common", features = ["perf"] } -swc_ecma_lints = { path = "../swc_ecma_lints", features = [ +swc = {path = "../swc"} +swc_common = {path = "../swc_common", features = ["perf"]} +swc_ecma_lints = {path = "../swc_ecma_lints", features = [ "non_critical_lints", -] } -swc_ecmascript = { path = "../swc_ecmascript" } -swc_plugin_runner = { path = "../swc_plugin_runner", default-features = false, optional = true } -tracing = { version = "0.1.32", features = ["release_max_level_off"] } -wasm-bindgen = { version = "0.2", features = ["serde-serialize"] } -wasmer = { version = "2.2.1", optional = true, default-features = false } -wasmer-wasi = { version = "2.2.1", optional = true, default-features = false } +]} +swc_ecmascript = {path = "../swc_ecmascript"} +swc_plugin_runner = {path = "../swc_plugin_runner", default-features = false, optional = true} +tracing = {version = "0.1.32", features = ["release_max_level_off"]} +wasm-bindgen = {version = "0.2", features = ["serde-serialize"]} +wasmer = {version = "2.2.1", optional = true, default-features = false} +wasmer-wasi = {version = "2.2.1", optional = true, default-features = false} diff --git a/crates/wasm/__tests__/error.js b/crates/binding_core_wasm/__tests__/error.js similarity index 100% rename from crates/wasm/__tests__/error.js rename to crates/binding_core_wasm/__tests__/error.js diff --git a/crates/wasm/__tests__/simple.js b/crates/binding_core_wasm/__tests__/simple.js similarity index 100% rename from crates/wasm/__tests__/simple.js rename to crates/binding_core_wasm/__tests__/simple.js diff --git a/crates/wasm/example/.gitignore b/crates/binding_core_wasm/example/.gitignore similarity index 100% rename from crates/wasm/example/.gitignore rename to crates/binding_core_wasm/example/.gitignore diff --git a/crates/wasm/example/index.js b/crates/binding_core_wasm/example/index.js similarity index 100% rename from crates/wasm/example/index.js rename to crates/binding_core_wasm/example/index.js diff --git a/crates/wasm/example/package.json b/crates/binding_core_wasm/example/package.json similarity index 100% rename from crates/wasm/example/package.json rename to crates/binding_core_wasm/example/package.json diff --git a/crates/wasm/example/readme.txt b/crates/binding_core_wasm/example/readme.txt similarity index 100% rename from crates/wasm/example/readme.txt rename to crates/binding_core_wasm/example/readme.txt diff --git a/crates/wasm/example/webpack.config.js b/crates/binding_core_wasm/example/webpack.config.js similarity index 100% rename from crates/wasm/example/webpack.config.js rename to crates/binding_core_wasm/example/webpack.config.js diff --git a/crates/wasm/package.json b/crates/binding_core_wasm/package.json similarity index 100% rename from crates/wasm/package.json rename to crates/binding_core_wasm/package.json diff --git a/crates/wasm/scripts/build.sh b/crates/binding_core_wasm/scripts/build.sh similarity index 100% rename from crates/wasm/scripts/build.sh rename to crates/binding_core_wasm/scripts/build.sh diff --git a/crates/wasm/scripts/build_nodejs_release.sh b/crates/binding_core_wasm/scripts/build_nodejs_release.sh similarity index 100% rename from crates/wasm/scripts/build_nodejs_release.sh rename to crates/binding_core_wasm/scripts/build_nodejs_release.sh diff --git a/crates/wasm/scripts/build_web_release.sh b/crates/binding_core_wasm/scripts/build_web_release.sh similarity index 100% rename from crates/wasm/scripts/build_web_release.sh rename to crates/binding_core_wasm/scripts/build_web_release.sh diff --git a/crates/wasm/scripts/test.sh b/crates/binding_core_wasm/scripts/test.sh similarity index 100% rename from crates/wasm/scripts/test.sh rename to crates/binding_core_wasm/scripts/test.sh diff --git a/crates/wasm/src/lib.rs b/crates/binding_core_wasm/src/lib.rs similarity index 100% rename from crates/wasm/src/lib.rs rename to crates/binding_core_wasm/src/lib.rs diff --git a/package.json b/package.json index 856cc7d2341..77f34649aee 100644 --- a/package.json +++ b/package.json @@ -59,8 +59,8 @@ "pack": "wasm-pack", "build:ts": "tsc -d", "build:wasm": "npm-run-all \"pack -- build ./crates/wasm --scope swc {1} -t {2} --features plugin\" --", - "build": "tsc -d && napi build --platform --cargo-name node --js ./node-swc/src/binding.js --dts ./node-swc/src/binding.d.ts -p node --release", - "build:dev": "tsc -d && napi build --platform --cargo-name node --js ./node-swc/src/binding.js --dts ./node-swc/src/binding.d.ts -p node", + "build": "tsc -d && napi build --platform --cargo-name binding_core_node --js ./node-swc/src/binding.js --dts ./node-swc/src/binding.d.ts -p binding_core_node --release", + "build:dev": "tsc -d && napi build --platform --cargo-name binding_core_node --js ./node-swc/src/binding.js --dts ./node-swc/src/binding.d.ts -p binding_core_node", "test": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest node-swc/__tests__", "version": "napi version -p scripts/npm" }, diff --git a/scripts/github/create-matrix.sh b/scripts/github/create-matrix.sh index f24bf85e8d4..627ac8d1b30 100755 --- a/scripts/github/create-matrix.sh +++ b/scripts/github/create-matrix.sh @@ -13,7 +13,7 @@ crates=$(\ ) # yq query syntax is weird, so we have to use jq -json_str="$(yq -o=json tests.yml)" +json_str="$(yq -o=json $SCRIPT_DIR/tests.yml)" for crate in $crates do diff --git a/scripts/github/tests.yml b/scripts/github/tests.yml index fc53229d601..1adcede946d 100644 --- a/scripts/github/tests.yml +++ b/scripts/github/tests.yml @@ -11,6 +11,8 @@ os: - swc_ecma_preset_env - swc_ecma_transforms_module - swc_ecma_transforms_testing + - swc_html_codegen + - swc_html_parser - swc_node_bundler - swc_plugin - swc_plugin_runner