Skip to content

Commit

Permalink
build(cargo): fix turbopack + next-swc build
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj committed Dec 15, 2022
1 parent 0168aa3 commit 70a5614
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 35 deletions.
14 changes: 7 additions & 7 deletions packages/next-swc/crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ pathdiff = "0.2.0"
regex = "1.5"
serde = "1"
serde_json = "1"
swc_emotion = "0.28.4"
styled_components = "0.52.8"
styled_jsx = "0.29.8"
modularize_imports = "0.25.8"
swc_emotion = "0.28.6"
styled_components = "0.52.10"
styled_jsx = "0.29.10"
modularize_imports = "0.25.10"
tracing = { version = "0.1.37", features = ["release_max_level_info"] }

swc_core = { features = [
Expand All @@ -42,9 +42,9 @@ swc_core = { features = [
"ecma_parser_typescript",
"cached",
"base"
], version = "0.45.4" }
], version = "0.48.12" }

[dev-dependencies]
swc_core = { features = ["testing_transform"], version = "0.45.4" }
testing = "0.31.14"
swc_core = { features = ["testing_transform"], version = "0.48.12" }
testing = "0.31.25"
walkdir = "2.3.2"
30 changes: 16 additions & 14 deletions packages/next-swc/crates/napi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,33 @@ publish = false
crate-type = ["cdylib", "rlib"]

[features]
default = []
default = ["rustls-tls"]
# Instead of enabling all the plugin-related features by default, make it explicitly specified
# 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
# (i.e wasmer/default vs wasmer/js-default) while cargo merges all the features at once.
plugin = [
"swc_core/plugin_transform_host_native",
"next-swc/plugin"
]
sentry_native_tls = ["_sentry_native_tls"]
sentry_rustls = ["_sentry_rustls"]
plugin = ["swc_core/plugin_transform_host_native", "next-swc/plugin"]
native-tls = ["next-dev/native-tls"]
rustls-tls = ["next-dev/rustls-tls"]

[dependencies]
anyhow = "1.0.66"
backtrace = "0.3"
fxhash = "0.2.1"
napi = { version = "2", default-features = false, features = ["napi3", "serde-json", "tokio_rt", "error_anyhow"] }
napi = { version = "2", default-features = false, features = [
"napi3",
"serde-json",
"tokio_rt",
"error_anyhow",
] }
napi-derive = "2"
next-swc = {version = "0.0.0", path = "../core"}
next-swc = { version = "0.0.0", path = "../core" }
once_cell = "1.13.0"
serde = "1"
serde_json = "1"
swc_core = { features = [
"allocator_node",
"base_concurrent", # concurrent?
"base_concurrent", # concurrent?
"base_node",
"common_concurrent",
"ecma_ast",
Expand All @@ -50,14 +52,14 @@ swc_core = { features = [
"ecma_transforms_typescript",
"ecma_utils",
"ecma_visit",
], version = "0.45.4" }
], version = "0.48.12" }
tracing = { version = "0.1.37", features = ["release_max_level_info"] }
tracing-futures = "0.2.5"
tracing-subscriber = "0.3.9"
tracing-chrome = "0.5.0"
next-dev = { git = "https://github.com/vercel/turbo.git", rev = "cc024fa59f1c3ad253e74eefe86e0386455455d1", features = ["serializable"] }
node-file-trace = { git = "https://github.com/vercel/turbo.git", rev = "cc024fa59f1c3ad253e74eefe86e0386455455d1", default-features = false, features = ["node-api"] }
mdxjs = { version = "0.1.3", features = ["serializable"] }
next-dev = { git = "https://github.com/vercel/turbo.git", rev = "2e240932d3fdd4fb141400baa259b86016d0df32", features = ["serializable"] }
node-file-trace = { git = "https://github.com/vercel/turbo.git", rev = "2e240932d3fdd4fb141400baa259b86016d0df32", default-features = false, features = ["node-api"] }
mdxjs = { version = "0.1.4", features = ["serializable"] }
# There are few build targets we can't use native-tls which default features rely on,
# allow to specify alternative (rustls) instead via features.
# Note to opt in rustls default-features should be disabled
Expand Down
25 changes: 12 additions & 13 deletions packages/next-swc/crates/wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,29 @@ crate-type = ["cdylib"]

[features]
default = ["swc_v1"]
swc_v1 = []
swc_v1 = []

plugin = [
"getrandom/js",
"swc_core/plugin_transform_host_js"
]
plugin = ["getrandom/js", "swc_core/plugin_transform_host_js"]

[dependencies]
anyhow = "1.0.66"
console_error_panic_hook = "0.1.6"
next-swc = {version = "0.0.0", path = "../core"}
next-swc = { version = "0.0.0", path = "../core" }
once_cell = "1.13.0"
parking_lot_core = "=0.8.0"
path-clean = "0.1"
serde = {version = "1", features = ["derive"]}
serde = { version = "1", features = ["derive"] }
serde_json = "1"
tracing = { version = "0.1.37", features = ["release_max_level_off","max_level_off"] }
wasm-bindgen = {version = "0.2", features = ["enable-interning"]}
tracing = { version = "0.1.37", features = [
"release_max_level_off",
"max_level_off",
] }
wasm-bindgen = { version = "0.2", features = ["enable-interning"] }
wasm-bindgen-futures = "0.4.8"
getrandom = { version = "0.2.5", optional = true, default-features = false }
js-sys = "0.3.59"
serde-wasm-bindgen = "0.4.3"
mdxjs = { version = "0.1.3", features = ["serializable"] }
mdxjs = { version = "0.1.4", features = ["serializable"] }

swc_core = { features = [
"common_concurrent",
Expand All @@ -45,9 +45,8 @@ swc_core = { features = [
"ecma_parser",
"ecma_parser_typescript",
"ecma_utils",
"ecma_visit"
], version = "0.45.4" }

"ecma_visit",
], version = "0.48.12" }

# Workaround a bug
[package.metadata.wasm-pack.profile.release]
Expand Down
4 changes: 3 additions & 1 deletion packages/next-swc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
"version": "13.0.7-canary.6",
"private": true,
"scripts": {
"build-native": "napi build --platform -p next-swc-napi --cargo-name next_swc_napi --features plugin --js false native",
"build-native": "napi build --platform -p next-swc-napi --cargo-name next_swc_napi --features plugin,rustls-tls --js false native",
"build-native-woa": "napi build --platform -p next-swc-napi --cargo-name next_swc_napi --features plugin,native-tls --js false native",
"build-native-no-plugin": "napi build --platform -p next-swc-napi --cargo-name next_swc_napi --js false native",
"build-native-no-plugin-woa": "napi build --platform -p next-swc-napi --cargo-name next_swc_napi --cargo-flags=--no-default-features --features native-tls --js false native",
"build-wasm": "wasm-pack build crates/wasm --scope=next",
"cache-build-native": "echo $(ls native)"
},
Expand Down
4 changes: 4 additions & 0 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
"dependsOn": ["^build-native-no-plugin"],
"outputs": ["native/*.node"]
},
"build-native-no-plugin-woa": {
"dependsOn": ["^build-native-no-plugin-woa"],
"outputs": ["native/*.node"]
},
"build-wasm": {
"dependsOn": ["^build-wasm"],
"outputs": ["crates/wasm/pkg/*"]
Expand Down

0 comments on commit 70a5614

Please sign in to comment.