diff --git a/.github/.kodiak.toml b/.github/.kodiak.toml
index a90b3113f6533..ee535afe225c9 100644
--- a/.github/.kodiak.toml
+++ b/.github/.kodiak.toml
@@ -13,6 +13,7 @@ notify_on_conflict = false
[merge.message]
title = "pull_request_title"
body = "pull_request_body"
+include_coauthors= true
include_pr_number = true
body_type = "markdown"
strip_html_comments = true
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index c78fb679b6e7a..76e9888bb1b2c 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -1,6 +1,24 @@
# Learn how to add code owners here:
# https://help.github.com/en/articles/about-code-owners
-* @timneutkens @ijjk @shuding @styfle @huozhi @padmaia
+* @timneutkens @ijjk @shuding @huozhi
+/.github/ @timneutkens @ijjk @shuding @styfle @huozhi @padmaia
/docs/ @timneutkens @ijjk @shuding @styfle @huozhi @padmaia @leerob @lfades @molebox
/examples/ @timneutkens @ijjk @shuding @leerob @lfades
+
+# SWC Build (@padmaia)
+
+/packages/next/build/ @timneutkens @ijjk @shuding @padmaia @huozhi
+
+# Image Component (@styfle)
+
+/examples/image-component/ @timneutkens @ijjk @shuding @styfle
+/packages/next/build/webpack/loaders/next-image-loader.js @timneutkens @ijjk @shuding @styfle
+/packages/next/client/image.tsx @timneutkens @ijjk @shuding @styfle
+/packages/next/image-types/ @timneutkens @ijjk @shuding @styfle
+/packages/next/server/image-config.ts @timneutkens @ijjk @shuding @styfle
+/packages/next/server/image-optimizer.ts @timneutkens @ijjk @shuding @styfle
+/packages/next/server/serve-static.ts @timneutkens @ijjk @shuding @styfle
+/packages/next/server/config.ts @timneutkens @ijjk @shuding @styfle
+/test/integration/image-optimizer/ @timneutkens @ijjk @shuding @styfle
+/test/integration/image-component/ @timneutkens @ijjk @shuding @styfle
diff --git a/.github/actions/next-stats-action/src/index.js b/.github/actions/next-stats-action/src/index.js
index 8277155f0a29e..770cf6f5cb0cb 100644
--- a/.github/actions/next-stats-action/src/index.js
+++ b/.github/actions/next-stats-action/src/index.js
@@ -118,6 +118,10 @@ if (!allowedActions.has(actionInfo.actionName) && !actionInfo.isRelease) {
// in case of noisy environment slowing down initial repo build
await exec(buildCommand, false, { timeout: 5 * 60 * 1000 })
}
+ await fs.copy(
+ path.join(__dirname, '../native'),
+ path.join(dir, 'packages/next/native')
+ )
logger(`Linking packages in ${dir}`)
const pkgPaths = await linkPackages(dir)
diff --git a/.github/actions/next-stats-action/src/prepare/repo-setup.js b/.github/actions/next-stats-action/src/prepare/repo-setup.js
index c526e623f2bcd..aba3266fc7e5a 100644
--- a/.github/actions/next-stats-action/src/prepare/repo-setup.js
+++ b/.github/actions/next-stats-action/src/prepare/repo-setup.js
@@ -100,6 +100,10 @@ module.exports = (actionInfo) => {
// make sure native binaries are included in local linking
if (pkg === 'next') {
pkgData.files.push('native')
+ console.log(
+ 'using swc binaries: ',
+ await exec(`ls ${path.join(path.dirname(pkgDataPath), 'native')}`)
+ )
}
await fs.writeFile(
pkgDataPath,
diff --git a/.github/actions/next-stats-action/src/run/index.js b/.github/actions/next-stats-action/src/run/index.js
index e2159e9a89bf2..f0dc07bd87a03 100644
--- a/.github/actions/next-stats-action/src/run/index.js
+++ b/.github/actions/next-stats-action/src/run/index.js
@@ -67,7 +67,7 @@ async function runConfigs(
const results = await glob(rename.srcGlob, { cwd: statsAppDir })
for (const result of results) {
let dest = rename.removeHash
- ? result.replace(/(\.|-)[0-9a-f]{20}(\.|-)/g, '$1HASH$2')
+ ? result.replace(/(\.|-)[0-9a-f]{16}(\.|-)/g, '$1HASH$2')
: rename.dest
if (result === dest) continue
await fs.move(
diff --git a/.github/lock.yml b/.github/lock.yml
index a836a1e1e94aa..ae1e70313fe43 100644
--- a/.github/lock.yml
+++ b/.github/lock.yml
@@ -1,6 +1,6 @@
# Configuration for lock-threads - https://github.com/dessant/lock-threads
# Number of days of inactivity before a closed issue or pull request is locked
-daysUntilLock: 365
+daysUntilLock: 45
# Comment to post before locking. Set to `false` to disable
-lockComment: false
+lockComment: 'This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please open a new issue with a reproduction. Thank you.'
diff --git a/.github/workflows/build_native.yml b/.github/workflows/build_native.yml
deleted file mode 100644
index 9f22bedf98cea..0000000000000
--- a/.github/workflows/build_native.yml
+++ /dev/null
@@ -1,105 +0,0 @@
-on: workflow_dispatch
-
-name: Build next-swc native binaries
-
-jobs:
- build-native:
- strategy:
- matrix:
- os: [ubuntu-18.04, macos-latest, windows-latest]
- description: [default]
- include:
- - os: ubuntu-18.04
- target: x86_64-unknown-linux-gnu
- name: linux-x64-gnu
- - os: windows-latest
- target: x86_64-pc-windows-msvc
- name: win32-x64-msvc
- - os: macos-latest
- target: x86_64-apple-darwin
- name: darwin-x64
- - os: macos-latest
- target: aarch64-apple-darwin
- name: darwin-arm64
- description: m1
-
- name: next-swc - ${{ matrix.os }} - ${{ matrix.target }} - node@14
- runs-on: ${{ matrix.os }}
-
- steps:
- - uses: actions/checkout@v2
- - name: Setup node
- uses: actions/setup-node@v2
- with:
- node-version: 14
- check-latest: true
- - name: Install
- uses: actions-rs/toolchain@v1
- with:
- profile: minimal
- toolchain: nightly-2021-08-12
- target: ${{ matrix.target }}
- - name: Cache cargo registry
- uses: actions/cache@v1
- with:
- path: ~/.cargo/registry
- key: stable-${{ matrix.os }}-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
- - name: Cache cargo index
- uses: actions/cache@v1
- with:
- path: ~/.cargo/git
- key: stable-${{ matrix.os }}-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
- - name: Cache native binary
- id: binary-cache
- uses: actions/cache@v2
- with:
- path: packages/next/native/**
- key: next-swc-nightly-2021-08-12-${{ matrix.target }}-${{ hashFiles('.github/workflows/build_native.yml', 'packages/next/build/swc/**') }}
- - name: Cross build aarch64 setup
- if: ${{ matrix.target == 'aarch64-apple-darwin' && steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
- run: |
- sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/*;
- export CC=$(xcrun -f clang);
- export CXX=$(xcrun -f clang++);
- SYSROOT=$(xcrun --sdk macosx --show-sdk-path);
- export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT";
- # We use restore-key to pick latest cache.
- # We will not get exact match, but doc says
- # "If there are multiple partial matches for a restore key, the action returns the most recently created cache."
- # So we get latest cache
- - name: Cache built files
- uses: actions/cache@v2
- with:
- path: ./packages/next/build/swc/target
- key: next-swc-cargo-cache-${{ matrix.os }}--${{ hashFiles('**/Cargo.lock') }}
- restore-keys: |
- next-swc-cargo-cache-${{ matrix.os }}
- - name: 'Build'
- if: steps.binary-cache.outputs.cache-hit != true
- run: yarn build-native --target ${{ matrix.target }}
- env:
- MACOSX_DEPLOYMENT_TARGET: '10.13'
- working-directory: packages/next
- - name: Upload artifact
- uses: actions/upload-artifact@v2.2.4
- with:
- name: next-swc-binaries
- path: packages/next/native/next-swc.${{ matrix.name }}.node
- - name: Clear the cargo caches
- run: |
- cargo install cargo-cache --no-default-features --features ci-autoclean
- cargo-cache
- commit:
- needs: build-native
- runs-on: ubuntu-18.04
-
- steps:
- - uses: actions/checkout@v2
- - uses: actions/download-artifact@v2.0.10
- with:
- name: next-swc-binaries
- path: packages/next/native
- - uses: EndBug/add-and-commit@v7
- with:
- add: 'packages/next/native --force'
- message: 'Build next-swc binaries'
diff --git a/.github/workflows/build_test_deploy.yml b/.github/workflows/build_test_deploy.yml
index 4c6fef83ae388..0a3d7b02dc1fc 100644
--- a/.github/workflows/build_test_deploy.yml
+++ b/.github/workflows/build_test_deploy.yml
@@ -21,6 +21,9 @@ jobs:
runs-on: ubuntu-latest
env:
NEXT_TELEMETRY_DISABLED: 1
+ # we build a dev binary for use in CI so skip downloading
+ # canary next-swc binaries in the monorepo
+ NEXT_SKIP_NATIVE_POSTINSTALL: 1
outputs:
docsChange: ${{ steps.docs-change.outputs.DOCS_CHANGE }}
isRelease: ${{ steps.check-release.outputs.IS_RELEASE }}
@@ -71,7 +74,7 @@ jobs:
checkPrecompiled:
name: Check Pre-compiled
runs-on: ubuntu-latest
- needs: [build, build-native]
+ needs: build
env:
NEXT_TELEMETRY_DISABLED: 1
steps:
@@ -96,18 +99,6 @@ jobs:
- run: rm -rf .git && mv .git-bak .git
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
- - uses: actions/download-artifact@v2
- if: ${{needs.build.outputs.docsChange != 'docs only change'}}
- with:
- name: next-swc-binaries
- path: packages/next/build/swc/dist
-
- # Only check linux build for now, mac builds can sometimes be different even with the same code
- - run: |
- mv ./packages/next/build/swc/dist/next-swc.linux-x64-gnu.node \
- ./packages/next/native/next-swc.linux-x64-gnu.node
- if: ${{needs.build.outputs.docsChange != 'docs only change'}}
-
- run: ./scripts/check-pre-compiled.sh
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
@@ -120,7 +111,7 @@ jobs:
testUnit:
name: Test Unit
runs-on: ubuntu-latest
- needs: build
+ needs: [build, build-native-dev]
env:
NEXT_TELEMETRY_DISABLED: 1
NEXT_TEST_JOB: 1
@@ -132,13 +123,19 @@ jobs:
path: ./*
key: ${{ github.sha }}
+ - uses: actions/download-artifact@v2
+ if: ${{needs.build.outputs.docsChange != 'docs only change'}}
+ with:
+ name: next-swc-dev-binary
+ path: packages/next/native
+
- run: node run-tests.js --type unit
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
testDev:
name: Test Development
runs-on: ubuntu-latest
- needs: build
+ needs: [build, build-native-dev]
env:
NEXT_TELEMETRY_DISABLED: 1
NEXT_TEST_JOB: 1
@@ -156,6 +153,12 @@ jobs:
path: ./*
key: ${{ github.sha }}
+ - uses: actions/download-artifact@v2
+ if: ${{needs.build.outputs.docsChange != 'docs only change'}}
+ with:
+ name: next-swc-dev-binary
+ path: packages/next/native
+
- run: npm i -g playwright-chromium@1.14.1 && npx playwright install-deps
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
@@ -171,10 +174,20 @@ jobs:
name: Run test/e2e (dev)
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
+ - name: Upload test trace
+ if: always()
+ uses: actions/upload-artifact@v2
+ with:
+ name: test-trace
+ if-no-files-found: ignore
+ retention-days: 2
+ path: |
+ test/traces
+
testProd:
name: Test Production
runs-on: ubuntu-latest
- needs: build
+ needs: [build, build-native-dev]
env:
NEXT_TELEMETRY_DISABLED: 1
NEXT_TEST_JOB: 1
@@ -192,6 +205,12 @@ jobs:
path: ./*
key: ${{ github.sha }}
+ - uses: actions/download-artifact@v2
+ if: ${{needs.build.outputs.docsChange != 'docs only change'}}
+ with:
+ name: next-swc-dev-binary
+ path: packages/next/native
+
- run: npm i -g playwright-chromium@1.14.1 && npx playwright install-deps
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
@@ -210,7 +229,7 @@ jobs:
testIntegration:
name: Test Integration
runs-on: ubuntu-latest
- needs: build
+ needs: [build, build-native-dev]
env:
NEXT_TELEMETRY_DISABLED: 1
NEXT_TEST_JOB: 1
@@ -233,6 +252,12 @@ jobs:
path: ./*
key: ${{ github.sha }}
+ - uses: actions/download-artifact@v2
+ if: ${{needs.build.outputs.docsChange != 'docs only change'}}
+ with:
+ name: next-swc-dev-binary
+ path: packages/next/native
+
- run: npm i -g playwright-chromium@1.14.1 && npx playwright install-deps
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
@@ -243,10 +268,20 @@ jobs:
- run: xvfb-run node run-tests.js --timings -g ${{ matrix.group }}/6
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
+ - name: Upload test trace
+ if: always()
+ uses: actions/upload-artifact@v2
+ with:
+ name: test-trace
+ if-no-files-found: ignore
+ retention-days: 2
+ path: |
+ test/traces
+
testElectron:
name: Test Electron
runs-on: ubuntu-latest
- needs: build
+ needs: [build, build-native-dev]
env:
NEXT_TELEMETRY_DISABLED: 1
NEXT_TEST_JOB: 1
@@ -259,6 +294,12 @@ jobs:
path: ./*
key: ${{ github.sha }}
+ - uses: actions/download-artifact@v2
+ if: ${{needs.build.outputs.docsChange != 'docs only change'}}
+ with:
+ name: next-swc-dev-binary
+ path: packages/next/native
+
# TODO: remove after we fix watchpack watching too much
- run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
@@ -271,7 +312,7 @@ jobs:
testYarnPnP:
runs-on: ubuntu-latest
- needs: build
+ needs: [build, build-native-dev]
env:
NODE_OPTIONS: '--unhandled-rejections=strict'
YARN_COMPRESSION_LEVEL: '0'
@@ -283,6 +324,12 @@ jobs:
path: ./*
key: ${{ github.sha }}
+ - uses: actions/download-artifact@v2
+ if: ${{needs.build.outputs.docsChange != 'docs only change'}}
+ with:
+ name: next-swc-dev-binary
+ path: packages/next/native
+
- run: bash ./scripts/test-pnp.sh
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
@@ -307,7 +354,7 @@ jobs:
testFirefox:
name: Test Firefox (production)
runs-on: ubuntu-latest
- needs: build
+ needs: [build, build-native-dev]
env:
BROWSER_NAME: 'firefox'
NEXT_TELEMETRY_DISABLED: 1
@@ -318,6 +365,11 @@ jobs:
with:
path: ./*
key: ${{ github.sha }}
+ - uses: actions/download-artifact@v2
+ if: ${{needs.build.outputs.docsChange != 'docs only change'}}
+ with:
+ name: next-swc-dev-binary
+ path: packages/next/native
- run: npx playwright install-deps && npx playwright install firefox
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
- run: node run-tests.js test/integration/production/test/index.test.js
@@ -326,7 +378,7 @@ jobs:
testSafari:
name: Test Safari (production)
runs-on: ubuntu-latest
- needs: build
+ needs: [build, build-native-dev]
env:
BROWSERSTACK: true
BROWSER_NAME: 'safari'
@@ -346,6 +398,12 @@ jobs:
path: ./*
key: ${{ github.sha }}
+ - uses: actions/download-artifact@v2
+ if: ${{needs.build.outputs.docsChange != 'docs only change'}}
+ with:
+ name: next-swc-dev-binary
+ path: packages/next/native
+
# TODO: use macos runner so that we can use playwright to test against
# PRs instead of only running on canary?
- run: '[[ -z "$BROWSERSTACK_ACCESS_KEY" ]] && echo "Skipping for PR" || npm i -g browserstack-local@1.4.0'
@@ -357,7 +415,7 @@ jobs:
testSafariOld:
name: Test Safari 10.1 (nav)
runs-on: ubuntu-latest
- needs: [build, testSafari]
+ needs: [build, testSafari, build-native-dev]
env:
BROWSERSTACK: true
LEGACY_SAFARI: true
@@ -378,17 +436,62 @@ jobs:
path: ./*
key: ${{ github.sha }}
+ - uses: actions/download-artifact@v2
+ if: ${{needs.build.outputs.docsChange != 'docs only change'}}
+ with:
+ name: next-swc-dev-binary
+ path: packages/next/native
+
- run: '[[ -z "$BROWSERSTACK_ACCESS_KEY" ]] && echo "Skipping for PR" || npm i -g browserstack-local@1.4.0'
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
- run: '[[ -z "$BROWSERSTACK_ACCESS_KEY" ]] && echo "Skipping for PR" || node run-tests.js test/integration/production-nav/test/index.test.js'
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
+ testFirefoxNode17:
+ name: Test Firefox Node.js 17
+ runs-on: ubuntu-latest
+ needs: [build, testFirefox, build-native-dev]
+ env:
+ BROWSER_NAME: 'firefox'
+ NEXT_TELEMETRY_DISABLED: 1
+ steps:
+ - name: Setup node
+ uses: actions/setup-node@v2
+ if: ${{ steps.docs-change.outputs.docsChange != 'docs only change' }}
+ with:
+ node-version: 17
+ check-latest: true
+ - uses: actions/cache@v2
+ if: ${{needs.build.outputs.docsChange != 'docs only change'}}
+ id: restore-build
+ with:
+ path: ./*
+ key: ${{ github.sha }}
+ - uses: actions/download-artifact@v2
+ if: ${{needs.build.outputs.docsChange != 'docs only change'}}
+ with:
+ name: next-swc-dev-binary
+ path: packages/next/native
+ - run: npx playwright install-deps && npx playwright install firefox
+ if: ${{needs.build.outputs.docsChange != 'docs only change'}}
+ - run: node run-tests.js test/integration/production/test/index.test.js
+ if: ${{needs.build.outputs.docsChange != 'docs only change'}}
+
publishRelease:
if: ${{ needs.build.outputs.isRelease == 'true' }}
name: Potentially publish release
runs-on: ubuntu-latest
- needs: [build, build-native]
+ needs:
+ - build
+ - build-native
+ - build-windows-i686
+ - build-windows-aarch64
+ - build-linux-musl
+ - build-linux-arm7
+ - build-linux-aarch64
+ - build-android-aarch64
+ - build-linux-aarch64-musl
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN_ELEVATED }}
steps:
@@ -412,19 +515,135 @@ jobs:
releaseStats:
name: Release Stats
runs-on: ubuntu-latest
- needs: [publishRelease]
+ needs: [publishRelease, build-native-dev]
steps:
- uses: actions/cache@v2
id: restore-build
with:
path: ./*
key: ${{ github.sha }}
+
+ - uses: actions/download-artifact@v2
+ with:
+ name: next-swc-dev-binary
+ path: packages/next/native
+
+ - run: cp -r packages/next/native .github/actions/next-stats-action/native
+
- run: ./scripts/release-stats.sh
- uses: ./.github/actions/next-stats-action
env:
PR_STATS_COMMENT_TOKEN: ${{ secrets.PR_STATS_COMMENT_TOKEN }}
+ build-native-dev:
+ name: Build dev binary for tests
+ runs-on: ubuntu-18.04
+ steps:
+ # https://github.com/actions/virtual-environments/issues/1187
+ - name: tune linux network
+ run: sudo ethtool -K eth0 tx off rx off
+
+ - uses: actions/checkout@v2
+ with:
+ fetch-depth: 25
+
+ - run: echo ::set-output name=DOCS_CHANGE::$(node skip-docs-change.js echo 'not-docs-only-change')
+ id: docs-change
+
+ - name: Setup node
+ uses: actions/setup-node@v2
+ if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
+ with:
+ node-version: 14
+ check-latest: true
+
+ - name: Install
+ uses: actions-rs/toolchain@v1
+ if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
+ with:
+ profile: minimal
+ toolchain: nightly-2021-08-12
+
+ - name: Cache cargo registry
+ uses: actions/cache@v1
+ if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
+ with:
+ path: ~/.cargo/registry
+ key: stable-ubuntu-18.04-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
+
+ - name: Cache cargo index
+ uses: actions/cache@v1
+ if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
+ with:
+ path: ~/.cargo/git
+ key: stable-ubuntu-18.04-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
+
+ - name: Cache native binary
+ id: binary-cache
+ uses: actions/cache@v2
+ if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
+ with:
+ path: packages/next/native/next-swc.linux-x64-gnu.node
+ key: dev-next-swc-nightly-2021-08-12-linux-x64-gnu-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next/build/swc/**') }}
+
+ # We use restore-key to pick latest cache.
+ # We will not get exact match, but doc says
+ # "If there are multiple partial matches for a restore key, the action returns the most recently created cache."
+ # So we get latest cache
+ - name: Cache built files
+ uses: actions/cache@v2
+ with:
+ path: ./packages/next/build/swc/target
+ key: next-swc-cargo-cache-ubuntu-18.04--${{ hashFiles('**/Cargo.lock') }}
+ restore-keys: |
+ next-swc-cargo-cache-ubuntu-18.04
+
+ # since the repo's dependencies aren't installed we need
+ # to install napi globally
+ - run: npm i -g @napi-rs/cli@1.2.1
+
+ - name: Build
+ if: ${{ steps.binary-cache.outputs.cache-hit != 'true' && steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
+ run: yarn build-native
+ env:
+ MACOSX_DEPLOYMENT_TARGET: '10.13'
+ working-directory: packages/next
+
+ - name: Upload artifact
+ uses: actions/upload-artifact@v2.2.4
+ with:
+ name: next-swc-dev-binary
+ path: packages/next/native/next-swc.linux-x64-gnu.node
+
+ - name: Clear the cargo caches
+ if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
+ run: |
+ cargo install cargo-cache --no-default-features --features ci-autoclean
+ cargo-cache
+
+ test-native:
+ name: Unit Test Native Code
+ runs-on: ubuntu-18.04
+
+ steps:
+ - uses: actions/checkout@v2
+ with:
+ fetch-depth: 25
+ - run: echo ::set-output name=DOCS_CHANGE::$(node skip-docs-change.js echo 'not-docs-only-change')
+ id: docs-change
+ - name: Install
+ if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
+ uses: actions-rs/toolchain@v1
+ with:
+ toolchain: nightly-2021-08-12
+ profile: minimal
+ - run: cd packages/next/build/swc && cargo test
+ if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
+
+ # Build binaries for publishing
build-native:
+ needs: build
+ if: ${{ needs.build.outputs.isRelease == 'true' }}
strategy:
matrix:
os: [ubuntu-18.04, macos-latest, windows-latest]
@@ -459,45 +678,48 @@ jobs:
run: sudo sysctl -w net.link.generic.system.hwcksum_tx=0 && sudo sysctl -w net.link.generic.system.hwcksum_rx=0
if: ${{ matrix.os == 'macos-latest' }}
- - uses: actions/checkout@v2
- with:
- fetch-depth: 25
- - run: echo ::set-output name=DOCS_CHANGE::$(node skip-docs-change.js echo 'not-docs-only-change')
- id: docs-change
- name: Setup node
uses: actions/setup-node@v2
- if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
with:
node-version: 14
check-latest: true
+
+ # we use checkout here instead of the build cache since
+ # it can fail to restore in different OS'
+ - uses: actions/checkout@v2
+
+ # since the repo's dependencies aren't installed we need
+ # to install napi globally
+ - run: npm i -g @napi-rs/cli@1.2.1
+
- name: Install
uses: actions-rs/toolchain@v1
- if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
with:
profile: minimal
toolchain: nightly-2021-08-12
target: ${{ matrix.target }}
+
- name: Cache cargo registry
uses: actions/cache@v1
- if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
with:
path: ~/.cargo/registry
key: stable-${{ matrix.os }}-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
+
- name: Cache cargo index
uses: actions/cache@v1
- if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
with:
path: ~/.cargo/git
key: stable-${{ matrix.os }}-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
+
- name: Cache native binary
id: binary-cache
uses: actions/cache@v2
- if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
with:
- path: packages/next/native/next-swc.*.node
+ path: packages/next/native/next-swc.${{ matrix.name }}.node
key: next-swc-nightly-2021-08-12-${{ matrix.target }}-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next/build/swc/**') }}
+
- name: Cross build aarch64 setup
- if: ${{ matrix.target == 'aarch64-apple-darwin' && steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
+ if: ${{ matrix.target == 'aarch64-apple-darwin' }}
run: |
sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/*;
export CC=$(xcrun -f clang);
@@ -515,38 +737,395 @@ jobs:
key: next-swc-cargo-cache-${{ matrix.os }}--${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
next-swc-cargo-cache-${{ matrix.os }}
+
- name: 'Build'
- if: ${{ steps.binary-cache.outputs.cache-hit != 'true' && steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
- run: yarn build-native --target ${{ matrix.target }}
+ if: ${{ steps.binary-cache.outputs.cache-hit != 'true' }}
+ run: yarn build-native --release --target ${{ matrix.target }}
env:
MACOSX_DEPLOYMENT_TARGET: '10.13'
working-directory: packages/next
+
- name: Upload artifact
uses: actions/upload-artifact@v2.2.4
with:
name: next-swc-binaries
path: packages/next/native/next-swc.${{ matrix.name }}.node
+
- name: Clear the cargo caches
- if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
run: |
cargo install cargo-cache --no-default-features --features ci-autoclean
cargo-cache
- test-native:
- name: Unit Test Native Code
+ build-windows-i686:
+ needs: build
+ if: ${{ needs.build.outputs.isRelease == 'true' }}
+ name: next-swc - windows-i686 - node@14
+ runs-on: windows-latest
+ env:
+ CARGO_PROFILE_RELEASE_CODEGEN_UNITS: 32
+ CARGO_PROFILE_RELEASE_LTO: 'false'
+ steps:
+ - name: Install node x86
+ run: |
+ choco install nodejs-lts --x86 -y --force
+ refreshenv
+
+ - name: Set 32bit Node.js path
+ run: |
+ echo "C:\\Program Files (x86)\\nodejs" >> $GITHUB_PATH
+ shell: bash
+
+ - name: Node.js arch
+ run: node -e "console.log(process.arch)"
+
+ # we use checkout here instead of the build cache since
+ # it can fail to restore in different OS'
+ - uses: actions/checkout@v2
+
+ # since the repo's dependencies aren't installed we need
+ # to install napi globally
+ - run: npm i -g @napi-rs/cli@1.2.1
+
+ - name: Install Rust
+ uses: actions-rs/toolchain@v1
+ with:
+ profile: minimal
+ toolchain: nightly-2021-08-12
+ override: true
+ target: i686-pc-windows-msvc
+
+ - name: Cache native binary
+ id: binary-cache
+ uses: actions/cache@v2
+ with:
+ path: packages/next/native/next-swc.win32-ia32-msvc.node
+ key: next-swc-nightly-2021-08-12-win32-ia32-msvc-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next/build/swc/**') }}
+
+ - name: Build
+ if: ${{ steps.binary-cache.outputs.cache-hit != 'true' }}
+ shell: bash
+ run: yarn build-native --release --target i686-pc-windows-msvc
+ working-directory: packages/next
+
+ - name: Upload artifact
+ uses: actions/upload-artifact@v2
+ with:
+ name: next-swc-binaries
+ path: packages/next/native/next-swc.win32-ia32-msvc.node
+
+ build-windows-aarch64:
+ needs: build
+ if: ${{ needs.build.outputs.isRelease == 'true' }}
+ name: next-swc - windows-aarch64 - node@14
+ runs-on: windows-latest
+ steps:
+ - name: Setup node
+ uses: actions/setup-node@v2
+ with:
+ node-version: 14
+
+ # we use checkout here instead of the build cache since
+ # it can fail to restore in different OS'
+ - uses: actions/checkout@v2
+
+ # since the repo's dependencies aren't installed we need
+ # to install napi globally
+ - run: npm i -g @napi-rs/cli@1.2.1
+
+ - name: Install Rust
+ uses: actions-rs/toolchain@v1
+ with:
+ profile: minimal
+ toolchain: nightly-2021-08-12
+ override: true
+ target: aarch64-pc-windows-msvc
+
+ - name: Cache native binary
+ id: binary-cache
+ uses: actions/cache@v2
+ with:
+ path: packages/next/native/next-swc.win32-arm64-msvc.node
+ key: next-swc-nightly-2021-08-12-win32-arm64-msvc-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next/build/swc/**') }}
+
+ - name: Build
+ if: ${{ steps.binary-cache.outputs.cache-hit != 'true' }}
+ shell: bash
+ run: yarn build-native --release --target aarch64-pc-windows-msvc
+ working-directory: packages/next
+
+ - name: Upload artifact
+ uses: actions/upload-artifact@v2
+ with:
+ name: next-swc-binaries
+ path: packages/next/native/next-swc.win32-arm64-msvc.node
+
+ build-linux-musl:
+ needs: build
+ if: ${{ needs.build.outputs.isRelease == 'true' }}
+ name: next-swc - linux-musl - node@lts
+ runs-on: ubuntu-latest
+ steps:
+ # we use checkout here instead of the build cache since
+ # it can fail to restore in different OS'
+ - uses: actions/checkout@v2
+
+ - name: Login to registry
+ run: |
+ docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD $DOCKER_REGISTRY_URL
+ env:
+ DOCKER_REGISTRY_URL: ghcr.io
+ DOCKER_USERNAME: ${{ github.actor }}
+ DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Cache
+ uses: actions/cache@v2
+ with:
+ path: |
+ target/
+ key: linux-musl-publish-integration
+
+ - name: Pull docker image
+ run: |
+ docker pull ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
+ docker tag ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine builder
+
+ - name: Cache native binary
+ id: binary-cache
+ uses: actions/cache@v2
+ with:
+ path: packages/next/native/next-swc.linux-x64-musl.node
+ key: next-swc-nightly-2021-08-12-linux-x64-musl-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next/build/swc/**') }}
+
+ - name: 'Build'
+ if: ${{ steps.binary-cache.outputs.cache-hit != 'true' }}
+ run: |
+ docker run --rm -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v $(pwd)/packages/next:/build -w /build builder sh -c "npm i -g @napi-rs/cli@1.2.1 && yarn build-native --release --target x86_64-unknown-linux-musl"
+
+ - name: Upload artifact
+ uses: actions/upload-artifact@v2
+ with:
+ name: next-swc-binaries
+ path: packages/next/native/next-swc.linux-x64-musl.node
+
+ build-linux-aarch64:
+ needs: build
+ if: ${{ needs.build.outputs.isRelease == 'true' }}
+ name: next-swc - aarch64-unknown-linux-gnu - node@14
runs-on: ubuntu-18.04
+ steps:
+ - run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
+ - name: Setup node
+ uses: actions/setup-node@v2
+ with:
+ node-version: 14
+
+ # we use checkout here instead of the build cache since
+ # it can fail to restore in different OS'
+ - uses: actions/checkout@v2
+
+ # since the repo's dependencies aren't installed we need
+ # to install napi globally
+ - run: npm i -g @napi-rs/cli@1.2.1
+
+ - name: Install Rust
+ uses: actions-rs/toolchain@v1
+ with:
+ profile: minimal
+ toolchain: nightly-2021-08-12
+ override: true
+ target: aarch64-unknown-linux-gnu
+
+ - name: Cache
+ uses: actions/cache@v2
+ with:
+ path: |
+ target/
+ key: aarch64-linux-gnu-publish-integration
+
+ - name: Install cross compile toolchain
+ run: |
+ sudo apt-get update
+ sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu -y
+
+ - name: Cache native binary
+ id: binary-cache
+ uses: actions/cache@v2
+ with:
+ path: packages/next/native/next-swc.linux-arm64-gnu.node
+ key: next-swc-nightly-2021-08-12-linux-arm64-gnu-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next/build/swc/**') }}
+
+ - name: Cross build aarch64
+ if: ${{ steps.binary-cache.outputs.cache-hit != 'true' }}
+ run: yarn build-native --release --target aarch64-unknown-linux-gnu
+ working-directory: packages/next
+
+ - name: Upload artifact
+ uses: actions/upload-artifact@v2
+ with:
+ name: next-swc-binaries
+ path: packages/next/native/next-swc.linux-arm64-gnu.node
+
+ build-linux-aarch64-musl:
+ needs: build
+ if: ${{ needs.build.outputs.isRelease == 'true' }}
+ name: next-swc - aarch64-unknown-linux-musl - node@14
+ runs-on: ubuntu-18.04
steps:
+ - name: Setup node
+ uses: actions/setup-node@v2
+ with:
+ node-version: 14
+
+ # we use checkout here instead of the build cache since
+ # it can fail to restore in different OS'
- uses: actions/checkout@v2
+
+ # since the repo's dependencies aren't installed we need
+ # to install napi globally
+ - run: npm i -g @napi-rs/cli@1.2.1
+
+ - name: Install Rust
+ uses: actions-rs/toolchain@v1
with:
- fetch-depth: 25
- - run: echo ::set-output name=DOCS_CHANGE::$(node skip-docs-change.js echo 'not-docs-only-change')
- id: docs-change
- - name: Install
- if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
+ profile: minimal
+ toolchain: nightly-2021-08-12
+ override: true
+ target: aarch64-unknown-linux-musl
+
+ - name: Cache
+ uses: actions/cache@v2
+ with:
+ path: |
+ target/
+ key: aarch64-linux-musl-publish-integration
+
+ - name: Install cross compile toolchain
+ run: |
+ sudo apt-get update
+ sudo apt-get install gcc-aarch64-linux-gnu -y
+
+ - name: Cache native binary
+ id: binary-cache
+ uses: actions/cache@v2
+ with:
+ path: packages/next/native/next-swc.linux-arm64-musl.node
+ key: next-swc-nightly-2021-08-12-linux-arm64-musl-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next/build/swc/**') }}
+
+ - name: Cross build aarch64
+ if: ${{ steps.binary-cache.outputs.cache-hit != 'true' }}
+ run: yarn build-native --release --target aarch64-unknown-linux-musl
+ working-directory: packages/next
+
+ - name: Upload artifact
+ uses: actions/upload-artifact@v2
+ with:
+ name: next-swc-binaries
+ path: packages/next/native/next-swc.linux-arm64-musl.node
+
+ build-linux-arm7:
+ needs: build
+ if: ${{ needs.build.outputs.isRelease == 'true' }}
+ name: next-swc - arm7-unknown-linux-gnu - node@14
+ runs-on: ubuntu-18.04
+ steps:
+ - run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
+
+ - name: Setup node
+ uses: actions/setup-node@v2
+ with:
+ node-version: 14
+
+ # we use checkout here instead of the build cache since
+ # it can fail to restore in different OS'
+ - uses: actions/checkout@v2
+
+ # since the repo's dependencies aren't installed we need
+ # to install napi globally
+ - run: npm i -g @napi-rs/cli@1.2.1
+
+ - name: Install Rust
uses: actions-rs/toolchain@v1
with:
+ profile: minimal
toolchain: nightly-2021-08-12
+ override: true
+ target: armv7-unknown-linux-gnueabihf
+
+ - name: Cache
+ uses: actions/cache@v2
+ with:
+ path: |
+ target/
+ key: arm7-linux-gnu-publish-integration
+
+ - name: Install cross compile toolchain
+ run: |
+ sudo apt-get update
+ sudo apt-get install gcc-arm-linux-gnueabihf -y
+
+ - name: Cache native binary
+ id: binary-cache
+ uses: actions/cache@v2
+ with:
+ path: packages/next/native/next-swc.linux-arm-gnueabihf.node
+ key: next-swc-nightly-2021-08-12-linux-arm-gnueabihf-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next/build/swc/**') }}
+
+ - name: Cross build aarch64
+ if: ${{ steps.binary-cache.outputs.cache-hit != 'true' }}
+ run: yarn build-native --release --target armv7-unknown-linux-gnueabihf
+ working-directory: packages/next
+
+ - name: Upload artifact
+ uses: actions/upload-artifact@v2
+ with:
+ name: next-swc-binaries
+ path: packages/next/native/next-swc.linux-arm-gnueabihf.node
+
+ build-android-aarch64:
+ needs: build
+ if: ${{ needs.build.outputs.isRelease == 'true' }}
+ name: next-swc - Android - aarch64
+ runs-on: macos-latest
+ steps:
+ - name: Setup node
+ uses: actions/setup-node@v2
+ with:
+ node-version: 14
+
+ # we use checkout here instead of the build cache since
+ # it can fail to restore in different OS'
+ - uses: actions/checkout@v2
+
+ # since the repo's dependencies aren't installed we need
+ # to install napi globally
+ - run: npm i -g @napi-rs/cli@1.2.1
+
+ - name: Install Rust
+ uses: actions-rs/toolchain@v1
+ with:
profile: minimal
- - run: cd packages/next/build/swc && cargo test
- if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
+ toolchain: nightly-2021-08-12
+ override: true
+ target: aarch64-linux-android
+
+ - name: Cache native binary
+ id: binary-cache
+ uses: actions/cache@v2
+ with:
+ path: packages/next/native/next-swc.android-arm64.node
+ key: next-swc-nightly-2021-08-12-android-arm64-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next/build/swc/**') }}
+
+ - name: Build
+ if: ${{ steps.binary-cache.outputs.cache-hit != 'true' }}
+ shell: bash
+ run: |
+ export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android24-clang"
+ yarn build-native --release --target aarch64-linux-android
+ working-directory: packages/next
+
+ - name: Upload artifact
+ uses: actions/upload-artifact@v2
+ with:
+ name: next-swc-binaries
+ path: packages/next/native/next-swc.android-arm64.node
diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml
index ce58d11cab7c9..093016a7beaf7 100644
--- a/.github/workflows/cancel.yml
+++ b/.github/workflows/cancel.yml
@@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- - uses: styfle/cancel-workflow-action@0.5.0
+ - uses: styfle/cancel-workflow-action@0.9.1
with:
workflow_id: 444921, 444987
access_token: ${{ github.token }}
diff --git a/.github/workflows/pull_request_stats.yml b/.github/workflows/pull_request_stats.yml
index 4c4874cdb9f48..11d63ac5e5f8a 100644
--- a/.github/workflows/pull_request_stats.yml
+++ b/.github/workflows/pull_request_stats.yml
@@ -5,8 +5,95 @@ on:
name: Generate Pull Request Stats
jobs:
+ build-native-dev:
+ name: Build dev binary for tests
+ runs-on: ubuntu-18.04
+ steps:
+ # https://github.com/actions/virtual-environments/issues/1187
+ - name: tune linux network
+ run: sudo ethtool -K eth0 tx off rx off
+
+ - uses: actions/checkout@v2
+ with:
+ fetch-depth: 25
+
+ - run: echo ::set-output name=DOCS_CHANGE::$(node skip-docs-change.js echo 'not-docs-only-change')
+ id: docs-change
+
+ - name: Setup node
+ uses: actions/setup-node@v2
+ if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
+ with:
+ node-version: 14
+ check-latest: true
+
+ - name: Install
+ uses: actions-rs/toolchain@v1
+ if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
+ with:
+ profile: minimal
+ toolchain: nightly-2021-08-12
+
+ - name: Cache cargo registry
+ uses: actions/cache@v1
+ if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
+ with:
+ path: ~/.cargo/registry
+ key: stable-ubuntu-18.04-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
+
+ - name: Cache cargo index
+ uses: actions/cache@v1
+ if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
+ with:
+ path: ~/.cargo/git
+ key: stable-ubuntu-18.04-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
+
+ - name: Cache native binary
+ id: binary-cache
+ uses: actions/cache@v2
+ if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
+ with:
+ path: packages/next/native/next-swc.linux-x64-gnu.node
+ key: dev-next-swc-nightly-2021-08-12-linux-x64-gnu-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next/build/swc/**') }}
+
+ # We use restore-key to pick latest cache.
+ # We will not get exact match, but doc says
+ # "If there are multiple partial matches for a restore key, the action returns the most recently created cache."
+ # So we get latest cache
+ - name: Cache built files
+ uses: actions/cache@v2
+ with:
+ path: ./packages/next/build/swc/target
+ key: next-swc-cargo-cache-ubuntu-18.04--${{ hashFiles('**/Cargo.lock') }}
+ restore-keys: |
+ next-swc-cargo-cache-ubuntu-18.04
+
+ # since the repo's dependencies aren't installed we need
+ # to install napi globally
+ - run: npm i -g @napi-rs/cli@1.2.1
+
+ - name: Build
+ if: ${{ steps.binary-cache.outputs.cache-hit != 'true' && steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
+ run: yarn build-native
+ env:
+ MACOSX_DEPLOYMENT_TARGET: '10.13'
+ working-directory: packages/next
+
+ - name: Upload artifact
+ uses: actions/upload-artifact@v2.2.4
+ with:
+ name: next-swc-dev-binary
+ path: packages/next/native/next-swc.linux-x64-gnu.node
+
+ - name: Clear the cargo caches
+ if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
+ run: |
+ cargo install cargo-cache --no-default-features --features ci-autoclean
+ cargo-cache
+
stats:
name: PR Stats
+ needs: build-native-dev
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
@@ -15,5 +102,15 @@ jobs:
- run: echo ::set-output name=DOCS_CHANGE::$(node skip-docs-change.js echo 'not-docs-only-change')
id: docs-change
+
+ - uses: actions/download-artifact@v2
+ if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
+ with:
+ name: next-swc-dev-binary
+ path: packages/next/native
+
+ - run: cp -r packages/next/native .github/actions/next-stats-action/native
+ if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
+
- uses: ./.github/actions/next-stats-action
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
diff --git a/.gitignore b/.gitignore
index e883995fb2dc7..a610b8f09ae7c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -39,3 +39,6 @@ test-timings.json
# Vercel
.vercel
.now
+
+# Cache
+*.tsbuildinfo
\ No newline at end of file
diff --git a/bench/nested-deps/next.config.js b/bench/nested-deps/next.config.js
index d06b18cf4e29c..004e6c18198b6 100644
--- a/bench/nested-deps/next.config.js
+++ b/bench/nested-deps/next.config.js
@@ -1,9 +1,9 @@
+const idx = process.execArgv.indexOf('--cpu-prof')
+if (idx >= 0) process.execArgv.splice(idx, 1)
+
module.exports = {
eslint: {
ignoreDuringBuilds: true,
},
- experimental: {
- swcLoader: true,
- swcMinify: true,
- },
+ swcMinify: true,
}
diff --git a/bench/nested-deps/package.json b/bench/nested-deps/package.json
index d025ab2b2ad3c..ad48206bed2d1 100644
--- a/bench/nested-deps/package.json
+++ b/bench/nested-deps/package.json
@@ -1,11 +1,11 @@
{
"scripts": {
- "prepare": "rm -rf components && mkdir components && node ./fuzzponent.js -d 2 -s 206 -o components",
- "dev": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK5=1 ../../node_modules/.bin/next dev",
- "build": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK5=1 ../../node_modules/.bin/next build",
- "start": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK5=1 ../../node_modules/.bin/next start",
- "dev-nocache": "rm -rf .next && yarn dev",
- "dev-cpuprofile-nocache": "rm -rf .next && cross-env NEXT_PRIVATE_LOCAL_WEBPACK5=1 node --cpu-prof ../../node_modules/.bin/next",
- "build-nocache": "rm -rf .next && yarn build"
+ "prepare": "rimraf components && mkdir components && node ./fuzzponent.js -d 2 -s 206 -o components",
+ "dev": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK5=1 node ../../node_modules/next/dist/bin/next dev",
+ "build": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK5=1 node ../../node_modules/next/dist/bin/next build",
+ "start": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK5=1 node ../../node_modules/next/dist/bin/next start",
+ "dev-nocache": "rimraf .next && yarn dev",
+ "dev-cpuprofile-nocache": "rimraf .next && cross-env NEXT_PRIVATE_LOCAL_WEBPACK5=1 node --cpu-prof ../../node_modules/next/dist/bin/next",
+ "build-nocache": "rimraf .next && yarn build"
}
}
diff --git a/contributing.md b/contributing.md
index 0028660ae5d32..1535ae5d4617a 100644
--- a/contributing.md
+++ b/contributing.md
@@ -15,8 +15,7 @@ To develop locally:
1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your
own GitHub account and then
- [clone](https://help.github.com/articles/cloning-a-repository/) it to your
- local device.
+ [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device.
2. Create a new branch:
```
git checkout -b MY_BRANCH_NAME
@@ -52,14 +51,14 @@ yarn build
yarn prepublish
```
+By default the latest canary of the next-swc binaries will be installed and used. If you are actively working on Rust code or you need to test out the most recent Rust code that hasn't been published as a canary yet you can [install Rust](https://www.rust-lang.org/tools/install) and run `yarn --cwd packages/next build-native`.
+
If you need to clean the project for any reason, use `yarn clean`.
## Testing
See the [testing readme](./test/readme.md) for information on writing tests.
-You may have to [install Rust](https://www.rust-lang.org/tools/install) and build our native packages to see all tests pass locally. We check in binaries for the most common targets and those required for CI so that most people don't have to, but if you do not see a binary for your target in `packages/next/native`, you can build it by running `yarn --cwd packages/next build-native`. If you are working on the Rust code and you need to build the binaries for ci, you can manually trigger [the workflow](https://github.com/vercel/next.js/actions/workflows/build_native.yml) to build and commit with the "Run workflow" button.
-
### Running tests
```sh
@@ -127,7 +126,7 @@ EXAMPLE=./test/integration/basic
There are two options to develop with your local version of the codebase:
-### Set as local dependency in package.json
+### Set as a local dependency in package.json
1. In your app's `package.json`, replace:
@@ -165,7 +164,24 @@ There are two options to develop with your local version of the codebase:
yarn install --force
```
-or
+#### Troubleshooting
+
+- If you see the below error while running `yarn dev` with next:
+
+```
+Failed to load SWC binary, see more info here: https://nextjs.org/docs/messages/failed-loading-swc
+```
+
+Try to add the below section to your `package.json`, then run again
+
+```json
+"optionalDependencies": {
+ "@next/swc-linux-x64-gnu": "canary",
+ "@next/swc-win32-x64-msvc": "canary",
+ "@next/swc-darwin-x64": "canary",
+ "@next/swc-darwin-arm64": "canary"
+},
+```
### Develop inside the monorepo
@@ -175,7 +191,7 @@ or
This will use the version of `next` built inside of the Next.js monorepo and the
main `yarn dev` monorepo command can be running to make changes to the local
-Next.js version at the same time (some changes might require re-running `yarn next-with-deps` to take affect).
+Next.js version at the same time (some changes might require re-running `yarn next-with-deps` to take effect).
## Adding warning/error descriptions
@@ -183,7 +199,7 @@ In Next.js we have a system to add helpful links to warnings and errors.
This allows for the logged message to be short while giving a broader description and instructions on how to solve the warning/error.
-In general all warnings and errors added should have these links attached.
+In general, all warnings and errors added should have these links attached.
Below are the steps to add a new link:
diff --git a/docs/advanced-features/debugging.md b/docs/advanced-features/debugging.md
index 407d0e98eb647..3c25d4a33fa6b 100644
--- a/docs/advanced-features/debugging.md
+++ b/docs/advanced-features/debugging.md
@@ -84,6 +84,16 @@ Once the server starts, open a new tab in Chrome and visit `chrome://inspect`, w
Debugging server-side code here works much like debugging client-side code with Chrome DevTools, except that when you search for files here with Ctrl+P or ⌘+P, your source files will have paths starting with `webpack://{application-name}/./` (where `{application-name}` will be replaced with the name of your application according to your `package.json` file).
+### Debugging on Windows
+
+Windows users may run into an issue when using `NODE_OPTIONS='--inspect'` as that syntax is not supported on Windows platforms. To get around this, install the [`cross-env`](https://www.npmjs.com/package/cross-env) package as a development dependency (`--dev` with Yarn or `-D` for NPM) and replace the `dev` script with the following.
+
+```json
+"dev": "cross-env NODE_OPTIONS='--inspect' next dev",
+```
+
+`cross-env` will set the `NODE_OPTIONS` environment variable regardless of which platform you are on (including Mac, Linux, and Windows) and allow you to debug consistently across devices and operating systems.
+
## More information
To learn more about how to use a JavaScript debugger, take a look at the following documentation:
diff --git a/docs/advanced-features/i18n-routing.md b/docs/advanced-features/i18n-routing.md
index 383fe72d3fbde..8272276b47418 100644
--- a/docs/advanced-features/i18n-routing.md
+++ b/docs/advanced-features/i18n-routing.md
@@ -100,6 +100,8 @@ module.exports = {
domains: [
{
+ // Note: subdomains must be included in the domain value to be matched
+ // e.g. www.example.com should be used if that is the expected hostname
domain: 'example.com',
defaultLocale: 'en-US',
},
@@ -122,6 +124,7 @@ module.exports = {
For example if you have `pages/blog.js` the following urls will be available:
- `example.com/blog`
+- `www.example.com/blog`
- `example.fr/blog`
- `example.nl/blog`
- `example.nl/nl-BE/blog`
@@ -139,6 +142,48 @@ When using Domain Routing, if a user with the `Accept-Language` header `fr;q=0.9
When using Sub-path Routing, the user would be redirected to `/fr`.
+### Prefixing the Default Locale
+
+With Next.js 12 and [Middleware](/docs/middleware.md), we can add a prefix to the default locale with a [workaround](https://github.com/vercel/next.js/discussions/18419).
+
+For example, here's a `next.config.js` file with support for a few languages. Note the `"default"` locale has been added intentionally.
+
+```js
+// next.config.js
+
+module.exports = {
+ i18n: {
+ locales: ['default', 'en', 'de', 'fr'],
+ defaultLocale: 'default',
+ localeDetection: false,
+ },
+ trailingSlash: true,
+}
+```
+
+Next, we can use [Middleware](/docs/middleware.md) to add custom routing rules:
+
+```js
+// pages/_middleware.ts
+
+import { NextRequest, NextResponse } from 'next/server'
+
+const PUBLIC_FILE = /\.(.*)$/
+
+export function middleware(request: NextRequest) {
+ const shouldHandleLocale =
+ !PUBLIC_FILE.test(request.nextUrl.pathname) &&
+ !request.nextUrl.pathname.includes('/api/') &&
+ request.nextUrl.locale === 'default'
+
+ return shouldHandleLocale
+ ? NextResponse.redirect(`/en${request.nextUrl.href}`)
+ : undefined
+}
+```
+
+This [Middleware](/docs/middleware.md) skips adding the default prefix to [API Routes](/docs/api-routes/introduction.md) and [public](/docs/basic-features/static-file-serving.md) files like fonts or images. If a request is made to the default locale, we redirect to our prefix `/en`.
+
### Disabling Automatic Locale Detection
The automatic locale detection can be disabled with:
@@ -306,4 +351,4 @@ export async function getStaticProps({ locale }) {
- `locales`: 100 total locales
- `domains`: 100 total locale domain items
-> **Note:** These limits have been added initially to prevent potential [performance issues at build time](#dynamic-routes-and-getStaticProps-pages). We are continuing to evaluate if these limits are sufficient.
+> **Note:** These limits have been added initially to prevent potential [performance issues at build time](#dynamic-routes-and-getStaticProps-pages). You can workaround these limits with custom routing using [Middleware](/docs/middleware.md) in Next.js 12.
diff --git a/docs/advanced-features/output-file-tracing.md b/docs/advanced-features/output-file-tracing.md
new file mode 100644
index 0000000000000..b5ba359591af6
--- /dev/null
+++ b/docs/advanced-features/output-file-tracing.md
@@ -0,0 +1,24 @@
+---
+description: Next.js automatically traces which files are needed by each page to allow for easy deployment of your application. Learn how it works here.
+---
+
+# Output File Tracing
+
+During a build, Next.js will automatically trace each page and its dependencies to determine all of the files that are needed for deploying a production version of your application.
+
+This feature helps reduce the size of deployments drastically. Previously, when deploying with Docker you would need to have all files from your package's `dependencies` installed to run `next start`. Starting with Next.js 12, you can leverage Output File Tracing in the `.next/` directory to only include the necessary files.
+
+Furthermore, this removes the need for the deprecated `serverless` target which can cause various issues and also creates unnecessary duplication.
+
+## How It Works
+
+During `next build`, Next.js will use [`@vercel/nft`](https://github.com/vercel/nft) to statically analyze `import`, `require`, and `fs` usage to determine all files that a page might load.
+
+Next.js' production server is also traced for its needed files and output at `.next/next-server.js.nft.json` which can be leveraged in production.
+
+To leverage the `.nft.json` files emitted to the `.next` output directory, you can read the list of files in each trace which are relative to the `.nft.json` file and then copy them to your deployment location.
+
+## Caveats
+
+- There are some cases that Next.js might fail to include required files, or might incorrectly include unused files. In those cases, you can export page configs props `unstable_includeFiles` and `unstable_excludeFiles` respectively. Each prop accepts an array of [globs](
Hello
+} +``` + +### Static Image Imports + +```js +import Image from 'next/image' +import logo from 'https://github.com/vercel/next.js/raw/canary/test/integration/production/public/vercel.png' + +export default () => ( +