Skip to content

Commit

Permalink
refactor: move rust crates to the repo root directory (vercel#67780)
Browse files Browse the repository at this point in the history
### Why?
In preparation for moving all turbopack crates

Also makes them easier to work with in general.

Closes PACK-3164
  • Loading branch information
ForsakenHarmony authored Jul 22, 2024
1 parent 8a37c2e commit cad3a51
Show file tree
Hide file tree
Showing 805 changed files with 86 additions and 118 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ test/production/emit-decorator-metadata/**/*.js
!test/**/*.test.*
test/e2e/app-dir/rsc-errors/app/swc/use-client/page.js
test-timings.json
packages/next-swc/crates/**
crates/**
bench/nested-deps/**
bench/nested-deps-app-router/**
bench/heavy-npm-deps/**
Expand Down
2 changes: 1 addition & 1 deletion .github/labeler.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"examples": ["examples/**"],
"Font (next/font)": ["**/*font*"],
"tests": ["test/**", "bench/**"],
"Turbopack": ["packages/next-swc/crates/next-*/**"],
"Turbopack": ["crates/next-*/**"],
"created-by: Chrome Aurora": [
{ "type": "user", "pattern": "atcastle" },
{ "type": "user", "pattern": "devknoll" },
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ jobs:
run: turbo run build-wasm -vvv --env-mode loose --remote-cache-timeout 90 --summarize -- --target ${{ matrix.target }}

- name: Add target to folder name
run: '[[ -d "packages/next-swc/crates/wasm/pkg" ]] && mv packages/next-swc/crates/wasm/pkg packages/next-swc/crates/wasm/pkg-${{ matrix.target }} || ls packages/next-swc/crates/wasm'
run: '[[ -d "crates/wasm/pkg" ]] && mv crates/wasm/pkg crates/wasm/pkg-${{ matrix.target }} || ls crates/wasm'

- name: Upload turbo summary artifact
uses: actions/upload-artifact@v4
Expand All @@ -441,7 +441,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: wasm-binaries-${{matrix.target}}
path: packages/next-swc/crates/wasm/pkg-*
path: crates/wasm/pkg-*

deploy-tarball:
if: ${{ needs.deploy-target.outputs.value != 'production' }}
Expand Down Expand Up @@ -486,7 +486,7 @@ jobs:
with:
pattern: wasm-binaries-*
merge-multiple: true
path: packages/next-swc/crates/wasm
path: crates/wasm

- name: Create tarballs
run: node scripts/create-preview-tarballs.js "${{ github.sha }}" "${{ runner.temp }}/preview-tarballs"
Expand Down Expand Up @@ -546,7 +546,7 @@ jobs:
with:
pattern: wasm-binaries-*
merge-multiple: true
path: packages/next-swc/crates/wasm
path: crates/wasm

- run: npm i -g [email protected] # need latest version for provenance (pinning to avoid bugs)
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ jobs:

uses: ./.github/workflows/build_reusable.yml
with:
afterBuild: rustup target add wasm32-unknown-unknown && curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh && node ./scripts/normalize-version-bump.js && turbo run build-wasm -- --target nodejs && git checkout . && mv packages/next-swc/crates/wasm/pkg packages/next-swc/crates/wasm/pkg-nodejs && node ./scripts/setup-wasm.mjs && NEXT_TEST_MODE=start TEST_WASM=true node run-tests.js test/production/pages-dir/production/test/index.test.ts test/e2e/streaming-ssr/index.test.ts
afterBuild: rustup target add wasm32-unknown-unknown && curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh && node ./scripts/normalize-version-bump.js && turbo run build-wasm -- --target nodejs && git checkout . && mv crates/wasm/pkg crates/wasm/pkg-nodejs && node ./scripts/setup-wasm.mjs && NEXT_TEST_MODE=start TEST_WASM=true node run-tests.js test/production/pages-dir/production/test/index.test.ts test/e2e/streaming-ssr/index.test.ts
stepName: 'test-next-swc-wasm'
secrets: inherit

Expand Down
18 changes: 9 additions & 9 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ packages/next/src/bundles/webpack/packages/lazy-compilation-*.js

.github/actions/next-stats-action/.work

packages/next-swc/crates/**/tests/**/output*
packages/next-swc/crates/core/tests/loader/issue-32553/input.js
crates/**/tests/**/output*
crates/core/tests/loader/issue-32553/input.js
# prettier destroys the directives here
packages/next-swc/crates/next-custom-transforms/tests/errors/react-server-components/client-graph/use-client/input.js
packages/next-swc/crates/next-custom-transforms/tests/errors/react-server-components/server-graph/fake-client-entry/input.js
packages/next-swc/crates/next-custom-transforms/tests/errors/server-actions/server-graph/8/input.js
packages/next-swc/crates/next-custom-transforms/tests/errors/server-actions/server-graph/9/input.js
packages/next-swc/crates/next-custom-transforms/tests/fixture/optimize-barrel/normal/4/input.js
packages/next-swc/crates/next-custom-transforms/tests/fixture/react-server-components/client-graph/client-entry/input.js
packages/next-swc/crates/next-custom-transforms/tests/fixture/react-server-components/server-graph/client-entry/input.js
crates/next-custom-transforms/tests/errors/react-server-components/client-graph/use-client/input.js
crates/next-custom-transforms/tests/errors/react-server-components/server-graph/fake-client-entry/input.js
crates/next-custom-transforms/tests/errors/server-actions/server-graph/8/input.js
crates/next-custom-transforms/tests/errors/server-actions/server-graph/9/input.js
crates/next-custom-transforms/tests/fixture/optimize-barrel/normal/4/input.js
crates/next-custom-transforms/tests/fixture/react-server-components/client-graph/client-entry/input.js
crates/next-custom-transforms/tests/fixture/react-server-components/server-graph/client-entry/input.js
packages/next-swc/native/**/*
packages/next-swc/docs/assets/**/*

Expand Down
22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ resolver = "2"

members = [
"scripts/send-trace-to-jaeger",
"packages/next-swc/crates/napi",
"packages/next-swc/crates/wasm",
"packages/next-swc/crates/next-api",
"packages/next-swc/crates/next-build-test",
"packages/next-swc/crates/next-build",
"packages/next-swc/crates/next-core",
"packages/next-swc/crates/next-custom-transforms",
"crates/napi",
"crates/wasm",
"crates/next-api",
"crates/next-build-test",
"crates/next-build",
"crates/next-core",
"crates/next-custom-transforms",
]

[workspace.lints.clippy]
Expand All @@ -25,10 +25,10 @@ opt-level = 3

[workspace.dependencies]
# Workspace crates
next-api = { path = "packages/next-swc/crates/next-api" }
next-build = { path = "packages/next-swc/crates/next-build" }
next-core = { path = "packages/next-swc/crates/next-core" }
next-custom-transforms = { path = "packages/next-swc/crates/next-custom-transforms" }
next-api = { path = "crates/next-api" }
next-build = { path = "crates/next-build" }
next-core = { path = "crates/next-core" }
next-custom-transforms = { path = "crates/next-custom-transforms" }

# SWC crates
swc_core = { version = "0.96.9", features = [
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"repository": {
"type": "git",
"url": "https://github.com/vercel/next.js",
"directory": "packages/next-swc/crates/napi/npm/darwin-arm64"
"directory": "crates/napi/npm/darwin-arm64"
},
"os": [
"darwin"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"repository": {
"type": "git",
"url": "https://github.com/vercel/next.js",
"directory": "packages/next-swc/crates/napi/npm/darwin-x64"
"directory": "crates/napi/npm/darwin-x64"
},
"os": [
"darwin"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"repository": {
"type": "git",
"url": "https://github.com/vercel/next.js",
"directory": "packages/next-swc/crates/napi/npm/linux-arm64-gnu"
"directory": "crates/napi/npm/linux-arm64-gnu"
},
"os": [
"linux"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"repository": {
"type": "git",
"url": "https://github.com/vercel/next.js",
"directory": "packages/next-swc/crates/napi/npm/linux-arm64-musl"
"directory": "crates/napi/npm/linux-arm64-musl"
},
"os": [
"linux"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"repository": {
"type": "git",
"url": "https://github.com/vercel/next.js",
"directory": "packages/next-swc/crates/napi/npm/linux-x64-gnu"
"directory": "crates/napi/npm/linux-x64-gnu"
},
"os": [
"linux"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"repository": {
"type": "git",
"url": "https://github.com/vercel/next.js",
"directory": "packages/next-swc/crates/napi/npm/linux-x64-musl"
"directory": "crates/napi/npm/linux-x64-musl"
},
"os": [
"linux"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"repository": {
"type": "git",
"url": "https://github.com/vercel/next.js",
"directory": "packages/next-swc/crates/napi/npm/win32-arm64-msvc"
"directory": "crates/napi/npm/win32-arm64-msvc"
},
"os": [
"win32"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"repository": {
"type": "git",
"url": "https://github.com/vercel/next.js",
"directory": "packages/next-swc/crates/napi/npm/win32-ia32-msvc"
"directory": "crates/napi/npm/win32-ia32-msvc"
},
"os": [
"win32"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"repository": {
"type": "git",
"url": "https://github.com/vercel/next.js",
"directory": "packages/next-swc/crates/napi/npm/win32-x64-msvc"
"directory": "crates/napi/npm/win32-x64-msvc"
},
"os": [
"win32"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"license": "UNLICENSED",
"private": true,
"scripts": {
"build": "pnpm check",
"check": "tsc --noEmit"
},
"dependencies": {
"next": "workspace:*"
}
}
19 changes: 19 additions & 0 deletions crates/next-core/js/src/entry/page-loader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/// <reference types="next/client" />

// inserted by rust code
declare const PAGE_PATH: string

// Adapted from https://github.com/vercel/next.js/blob/b7f9f1f98fc8ab602e84825105b5727272b72e7d/packages/next/src/build/webpack/loaders/next-client-pages-loader.ts
;(window.__NEXT_P = window.__NEXT_P || []).push([
PAGE_PATH,
() => {
return require('PAGE')
},
])
// @ts-expect-error module.hot exists
if (module.hot) {
// @ts-expect-error module.hot exists
module.hot.dispose(function () {
window.__NEXT_P.push([PAGE_PATH])
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,8 @@
"baseUrl": ".",
"module": "node16",
"moduleResolution": "node16",
"paths": {
"@vercel/turbopack-next/*": ["src/*"],
"@vercel/turbopack-next/pages/_app": ["node_modules/next/app"],
"@vercel/turbopack-next/pages/_document": ["node_modules/next/document"],
"@vercel/turbopack-next/pages/_error": ["node_modules/next/error"],
"@vercel/turbopack-next/internal/_error": ["node_modules/next/error"]
},
"resolveJsonModule": true,
"types": ["react/next"],
"types": ["next"],
// emit
"noEmit": true,
"stripInternal": true
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit cad3a51

Please sign in to comment.