From 9f5463dc9a5194142ef4394a0f144470bb11d2ed Mon Sep 17 00:00:00 2001 From: OJ Kwon <1210596+kwonoj@users.noreply.github.com> Date: Wed, 19 Apr 2023 09:38:36 -0700 Subject: [PATCH] build(cargo): move workspaces manifest to top level (#48198) ### What? This PR changes to the `root` of the cargo workspace to the root of repo itself, allows next-swc and other rust codebase can use repo root as workspace root. ### Why? Currently cargo manifest for the next-swc is not placed under the root of the repo, which makes invocation to the tool requires to change cwd / or set cwd. Similarly needs to open editor to the root of the cargo manifest separately to able to utilize language server kicks in. Moving manifest to the root consolidates those, so can invoke either cli / or editor to the same root of the repo. --- .../next-swc/.cargo => .cargo}/config.toml | 0 .../next-swc/.config => .config}/nextest.toml | 0 .github/CODEOWNERS | 4 +++ .github/workflows/build_test_deploy.yml | 1 - .../next-swc/.rustfmt.toml => .rustfmt.toml | 0 .vscode/settings.json | 5 +-- packages/next-swc/Cargo.lock => Cargo.lock | 0 packages/next-swc/Cargo.toml => Cargo.toml | 34 +++++++++---------- packages/next-swc/package.json | 8 ++--- .../next-swc/rust-toolchain => rust-toolchain | 0 10 files changed, 28 insertions(+), 24 deletions(-) rename {packages/next-swc/.cargo => .cargo}/config.toml (100%) rename {packages/next-swc/.config => .config}/nextest.toml (100%) rename packages/next-swc/.rustfmt.toml => .rustfmt.toml (100%) rename packages/next-swc/Cargo.lock => Cargo.lock (100%) rename packages/next-swc/Cargo.toml => Cargo.toml (74%) rename packages/next-swc/rust-toolchain => rust-toolchain (100%) diff --git a/packages/next-swc/.cargo/config.toml b/.cargo/config.toml similarity index 100% rename from packages/next-swc/.cargo/config.toml rename to .cargo/config.toml diff --git a/packages/next-swc/.config/nextest.toml b/.config/nextest.toml similarity index 100% rename from packages/next-swc/.config/nextest.toml rename to .config/nextest.toml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index debb94847e..656d628179 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -28,3 +28,7 @@ /packages/next/src/build/ @timneutkens @ijjk @shuding @vercel/web-tooling @huozhi /packages/next/src/telemetry/ @timneutkens @ijjk @shuding @padmaia /packages/next-swc/ @timneutkens @ijjk @shuding @vercel/web-tooling +Cargo.toml @timneutkens @ijjk @shuding @vercel/web-tooling +Cargo.lock @timneutkens @ijjk @shuding @vercel/web-tooling +/.cargo/config.toml @timneutkens @ijjk @shuding @vercel/web-tooling +/.config/nextest.toml @timneutkens @ijjk @shuding @vercel/web-tooling \ No newline at end of file diff --git a/.github/workflows/build_test_deploy.yml b/.github/workflows/build_test_deploy.yml index 46f7177ec3..c4230b4343 100644 --- a/.github/workflows/build_test_deploy.yml +++ b/.github/workflows/build_test_deploy.yml @@ -191,7 +191,6 @@ jobs: cargo fmt -- --check cargo clippy --all -- -D warnings -A deprecated cargo check -p next-dev --no-default-features --features cli,custom_allocator,rustls-tls,__internal_nextjs_integration_test - working-directory: packages/next-swc checkPrecompiled: name: Check Pre-compiled diff --git a/packages/next-swc/.rustfmt.toml b/.rustfmt.toml similarity index 100% rename from packages/next-swc/.rustfmt.toml rename to .rustfmt.toml diff --git a/.vscode/settings.json b/.vscode/settings.json index 76cdb85bea..2de2ef6193 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -58,8 +58,6 @@ "*.ts": "$(capture).test.ts, $(capture).test.tsx", "*.tsx": "$(capture).test.ts, $(capture).test.tsx" }, - // Allow to find the cargo project for rust-analyzer. - "rust-analyzer.linkedProjects": ["packages/next-swc/Cargo.toml"], // Compile rust-analyzer in a separate directory to avoid conflicts with the main project. "rust-analyzer.checkOnSave.extraEnv": { "CARGO_TARGET_DIR": "target/rust-analyzer" @@ -68,6 +66,9 @@ "CARGO_TARGET_DIR": "target/rust-analyzer", "RUST_BACKTRACE": "0" }, + "rust-analyzer.cargo.extraEnv": { + "CARGO_TARGET_DIR": "target/rust_analyzer" + }, "cSpell.words": [ "Entrypoints", "napi", diff --git a/packages/next-swc/Cargo.lock b/Cargo.lock similarity index 100% rename from packages/next-swc/Cargo.lock rename to Cargo.lock diff --git a/packages/next-swc/Cargo.toml b/Cargo.toml similarity index 74% rename from packages/next-swc/Cargo.toml rename to Cargo.toml index 023b4d0daa..c9305c8a04 100644 --- a/packages/next-swc/Cargo.toml +++ b/Cargo.toml @@ -1,16 +1,16 @@ [workspace] members = [ - "crates/core", - "crates/napi", - "crates/wasm", - "crates/next-build", - "crates/next-core", - "crates/next-dev", - "crates/next-dev-tests", - "crates/next-transform-font", - "crates/next-transform-dynamic", - "crates/next-transform-strip-page-exports", + "packages/next-swc/crates/core", + "packages/next-swc/crates/napi", + "packages/next-swc/crates/wasm", + "packages/next-swc/crates/next-build", + "packages/next-swc/crates/next-core", + "packages/next-swc/crates/next-dev", + "packages/next-swc/crates/next-dev-tests", + "packages/next-swc/crates/next-transform-font", + "packages/next-swc/crates/next-transform-dynamic", + "packages/next-swc/crates/next-transform-strip-page-exports", ] [profile.dev.package.swc_css_prefixer] @@ -25,15 +25,15 @@ lto = true [workspace.dependencies] # Workspace crates -next-build = { path = "crates/next-build" } -next-core = { path = "crates/next-core", default-features = false } -next-dev = { path = "crates/next-dev", default-features = false, features = [ +next-build = { path = "packages/next-swc/crates/next-build" } +next-core = { path = "packages/next-swc/crates/next-core", default-features = false } +next-dev = { path = "packages/next-swc/crates/next-dev", default-features = false, features = [ "serializable", ] } -next-dev-tests = { path = "crates/next-dev-tests" } -next-transform-font = { path = "crates/next-transform-font" } -next-transform-dynamic = { path = "crates/next-transform-dynamic" } -next-transform-strip-page-exports = { path = "crates/next-transform-strip-page-exports" } +next-dev-tests = { path = "packages/next-swc/crates/next-dev-tests" } +next-transform-font = { path = "packages/next-swc/crates/next-transform-font" } +next-transform-dynamic = { path = "packages/next-swc/crates/next-transform-dynamic" } +next-transform-strip-page-exports = { path = "packages/next-swc/crates/next-transform-strip-page-exports" } # SWC crates # Keep consistent with preset_env_base through swc_core diff --git a/packages/next-swc/package.json b/packages/next-swc/package.json index ee2014fcba..6af00bd0da 100644 --- a/packages/next-swc/package.json +++ b/packages/next-swc/package.json @@ -4,10 +4,10 @@ "private": true, "scripts": { "clean": "rm -rf ./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 --cargo-flags=--no-default-features --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-native": "napi build --platform -p next-swc-napi --cargo-cwd ../../ --cargo-name next_swc_napi --features plugin,rustls-tls --js false native", + "build-native-woa": "napi build --platform -p next-swc-napi --cargo-cwd ../../ --cargo-name next_swc_napi --cargo-flags=--no-default-features --features plugin,native-tls --js false native", + "build-native-no-plugin": "napi build --platform -p next-swc-napi --cargo-cwd ../../ --cargo-name next_swc_napi --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 native-tls --js false native", "build-wasm": "wasm-pack build crates/wasm --scope=next", "cache-build-native": "echo $(ls native)" }, diff --git a/packages/next-swc/rust-toolchain b/rust-toolchain similarity index 100% rename from packages/next-swc/rust-toolchain rename to rust-toolchain