Skip to content

Commit

Permalink
Merge branch 'canary' into feedthejim/next-1108-support-useparams-for…
Browse files Browse the repository at this point in the history
…-parallel-routes
  • Loading branch information
kodiakhq[bot] committed May 10, 2023
2 parents 96d3141 + a7fd95e commit 7d15955
Show file tree
Hide file tree
Showing 83 changed files with 717 additions and 184 deletions.
20 changes: 11 additions & 9 deletions .github/workflows/build_test_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,6 @@ jobs:
name: Test Codemods
runs-on: ubuntu-latest
needs: [build]
if: ${{ needs.build.outputs.codemodChange == 'yup' }}
timeout-minutes: 5
env:
NEXT_TELEMETRY_DISABLED: 1
Expand All @@ -683,16 +682,19 @@ jobs:

# https://github.com/actions/virtual-environments/issues/1187
- name: tune linux network
if: ${{ needs.build.outputs.codemodChange == 'yup' }}
run: sudo ethtool -K eth0 tx off rx off

- uses: actions/cache@v3
if: ${{ needs.build.outputs.codemodChange == 'yup' }}
timeout-minutes: 5
id: restore-build
with:
path: ./*
key: ${{ github.sha }}-${{ github.run_number }}

- name: Run tests
if: ${{ needs.build.outputs.codemodChange == 'yup' }}
run: docker run --rm -v $(pwd):/work mcr.microsoft.com/playwright:v1.28.1-jammy /bin/bash -c "cd /work && NODE_VERSION=${{ env.NODE_LTS_VERSION }} ./scripts/setup-node.sh && npm i -g pnpm@${PNPM_VERSION} > /dev/null && cd ./packages/next-codemod && pnpm build && pnpm test >> /proc/1/fd/1"

testIntegration:
Expand Down Expand Up @@ -1336,12 +1338,12 @@ jobs:
target: 'x86_64-apple-darwin'
build: |
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" && if [ ! -f $(dirname $(which yarn))/pnpm ]; then ln -s $(which yarn) $(dirname $(which yarn))/pnpm;fi
turbo run build-native -- --release --target x86_64-apple-darwin
turbo run build-native-release -- --target x86_64-apple-darwin --release
strip -x packages/next-swc/native/next-swc.*.node
- host: windows-latest
build: |
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" "pnpm@${PNPM_VERSION}"
turbo run build-native -- --release --target x86_64-pc-windows-msvc
turbo run build-native-release -- --target x86_64-pc-windows-msvc
target: 'x86_64-pc-windows-msvc'
- host: windows-latest
build: |
Expand All @@ -1358,7 +1360,7 @@ jobs:
rustup target add x86_64-unknown-linux-gnu &&
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" && if [ ! -f $(dirname $(which yarn))/pnpm ]; then ln -s $(which yarn) $(dirname $(which yarn))/pnpm;fi &&
unset CC_x86_64_unknown_linux_gnu && unset CC &&
turbo run build-native -- --release --target x86_64-unknown-linux-gnu &&
turbo run build-native-release -- --target x86_64-unknown-linux-gnu &&
strip packages/next-swc/native/next-swc.*.node
- host: ubuntu-latest
target: 'x86_64-unknown-linux-musl'
Expand All @@ -1370,7 +1372,7 @@ jobs:
rustup default "${RUST_TOOLCHAIN}" &&
rustup target add x86_64-unknown-linux-musl &&
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" && if [ ! -f $(dirname $(which yarn))/pnpm ]; then ln -s $(which yarn) $(dirname $(which yarn))/pnpm;fi &&
turbo run build-native -- --release --target x86_64-unknown-linux-musl &&
turbo run build-native-release -- --target x86_64-unknown-linux-musl &&
strip packages/next-swc/native/next-swc.*.node
- host: macos-latest
target: 'aarch64-apple-darwin'
Expand All @@ -1381,7 +1383,7 @@ jobs:
SYSROOT=$(xcrun --sdk macosx --show-sdk-path);
export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT";
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" && if [ ! -f $(dirname $(which yarn))/pnpm ]; then ln -s $(which yarn) $(dirname $(which yarn))/pnpm;fi
turbo run build-native -- --release --target aarch64-apple-darwin
turbo run build-native-release -- --target aarch64-apple-darwin
strip -x packages/next-swc/native/next-swc.*.node
- host: ubuntu-latest
target: 'aarch64-unknown-linux-gnu'
Expand All @@ -1394,7 +1396,7 @@ jobs:
rustup target add aarch64-unknown-linux-gnu &&
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" && if [ ! -f $(dirname $(which yarn))/pnpm ]; then ln -s $(which yarn) $(dirname $(which yarn))/pnpm;fi &&
export CC_aarch64_unknown_linux_gnu=/usr/aarch64-unknown-linux-gnu/bin/aarch64-unknown-linux-gnu-gcc &&
turbo run build-native -- --release --target aarch64-unknown-linux-gnu &&
turbo run build-native-release -- --target aarch64-unknown-linux-gnu &&
llvm-strip -x packages/next-swc/native/next-swc.*.node
- host: ubuntu-latest
target: 'aarch64-unknown-linux-musl'
Expand All @@ -1407,13 +1409,13 @@ jobs:
rustup toolchain install "${RUST_TOOLCHAIN}" &&
rustup default "${RUST_TOOLCHAIN}" &&
rustup target add aarch64-unknown-linux-musl &&
turbo run build-native -- --release --target aarch64-unknown-linux-musl &&
turbo run build-native-release -- --target aarch64-unknown-linux-musl &&
llvm-strip -x packages/next-swc/native/next-swc.*.node
- host: windows-latest
target: 'aarch64-pc-windows-msvc'
build: |
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" "pnpm@${PNPM_VERSION}"
turbo run build-native-no-plugin-woa -- --release --target aarch64-pc-windows-msvc --cargo-flags=--no-default-features
turbo run build-native-no-plugin-woa-release -- --target aarch64-pc-windows-msvc
if: ${{ needs.build.outputs.isRelease == 'true' || (needs.build.outputs.turboToken != 'empty') }}
needs: build
name: stable - ${{ matrix.settings.target }} - node@16
Expand Down
2 changes: 2 additions & 0 deletions docs/advanced-features/output-file-tracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ This will create a folder at `.next/standalone` which can then be deployed on it

Additionally, a minimal `server.js` file is also output which can be used instead of `next start`. This minimal server does not copy the `public` or `.next/static` folders by default as these should ideally be handled by a CDN instead, although these folders can be copied to the `standalone/public` and `standalone/.next/static` folders manually, after which `server.js` file will serve these automatically.

> **Note**: If [`distDir`](/docs/api-reference/next.config.js/setting-a-custom-build-directory.md) is configured, the standalone build can be found at `<distDir>/standalone`. Additionally, static files should be copied to `standalone/<distDir>/static` if they should be served by the integrated server.
> **Note**: `next.config.js` is read during `next build` and serialized into the `server.js` output file. If the legacy [`serverRuntimeConfig` or `publicRuntimeConfig` options](/docs/api-reference/next.config.js/runtime-configuration.md) are being used, the values will be specific to values at build time.
> **Note**: If your project uses [Image Optimization](/docs/basic-features/image-optimization.md) with the default `loader`, you must install `sharp` as a dependency:
Expand Down
4 changes: 4 additions & 0 deletions docs/api-reference/create-next-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ Options:

Explicitly tell the CLI to bootstrap the app using pnpm

--use-yarn

Explicitly tell the CLI to bootstrap the app using Yarn

-e, --example [name]|[github-url]

An example to bootstrap the app with. You can use an example name
Expand Down
4 changes: 4 additions & 0 deletions packages/create-next-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ Options:

Explicitly tell the CLI to bootstrap the app using pnpm

--use-yarn

Explicitly tell the CLI to bootstrap the app using Yarn

-e, --example [name]|[github-url]

An example to bootstrap the app with. You can use an example name
Expand Down
9 changes: 9 additions & 0 deletions packages/create-next-app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ const program = new Commander.Command(packageJson.name)
`
Explicitly tell the CLI to bootstrap the application using pnpm
`
)
.option(
'--use-yarn',
`
Explicitly tell the CLI to bootstrap the application using Yarn
`
)
.option(
Expand Down Expand Up @@ -134,6 +141,8 @@ const packageManager = !!program.useNpm
? 'npm'
: !!program.usePnpm
? 'pnpm'
: !!program.useYarn
? 'yarn'
: getPkgManager()

async function run(): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-swc/crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ regex = "1.5"
serde = "1"
serde_json = "1"
sha1 = "0.10.1"
tracing = { version = "0.1.37", features = ["release_max_level_info"] }
tracing = { version = "0.1.37" }

turbo-binding = { workspace = true, features = [
"__swc_core",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-swc/crates/napi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ turbo-tasks = { workspace = true }
once_cell = { workspace = true }
serde = "1"
serde_json = "1"
tracing = { version = "0.1.37", features = ["release_max_level_info"] }
tracing = { version = "0.1.37" }
tracing-futures = "0.2.5"
tracing-subscriber = "0.3.9"
tracing-chrome = "0.5.0"
Expand Down
1 change: 1 addition & 0 deletions packages/next-swc/crates/next-dev-tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tests/temp
62 changes: 57 additions & 5 deletions packages/next-swc/crates/next-dev-tests/test-harness/harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ declare global {
// We need to extract only the call signature as `autoReady(jest.describe)` drops all the other properties
var describe: AutoReady<typeof jest.describe>
var it: AutoReady<typeof jest.it>
var READY: (arg: string) => void
var TURBOPACK_READY: (arg: string) => void
var TURBOPACK_CHANGE_FILE: (arg: string) => void
var nsObj: (obj: any) => any
var __turbopackFileChanged: (id: string, error: Error) => void

interface Window {
NEXT_HYDRATED?: boolean
Expand Down Expand Up @@ -62,8 +64,8 @@ function markReady() {
isReady = true
requestIdleCallback(
() => {
if (typeof READY === 'function') {
READY('')
if (typeof TURBOPACK_READY === 'function') {
TURBOPACK_READY('')
} else {
console.info(
'%cTurbopack tests:',
Expand All @@ -83,16 +85,28 @@ export function wait(ms: number): Promise<void> {
})
}

async function waitForPath(contentWindow: Window, path: string): Promise<void> {
export async function waitForCondition(
predicate: () => boolean,
timeout: number | null = null
): Promise<void> {
const start = Date.now()
while (true) {
if (contentWindow.location.pathname === path) {
if (predicate()) {
break
}

await wait(1)

if (timeout != null && Date.now() - start > timeout) {
throw new Error('Timed out waiting for condition')
}
}
}

async function waitForPath(contentWindow: Window, path: string): Promise<void> {
return waitForCondition(() => contentWindow.location.pathname === path)
}

/**
* Loads a new page in an iframe and waits for it to load.
*/
Expand Down Expand Up @@ -210,3 +224,41 @@ export function markAsHydrated() {
window.onNextHydrated()
}
}

const fileChangedResolvers: Map<
string,
{ resolve: (value: unknown) => void; reject: (error: Error) => void }
> = new Map()

globalThis.__turbopackFileChanged = (id: string, error?: Error) => {
const resolver = fileChangedResolvers.get(id)
if (resolver == null) {
throw new Error(`No resolver found for id ${id}`)
} else if (error != null) {
resolver.reject(error)
} else {
resolver.resolve(null)
}
}

function unsafeUniqueId(): string {
const LENGTH = 10
const BASE = 16
return Math.floor(Math.random() * Math.pow(BASE, LENGTH))
.toString(BASE)
.slice(0, LENGTH)
}

export async function changeFile(
path: string,
find: string,
replaceWith: string
) {
return new Promise((resolve, reject) => {
const id = unsafeUniqueId()

fileChangedResolvers.set(id, { resolve, reject })

TURBOPACK_CHANGE_FILE(JSON.stringify({ path, id, find, replaceWith }))
})
}

0 comments on commit 7d15955

Please sign in to comment.