Unverified Commit 4ead5fc0 authored by Benjamin Woodruff's avatar Benjamin Woodruff Committed by GitHub

next-swc-napi: Enable "plugin" feature by default (#66006)

As noted in (https://github.com/vercel/nextpack/pull/103), by not having
this as a default feature, when running the `build-native` script it's
not able to re-use any cargo caches that might already exist from a
default build.

Because this feature impacts the swc crate, everything dependent on it
can be forced to rebuild.

By making this a default feature, the hope/theory is that the number of
different ways we potentially build our dependency graph reduces, and
cargo cache hits will improve.

## Changes

- Add `plugin` to the default set of features for `next-swc-napi`.
- Consolidate `build-native-no-plugin-woa` with
`build-native-no-plugin`. Given the lack of any other default features,
these are equivalent.
- `i686-pc-windows-msvc`: Switch to `build-native-no-plugin-release` in
CI instead of just supplying the `--release` flag. This has the benefit
of also enabling `tracing/release_max_level_info`, which might reduce
the size of or speed up these builds.
- `x86_64-apple-darwin`: Remove a redundant `--release` flag in the CI
config (no expected changes).

## Testing

I've tested this locally on Linux (`pnpm run build-native`) and
Windows-on-ARM (`pnpm run build-native-no-plugin`) by making sure things
still build. I'll also make sure CI passes.
parent c3d93b12
...@@ -86,7 +86,7 @@ jobs: ...@@ -86,7 +86,7 @@ jobs:
target: 'x86_64-apple-darwin' target: 'x86_64-apple-darwin'
build: | build: |
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" && corepack enable npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" && corepack enable
turbo run build-native-release -vvv --remote-cache-timeout 90 --summarize -- --target x86_64-apple-darwin --release turbo run build-native-release -vvv --remote-cache-timeout 90 --summarize -- --target x86_64-apple-darwin
strip -x packages/next-swc/native/next-swc.*.node strip -x packages/next-swc/native/next-swc.*.node
- host: - host:
...@@ -123,7 +123,7 @@ jobs: ...@@ -123,7 +123,7 @@ jobs:
build: | build: |
corepack enable corepack enable
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}"
turbo run build-native-no-plugin -vvv --remote-cache-timeout 90 --summarize -- --release --target i686-pc-windows-msvc turbo run build-native-no-plugin-release -vvv --remote-cache-timeout 90 --summarize -- --target i686-pc-windows-msvc
target: 'i686-pc-windows-msvc' target: 'i686-pc-windows-msvc'
- host: - host:
...@@ -135,7 +135,7 @@ jobs: ...@@ -135,7 +135,7 @@ jobs:
build: | build: |
corepack enable corepack enable
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}"
turbo run build-native-no-plugin-woa-release -vvv --remote-cache-timeout 90 --summarize -- --target aarch64-pc-windows-msvc turbo run build-native-no-plugin-release -vvv --remote-cache-timeout 90 --summarize -- --target aarch64-pc-windows-msvc
- host: - host:
- 'self-hosted' - 'self-hosted'
......
...@@ -8,10 +8,13 @@ publish = false ...@@ -8,10 +8,13 @@ publish = false
crate-type = ["cdylib", "rlib"] crate-type = ["cdylib", "rlib"]
[features] [features]
# Instead of enabling all the plugin-related features by default, make it explicitly specified default = ["plugin"]
# when build (i.e napi --build --features plugin), same for the wasm as well.
# this is due to some of transitive dependencies have features cannot be enabled at the same time # Instead of unconditionally enabling all the plugin-related features, make it
# (i.e wasmer/default vs wasmer/js-default) while cargo merges all the features at once. # default, but overridable when built (i.e napi --build --no-default-features).
# This is due to some of transitive dependencies have features cannot be enabled
# at the same time (i.e wasmer/default vs wasmer/js-default) while cargo merges
# all the features at once.
plugin = [ plugin = [
"turbopack-binding/__swc_core_binding_napi_plugin", "turbopack-binding/__swc_core_binding_napi_plugin",
"turbopack-binding/__swc_core_binding_napi_plugin_filesystem_cache", "turbopack-binding/__swc_core_binding_napi_plugin_filesystem_cache",
......
...@@ -4,12 +4,11 @@ ...@@ -4,12 +4,11 @@
"private": true, "private": true,
"scripts": { "scripts": {
"clean": "node ../../scripts/rm.mjs native", "clean": "node ../../scripts/rm.mjs native",
"build-native": "napi build --platform -p next-swc-napi --cargo-cwd ../../ --cargo-name next_swc_napi --features plugin,image-extended --js false native", "build-native": "napi build --platform -p next-swc-napi --cargo-cwd ../../ --cargo-name next_swc_napi --features image-extended --js false native",
"build-native-release": "napi build --platform -p next-swc-napi --cargo-cwd ../../ --cargo-name next_swc_napi --release --features plugin,image-extended,tracing/release_max_level_info --js false native", "build-native-release": "napi build --platform -p next-swc-napi --cargo-cwd ../../ --cargo-name next_swc_napi --release --features image-extended,tracing/release_max_level_info --js false native",
"build-native-no-plugin": "napi build --platform -p next-swc-napi --cargo-cwd ../../ --cargo-name next_swc_napi --features image-webp --js false native", "build-native-no-plugin": "napi build --platform -p next-swc-napi --cargo-cwd ../../ --cargo-name next_swc_napi --cargo-flags=--no-default-features --features image-webp --js false native",
"build-native-no-plugin-woa": "napi build --platform -p next-swc-napi --cargo-cwd ../../ --cargo-name next_swc_napi --cargo-flags=--no-default-features --features image-webp --js false native", "build-native-no-plugin-release": "napi build --platform -p next-swc-napi --cargo-cwd ../../ --cargo-name next_swc_napi --release --cargo-flags=--no-default-features --features image-webp,tracing/release_max_level_info --js false native",
"build-native-no-plugin-woa-release": "napi build --platform -p next-swc-napi --cargo-cwd ../../ --cargo-name next_swc_napi --release --cargo-flags=--no-default-features --features image-webp,tracing/release_max_level_info --js false native", "build-native-wasi": "npx --package=@napi-rs/cli@3.0.0-alpha.45 napi build --platform --target wasm32-wasip1-threads -p next-swc-napi --cwd ../../ --output-dir packages/next-swc/native --no-default-features",
"build-native-wasi": "npx --package=@napi-rs/cli@3.0.0-alpha.45 napi build --platform --target wasm32-wasip1-threads -p next-swc-napi --cwd ../../ --output-dir packages/next-swc/native",
"build-wasm": "wasm-pack build crates/wasm --scope=next", "build-wasm": "wasm-pack build crates/wasm --scope=next",
"cache-build-native": "[ -d native ] && echo $(ls native)", "cache-build-native": "[ -d native ] && echo $(ls native)",
"rust-check-fmt": "cd ../..; cargo fmt -- --check", "rust-check-fmt": "cd ../..; cargo fmt -- --check",
......
...@@ -34,18 +34,7 @@ ...@@ -34,18 +34,7 @@
], ],
"outputs": ["native/*.node"] "outputs": ["native/*.node"]
}, },
"build-native-no-plugin-woa": { "build-native-no-plugin-release": {
"inputs": [
"../../.cargo/**",
"crates/**",
"../../**/Cargo.toml",
"../../**/Cargo.lock",
"../../.github/workflows/build_and_deploy.yml",
"../../rust-toolchain"
],
"outputs": ["native/*.node"]
},
"build-native-no-plugin-woa-release": {
"inputs": [ "inputs": [
"../../.cargo/**", "../../.cargo/**",
"crates/**", "crates/**",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment