diff --git a/.github/ISSUE_TEMPLATE/1.bug_report.yml b/.github/ISSUE_TEMPLATE/1.bug_report.yml index 440f9434bf332..d0aa0b7589ace 100644 --- a/.github/ISSUE_TEMPLATE/1.bug_report.yml +++ b/.github/ISSUE_TEMPLATE/1.bug_report.yml @@ -14,6 +14,12 @@ body: - type: markdown attributes: value: 'next@canary is the beta version of Next.js. It includes all features and fixes that are pending to land on the stable release line.' + - type: textarea + attributes: + label: Run `next info` (available from version 12.0.8 and up) + description: Please run `next info` in the root directory of your project and paste the results. You might need to use `npx --no-install next info` if next is not in the current PATH. + validations: + required: false - type: input attributes: label: What version of Next.js are you using? diff --git a/.github/workflows/build_test_deploy.yml b/.github/workflows/build_test_deploy.yml index 3e0072d48d0f5..d74d4da95102b 100644 --- a/.github/workflows/build_test_deploy.yml +++ b/.github/workflows/build_test_deploy.yml @@ -552,7 +552,7 @@ jobs: - build-windows-aarch64 - build-linux-musl - build-linux-arm7 - - build-linux-aarch64 + - build-linux-aarch64-gnu - build-android-aarch64 - build-linux-aarch64-musl env: @@ -664,16 +664,17 @@ jobs: - id: get-week run: echo ::set-output name=WEEK::$(date +%U) - # - name: Turbo Cache - # id: turbo-cache - # uses: actions/cache@v2 - # if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }} - # with: - # path: .turbo - # key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ steps.get-week.outputs.WEEK }}-${{ github.sha }} - # restore-keys: | - # turbo-${{ github.job }}-${{ github.ref_name }}-${{ steps.get-week.outputs.WEEK }}- - # turbo-${{ github.job }}-canary-${{ steps.get-week.outputs.WEEK }}- + - name: Turbo Cache + id: turbo-cache + uses: actions/cache@v2 + if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }} + with: + path: .turbo + key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ steps.get-week.outputs.WEEK }}-${{ github.sha }} + restore-keys: | + turbo-${{ github.job }}- + turbo-${{ github.job }}-${{ github.ref_name }}-${{ steps.get-week.outputs.WEEK }}- + turbo-${{ github.job }}-canary-${{ steps.get-week.outputs.WEEK }}- # We use restore-key to pick latest cache. # We will not get exact match, but doc says @@ -683,24 +684,20 @@ jobs: uses: actions/cache@v2 with: path: ./packages/next-swc/target - key: next-swc-cargo-cache-ubuntu-18.04--${{ hashFiles('**/Cargo.lock') }} + key: next-swc-cargo-cache-dev-ubuntu-18.04-${{ hashFiles('**/Cargo.lock') }} restore-keys: | - next-swc-cargo-cache-ubuntu-18.04 + next-swc-cargo-cache-dev-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 - - run: npm i -g turbo@1.0.14 + - run: npm i -g turbo@1.0.24 - name: Build if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }} - working-directory: packages/next-swc - run: yarn build-native + run: turbo run build-native --cache-dir=".turbo" env: MACOSX_DEPLOYMENT_TARGET: '10.13' - TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} - TURBO_TEAM: nextjs - TURBO_PROJECT: nextjs - name: Upload artifact uses: actions/upload-artifact@v2.2.4 @@ -829,6 +826,7 @@ jobs: # since the repo's dependencies aren't installed we need # to install napi globally - run: npm i -g @napi-rs/cli@1.2.1 + - run: npm i -g turbo@1.0.24 - name: Install uses: actions-rs/toolchain@v1 @@ -849,15 +847,16 @@ jobs: path: ~/.cargo/git key: stable-${{ matrix.os }}-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }} - # - name: Turbo cache - # id: turbo-cache - # uses: actions/cache@v2 - # with: - # path: .turbo - # key: turbo-${{ github.job }}-${{ matrix.name }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} - # restore-keys: | - # turbo-${{ github.job }}-${{ matrix.name }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- - # turbo-${{ github.job }}-${{ matrix.name }}-canary-${{ needs.build.outputs.weekNum }}- + - name: Turbo cache + id: turbo-cache + uses: actions/cache@v2 + with: + path: .turbo + key: turbo-${{ github.job }}-${{ matrix.name }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} + restore-keys: | + turbo-${{ github.job }}-${{ matrix.name }}- + turbo-${{ github.job }}-${{ matrix.name }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- + turbo-${{ github.job }}-${{ matrix.name }}-canary-${{ needs.build.outputs.weekNum }}- - name: Cross build aarch64 setup if: ${{ matrix.target == 'aarch64-apple-darwin' }} @@ -880,13 +879,10 @@ jobs: next-swc-cargo-cache-${{ matrix.os }} - name: 'Build' - working-directory: packages/next-swc - run: yarn build-native --release --target ${{ matrix.target }} + shell: bash + run: turbo run build-native --cache-dir=".turbo" -- --release --target ${{ matrix.target }} env: MACOSX_DEPLOYMENT_TARGET: '10.13' - TURBO_TOKEN: ${{secrets.TURBO_TOKEN}} - TURBO_TEAM: nextjs - TURBO_PROJECT: nextjs - name: Upload artifact uses: actions/upload-artifact@v2.2.4 @@ -928,7 +924,7 @@ jobs: # since the repo's dependencies aren't installed we need # to install napi globally - run: npm i -g @napi-rs/cli@1.2.1 - - run: npm i -g turbo@1.0.14 + - run: npm i -g turbo@1.0.24 - name: Install Rust uses: actions-rs/toolchain@v1 with: @@ -937,20 +933,20 @@ jobs: override: true target: i686-pc-windows-msvc - # - name: Turbo Cache - # id: turbo-cache - # uses: actions/cache@v2 - # with: - # path: .turbo - # key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} - # restore-keys: | - # turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- - # turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- + - name: Turbo Cache + id: turbo-cache + uses: actions/cache@v2 + with: + path: .turbo + key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} + restore-keys: | + turbo-${{ github.job }}- + turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- + turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- - name: Build shell: bash - working-directory: packages/next-swc - run: yarn build-native --release --target i686-pc-windows-msvc + run: turbo run build-native --cache-dir=".turbo" -- --release --target i686-pc-windows-msvc - name: Upload artifact uses: actions/upload-artifact@v2 @@ -976,7 +972,7 @@ jobs: # since the repo's dependencies aren't installed we need # to install napi globally - run: npm i -g @napi-rs/cli@1.2.1 - - run: npm i -g turbo@1.0.14 + - run: npm i -g turbo@1.0.24 - name: Install Rust uses: actions-rs/toolchain@v1 with: @@ -985,20 +981,20 @@ jobs: override: true target: aarch64-pc-windows-msvc - # - name: Turbo Cache - # id: turbo-cache - # uses: actions/cache@v2 - # with: - # path: .turbo - # key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} - # restore-keys: | - # turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- - # turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- + - name: Turbo Cache + id: turbo-cache + uses: actions/cache@v2 + with: + path: .turbo + key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} + restore-keys: | + turbo-${{ github.job }}- + turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- + turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- - name: Build shell: bash - working-directory: packages/next-swc - run: yarn build-native --release --target aarch64-pc-windows-msvc + run: turbo run build-native --cache-dir=".turbo" -- --release --target aarch64-pc-windows-msvc - name: Upload artifact uses: actions/upload-artifact@v2 @@ -1036,19 +1032,20 @@ jobs: 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: Turbo Cache - # id: turbo-cache - # uses: actions/cache@v2 - # with: - # path: .turbo - # key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} - # restore-keys: | - # turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- - # turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- + - name: Turbo Cache + id: turbo-cache + uses: actions/cache@v2 + with: + path: .turbo + key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} + restore-keys: | + turbo-${{ github.job }}- + turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- + turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- - name: 'Build' run: | - docker run --rm -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v $(pwd)/packages/next-swc:/build -w /build builder sh -c "npm i -g @napi-rs/cli@1.2.1 && npm i -g turbo@1.0.14 && yarn build-native --release --target x86_64-unknown-linux-musl" + docker run --rm -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v $(pwd):/build -w /build builder sh -c "npm i -g @napi-rs/cli@1.2.1 && npm i -g turbo@1.0.24 && turbo run build-native --cache-dir=".turbo" -- --release --target x86_64-unknown-linux-musl" - name: Upload artifact uses: actions/upload-artifact@v2 @@ -1056,7 +1053,7 @@ jobs: name: next-swc-binaries path: packages/next-swc/native/next-swc.linux-x64-musl.node - build-linux-aarch64: + build-linux-aarch64-gnu: needs: build if: ${{ needs.build.outputs.isRelease == 'true' }} name: next-swc - aarch64-unknown-linux-gnu - node@14 @@ -1076,7 +1073,7 @@ jobs: # since the repo's dependencies aren't installed we need # to install napi globally - run: npm i -g @napi-rs/cli@1.2.1 - - run: npm i -g turbo@1.0.14 + - run: npm i -g turbo@1.0.24 - name: Install Rust uses: actions-rs/toolchain@v1 @@ -1098,20 +1095,20 @@ jobs: sudo apt-get update sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu -y - # - name: Turbo Cache - # id: turbo-cache - # uses: actions/cache@v2 - # with: - # path: .turbo - # key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} - # restore-keys: | - # turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- - # turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- + - name: Turbo Cache + id: turbo-cache + uses: actions/cache@v2 + with: + path: .turbo + key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} + restore-keys: | + turbo-${{ github.job }}- + turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- + turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- - name: Cross build aarch64 - working-directory: packages/next-swc if: ${{ steps.binary-cache.outputs.cache-hit != 'true' }} - run: yarn build-native --release --target aarch64-unknown-linux-gnu + run: turbo run build-native --cache-dir=".turbo" -- --release --target aarch64-unknown-linux-gnu - name: Upload artifact uses: actions/upload-artifact@v2 @@ -1137,7 +1134,7 @@ jobs: # since the repo's dependencies aren't installed we need # to install napi globally - run: npm i -g @napi-rs/cli@1.2.1 - - run: npm i -g turbo@1.0.14 + - run: npm i -g turbo@1.0.24 - name: Install Rust uses: actions-rs/toolchain@v1 with: @@ -1158,19 +1155,19 @@ jobs: sudo apt-get update sudo apt-get install gcc-aarch64-linux-gnu -y - # - name: Turbo Cache - # id: turbo-cache - # uses: actions/cache@v2 - # with: - # path: .turbo - # key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} - # restore-keys: | - # turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- - # turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- + - name: Turbo Cache + id: turbo-cache + uses: actions/cache@v2 + with: + path: .turbo + key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} + restore-keys: | + turbo-${{ github.job }}- + turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- + turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- - name: Cross build aarch64 - working-directory: packages/next-swc - run: yarn build-native --release --target aarch64-unknown-linux-musl + run: turbo run build-native --cache-dir=".turbo" -- --release --target aarch64-unknown-linux-musl - name: Upload artifact uses: actions/upload-artifact@v2 @@ -1198,7 +1195,7 @@ jobs: # since the repo's dependencies aren't installed we need # to install napi globally - run: npm i -g @napi-rs/cli@1.2.1 - - run: npm i -g turbo@1.0.14 + - run: npm i -g turbo@1.0.24 - name: Install Rust uses: actions-rs/toolchain@v1 @@ -1220,19 +1217,19 @@ jobs: sudo apt-get update sudo apt-get install gcc-arm-linux-gnueabihf -y - # - name: Turbo Cache - # id: turbo-cache - # uses: actions/cache@v2 - # with: - # path: .turbo - # key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} - # restore-keys: | - # turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- - # turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- + - name: Turbo Cache + id: turbo-cache + uses: actions/cache@v2 + with: + path: .turbo + key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} + restore-keys: | + turbo-${{ github.job }}- + turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- + turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- - name: Cross build aarch64 - working-directory: packages/next-swc - run: yarn build-native --release --target armv7-unknown-linux-gnueabihf + run: turbo run build-native --cache-dir=".turbo" -- --release --target armv7-unknown-linux-gnueabihf - name: Upload artifact uses: actions/upload-artifact@v2 @@ -1258,7 +1255,7 @@ jobs: # since the repo's dependencies aren't installed we need # to install napi globally - run: npm i -g @napi-rs/cli@1.2.1 - - run: npm i -g turbo@1.0.14 + - run: npm i -g turbo@1.0.24 - name: Install Rust uses: actions-rs/toolchain@v1 @@ -1268,22 +1265,22 @@ jobs: override: true target: aarch64-linux-android - # - name: Turbo Cache - # id: turbo-cache - # uses: actions/cache@v2 - # with: - # path: .turbo - # key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} - # restore-keys: | - # turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- - # turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- + - name: Turbo Cache + id: turbo-cache + uses: actions/cache@v2 + with: + path: .turbo + key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} + restore-keys: | + turbo-${{ github.job }}- + turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- + turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- - name: Build shell: bash - working-directory: packages/next-swc 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 + turbo run build-native --cache-dir=".turbo" -- --release --target aarch64-linux-android - name: Upload artifact uses: actions/upload-artifact@v2 @@ -1318,22 +1315,27 @@ jobs: override: true target: wasm32-unknown-unknown - - name: Cache + - run: npm i -g turbo@1.0.24 + + - name: Turbo cache + id: turbo-cache uses: actions/cache@v2 with: - path: | - ~/.cargo/ - **/target/ - key: ${{ runner.os }}-publish-integration + path: .turbo + key: turbo-${{ github.job }}-${{ matrix.target }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} + restore-keys: | + turbo-${{ github.job }}-${{ matrix.target }}- + turbo-${{ github.job }}-${{ matrix.target }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- + turbo-${{ github.job }}-${{ matrix.target }}-canary-${{ needs.build.outputs.weekNum }}- - name: Install wasm-pack run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh - name: Build - run: (wasm-pack build packages/next-swc/crates/wasm --release --scope=next --target ${{ matrix.target }}) + run: turbo run build-wasm --cache-dir=".turbo" -- --target ${{ matrix.target }} - name: Add target to folder name - run: mv packages/next-swc/crates/wasm/pkg packages/next-swc/crates/wasm/pkg-${{ matrix.target }} + 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' - name: Upload artifact uses: actions/upload-artifact@v2 @@ -1358,6 +1360,8 @@ jobs: with: node-version: 14 + - run: npm i -g turbo@1.0.24 + - name: Install Rust if: ${{needs.build.outputs.docsChange != 'docs only change'}} uses: actions-rs/toolchain@v1 @@ -1367,34 +1371,29 @@ jobs: override: true target: wasm32-unknown-unknown - - name: Cache - if: ${{needs.build.outputs.docsChange != 'docs only change'}} - uses: actions/cache@v2 - with: - path: | - ~/.cargo/ - **/target/ - key: ${{ runner.os }}-publish-integration - - - name: Cache wasm binary - if: ${{needs.build.outputs.docsChange != 'docs only change'}} - id: binary-cache + - name: Turbo Cache + id: turbo-cache uses: actions/cache@v2 + if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }} with: - path: packages/next-swc/crates/wasm/pkg-nodejs - key: dev-wasm-next-swc-nightly-2021-11-15-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next-swc/**') }} + path: .turbo + key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ steps.get-week.outputs.WEEK }}-${{ github.sha }} + restore-keys: | + turbo-${{ github.job }}- + turbo-${{ github.job }}-${{ github.ref_name }}-${{ steps.get-week.outputs.WEEK }}- + turbo-${{ github.job }}-canary-${{ steps.get-week.outputs.WEEK }}- - name: Install wasm-pack - if: ${{needs.build.outputs.docsChange != 'docs only change' && steps.binary-cache.outputs.cache-hit != 'true'}} + if: ${{needs.build.outputs.docsChange != 'docs only change'}} run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh - name: Build - if: ${{needs.build.outputs.docsChange != 'docs only change' && steps.binary-cache.outputs.cache-hit != 'true'}} - run: (wasm-pack build packages/next-swc/crates/wasm --dev --scope=next --target nodejs) + if: ${{needs.build.outputs.docsChange != 'docs only change'}} + run: turbo run build-wasm --cache-dir=".turbo" -- --target nodejs --dev - name: Add target to folder name - if: ${{needs.build.outputs.docsChange != 'docs only change' && steps.binary-cache.outputs.cache-hit != 'true'}} - run: mv packages/next-swc/crates/wasm/pkg packages/next-swc/crates/wasm/pkg-nodejs + if: ${{needs.build.outputs.docsChange != 'docs only change'}} + run: '[[ -d "packages/next-swc/crates/wasm/pkg" ]] && mv packages/next-swc/crates/wasm/pkg packages/next-swc/crates/wasm/pkg-nodejs || ls packages/next-swc/crates/wasm' - name: Upload artifact if: ${{needs.build.outputs.docsChange != 'docs only change'}} diff --git a/docs/advanced-features/measuring-performance.md b/docs/advanced-features/measuring-performance.md index 789d94bb8759c..0a861b416473d 100644 --- a/docs/advanced-features/measuring-performance.md +++ b/docs/advanced-features/measuring-performance.md @@ -164,7 +164,7 @@ export function reportWebVitals(metric) { > ```js > export function reportWebVitals({ id, name, label, value }) { > // Use `window.gtag` if you initialized Google Analytics as this example: -> // https://github.com/vercel/next.js/blob/canary/examples/with-google-analytics/pages/_document.js +> // https://github.com/vercel/next.js/blob/canary/examples/with-google-analytics/pages/_app.js > window.gtag('event', name, { > event_category: > label === 'web-vital' ? 'Web Vitals' : 'Next.js custom metric', diff --git a/docs/api-reference/cli.md b/docs/api-reference/cli.md index b79edb5f0bbce..20b36920d7bf3 100644 --- a/docs/api-reference/cli.md +++ b/docs/api-reference/cli.md @@ -21,7 +21,7 @@ Usage $ next Available commands - build, start, export, dev, lint, telemetry + build, start, export, dev, lint, telemetry, info Options --version, -v Version number @@ -125,3 +125,36 @@ Next.js collects **completely anonymous** telemetry data about general usage. Participation in this anonymous program is optional, and you may opt-out if you'd not like to share any information. To learn more about Telemetry, [please read this document](https://nextjs.org/telemetry/). + +## Info + +`next info` prints relevant details about the current system which can be used to report Next.js bugs. +This information includes Operating System platform/arch/version, Binaries (Node.js, npm, Yarn, pnpm) and npm package versions (`next`, `react`, `react-dom`). + +Running the following in your project's root directory: + +```bash +next info +``` + +will give you information like this example: + +```bash + + Operating System: + Platform: linux + Arch: x64 + Version: #22-Ubuntu SMP Fri Nov 5 13:21:36 UTC 2021 + Binaries: + Node: 16.13.0 + npm: 8.1.0 + Yarn: 1.22.17 + pnpm: 6.24.2 + Relevant packages: + next: 12.0.8 + react: 17.0.2 + react-dom: 17.0.2 + +``` + +This information should then be pasted into GitHub Issues. diff --git a/examples/cms-contentful/pages/api/preview.js b/examples/cms-contentful/pages/api/preview.js new file mode 100644 index 0000000000000..b5d2be17789df --- /dev/null +++ b/examples/cms-contentful/pages/api/preview.js @@ -0,0 +1,33 @@ +import { getPreviewPostBySlug } from '../../lib/api' + +export default async function preview(req, res) { + const { secret, slug } = req.query + + if (secret !== process.env.CONTENTFUL_PREVIEW_SECRET || !slug) { + return res.status(401).json({ message: 'Invalid token' }) + } + + // Fetch the headless CMS to check if the provided `slug` exists + const post = await getPreviewPostBySlug(slug) + + // If the slug doesn't exist prevent preview mode from being enabled + if (!post) { + return res.status(401).json({ message: 'Invalid slug' }) + } + + // Enable Preview Mode by setting the cookies + res.setPreviewData({}) + + // Redirect to the path from the fetched post + // We don't redirect to req.query.slug as that might lead to open redirect vulnerabilities + // res.writeHead(307, { Location: `/posts/${post.slug}` }) + const url = `/posts/${post.slug}` + res.setHeader('Content-Type', 'text/html') + res.write( + ` + + + ` + ) + res.end() +} diff --git a/examples/with-deta-base/package.json b/examples/with-deta-base/package.json index a38fa7b3134b4..e7759e2daac70 100644 --- a/examples/with-deta-base/package.json +++ b/examples/with-deta-base/package.json @@ -6,7 +6,7 @@ "start": "next start" }, "dependencies": { - "deta": "^0.0.8", + "deta": "^1.0.1", "next": "latest", "react": "^17.0.2", "react-dom": "^17.0.2" diff --git a/examples/with-emotion-vanilla/pages/_document.js b/examples/with-emotion-vanilla/pages/_document.js index e34725067736d..34ab85def6e17 100644 --- a/examples/with-emotion-vanilla/pages/_document.js +++ b/examples/with-emotion-vanilla/pages/_document.js @@ -3,9 +3,8 @@ import * as React from 'react' import { renderStatic } from '../shared/renderer' export default class AppDocument extends Document { static async getInitialProps(ctx) { - const page = await ctx.renderPage() - const { css, ids } = await renderStatic(page.html) const initialProps = await Document.getInitialProps(ctx) + const { css, ids } = await renderStatic(initialProps.html) return { ...initialProps, styles: ( diff --git a/examples/with-jest/package.json b/examples/with-jest/package.json index a2a95622fd778..23e5d9ed94c85 100644 --- a/examples/with-jest/package.json +++ b/examples/with-jest/package.json @@ -17,10 +17,12 @@ "@testing-library/jest-dom": "5.16.1", "@testing-library/react": "12.1.2", "@testing-library/user-event": "13.5.0", + "@types/react": "17.0.38", "babel-jest": "27.4.5", "eslint": "8.5.0", "eslint-config-next": "latest", "eslint-plugin-testing-library": "5.0.1", - "jest": "27.4.5" + "jest": "27.4.5", + "typescript": "4.5.4" } } diff --git a/examples/with-redis/pages/api/create.js b/examples/with-redis/pages/api/create.js index 1affbb4400608..df777bce298a0 100644 --- a/examples/with-redis/pages/api/create.js +++ b/examples/with-redis/pages/api/create.js @@ -2,7 +2,7 @@ import { v4 as uuidv4 } from 'uuid' import redis from '../../lib/redis' -export default async function upvote(req, res) { +export default async function create(req, res) { const { title } = req.body if (!title) { diff --git a/examples/with-redis/pages/api/features.js b/examples/with-redis/pages/api/features.js index 37c1e67abfd54..afa8546703e70 100644 --- a/examples/with-redis/pages/api/features.js +++ b/examples/with-redis/pages/api/features.js @@ -1,6 +1,6 @@ import redis from '../../lib/redis' -export default async function upvote(req, res) { +export default async function getAllFeatures(req, res) { const features = (await redis.hvals('features')) .map((entry) => JSON.parse(entry)) .sort((a, b) => b.score - a.score) diff --git a/examples/with-redis/pages/api/subscribe.js b/examples/with-redis/pages/api/subscribe.js index 4b1895b0b6ba0..436ff17642cdd 100644 --- a/examples/with-redis/pages/api/subscribe.js +++ b/examples/with-redis/pages/api/subscribe.js @@ -1,6 +1,6 @@ import redis from '../../lib/redis' -export default async function upvote(req, res) { +export default async function subscribe(req, res) { const { email } = req.body if (email && validateEmail(email)) { diff --git a/examples/with-tailwindcss/.eslintrc.json b/examples/with-tailwindcss/.eslintrc.json new file mode 100644 index 0000000000000..bffb357a71225 --- /dev/null +++ b/examples/with-tailwindcss/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "next/core-web-vitals" +} diff --git a/examples/with-tailwindcss/.gitignore b/examples/with-tailwindcss/.gitignore index 1437c53f70bc2..88b6f0d981643 100644 --- a/examples/with-tailwindcss/.gitignore +++ b/examples/with-tailwindcss/.gitignore @@ -32,3 +32,6 @@ yarn-error.log* # vercel .vercel + +# typescript +*.tsbuildinfo diff --git a/examples/with-tailwindcss/README.md b/examples/with-tailwindcss/README.md index 5981eee944757..dc54d0c3f47ed 100644 --- a/examples/with-tailwindcss/README.md +++ b/examples/with-tailwindcss/README.md @@ -1,3 +1,11 @@ +

+ +Next.js TypeScript Starter + +

+ +
+ # Next.js + Tailwind CSS Example This example shows how to use [Tailwind CSS](https://tailwindcss.com/) [(v3.0)](https://tailwindcss.com/blog/tailwindcss-v3) with Next.js. It follows the steps outlined in the official [Tailwind docs](https://tailwindcss.com/docs/guides/nextjs). diff --git a/examples/with-tailwindcss/next-env.d.ts b/examples/with-tailwindcss/next-env.d.ts new file mode 100644 index 0000000000000..4f11a03dc6cc3 --- /dev/null +++ b/examples/with-tailwindcss/next-env.d.ts @@ -0,0 +1,5 @@ +/// +/// + +// NOTE: This file should not be edited +// see https://nextjs.org/docs/basic-features/typescript for more information. diff --git a/examples/with-tailwindcss/next.config.js b/examples/with-tailwindcss/next.config.js new file mode 100644 index 0000000000000..8b61df4e50f8a --- /dev/null +++ b/examples/with-tailwindcss/next.config.js @@ -0,0 +1,4 @@ +/** @type {import('next').NextConfig} */ +module.exports = { + reactStrictMode: true, +} diff --git a/examples/with-tailwindcss/package.json b/examples/with-tailwindcss/package.json index 0850b4715b9c0..777749724d872 100644 --- a/examples/with-tailwindcss/package.json +++ b/examples/with-tailwindcss/package.json @@ -11,8 +11,13 @@ "react-dom": "^17.0.2" }, "devDependencies": { + "@types/node": "17.0.4", + "@types/react": "17.0.38", "autoprefixer": "^10.4.0", - "postcss": "^8.4.4", - "tailwindcss": "^3.0.0" + "eslint": "8.5.0", + "eslint-config-next": "12.0.7", + "postcss": "^8.4.5", + "tailwindcss": "^3.0.7", + "typescript": "4.5.4" } } diff --git a/examples/with-tailwindcss/pages/_app.js b/examples/with-tailwindcss/pages/_app.tsx similarity index 50% rename from examples/with-tailwindcss/pages/_app.js rename to examples/with-tailwindcss/pages/_app.tsx index 1e1cec92425c8..3f5c9d5485860 100644 --- a/examples/with-tailwindcss/pages/_app.js +++ b/examples/with-tailwindcss/pages/_app.tsx @@ -1,6 +1,7 @@ import '../styles/globals.css' +import type { AppProps } from 'next/app' -function MyApp({ Component, pageProps }) { +function MyApp({ Component, pageProps }: AppProps) { return } diff --git a/examples/with-tailwindcss/pages/api/hello.js b/examples/with-tailwindcss/pages/api/hello.js deleted file mode 100644 index f163396631ba5..0000000000000 --- a/examples/with-tailwindcss/pages/api/hello.js +++ /dev/null @@ -1,5 +0,0 @@ -// Next.js API route support: https://nextjs.org/docs/api-routes/introduction - -export default function helloAPI(req, res) { - res.status(200).json({ name: 'John Doe' }) -} diff --git a/examples/with-tailwindcss/pages/api/hello.ts b/examples/with-tailwindcss/pages/api/hello.ts new file mode 100644 index 0000000000000..f8bcc7e5caed1 --- /dev/null +++ b/examples/with-tailwindcss/pages/api/hello.ts @@ -0,0 +1,13 @@ +// Next.js API route support: https://nextjs.org/docs/api-routes/introduction +import type { NextApiRequest, NextApiResponse } from 'next' + +type Data = { + name: string +} + +export default function handler( + req: NextApiRequest, + res: NextApiResponse +) { + res.status(200).json({ name: 'John Doe' }) +} diff --git a/examples/with-tailwindcss/pages/index.js b/examples/with-tailwindcss/pages/index.tsx similarity index 99% rename from examples/with-tailwindcss/pages/index.js rename to examples/with-tailwindcss/pages/index.tsx index 6b67e91ccd256..828dd6012730d 100644 --- a/examples/with-tailwindcss/pages/index.js +++ b/examples/with-tailwindcss/pages/index.tsx @@ -19,7 +19,7 @@ export default function Home() {

Get started by editing{' '} - pages/index.js + pages/index.tsx

diff --git a/examples/with-tailwindcss/postcss.config.js b/examples/with-tailwindcss/postcss.config.js index 3fa0a9514dc9d..33ad091d26d8a 100644 --- a/examples/with-tailwindcss/postcss.config.js +++ b/examples/with-tailwindcss/postcss.config.js @@ -1,5 +1,3 @@ -// If you want to use other PostCSS plugins, see the following: -// https://tailwindcss.com/docs/using-with-preprocessors module.exports = { plugins: { tailwindcss: {}, diff --git a/examples/with-tailwindcss/tsconfig.json b/examples/with-tailwindcss/tsconfig.json new file mode 100644 index 0000000000000..99710e857874f --- /dev/null +++ b/examples/with-tailwindcss/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "target": "es5", + "lib": ["dom", "dom.iterable", "esnext"], + "allowJs": true, + "skipLibCheck": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "noEmit": true, + "esModuleInterop": true, + "module": "esnext", + "moduleResolution": "node", + "resolveJsonModule": true, + "isolatedModules": true, + "jsx": "preserve", + "incremental": true + }, + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], + "exclude": ["node_modules"] +} diff --git a/examples/with-typescript/pages/api/users/index.ts b/examples/with-typescript/pages/api/users/index.ts index 4efdba6f1a4e7..67a645ea39199 100644 --- a/examples/with-typescript/pages/api/users/index.ts +++ b/examples/with-typescript/pages/api/users/index.ts @@ -8,7 +8,7 @@ const handler = (_req: NextApiRequest, res: NextApiResponse) => { } res.status(200).json(sampleUserData) - } catch (err) { + } catch (err: any) { res.status(500).json({ statusCode: 500, message: err.message }) } } diff --git a/examples/with-typescript/pages/users/[id].tsx b/examples/with-typescript/pages/users/[id].tsx index 61720da5a7a5d..ca442c0c16a4b 100644 --- a/examples/with-typescript/pages/users/[id].tsx +++ b/examples/with-typescript/pages/users/[id].tsx @@ -55,7 +55,7 @@ export const getStaticProps: GetStaticProps = async ({ params }) => { // By returning { props: item }, the StaticPropsDetail component // will receive `item` as a prop at build time return { props: { item } } - } catch (err) { + } catch (err: any) { return { props: { errors: err.message } } } } diff --git a/lerna.json b/lerna.json index 27d719a3c291d..f975ce5a8ff8f 100644 --- a/lerna.json +++ b/lerna.json @@ -17,5 +17,5 @@ "registry": "https://registry.npmjs.org/" } }, - "version": "12.0.8-canary.14" + "version": "12.0.8-canary.17" } diff --git a/package.json b/package.json index 84553d2b39362..1d2b13d141d41 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,7 @@ "@types/fs-extra": "8.1.0", "@types/http-proxy": "1.17.3", "@types/jest": "24.0.13", + "@types/node": "13.11.0", "@types/selenium-webdriver": "4.0.15", "@types/sharp": "0.29.3", "@types/string-hash": "1.1.1", @@ -153,7 +154,7 @@ "tailwindcss": "1.1.3", "taskr": "1.1.0", "tree-kill": "1.2.2", - "turbo": "1.0.14", + "turbo": "1.0.24", "typescript": "4.4.3", "wait-port": "0.2.2", "web-streams-polyfill": "2.1.1", diff --git a/packages/create-next-app/package.json b/packages/create-next-app/package.json index 8a372a22b8c59..a095e220fc013 100644 --- a/packages/create-next-app/package.json +++ b/packages/create-next-app/package.json @@ -1,6 +1,6 @@ { "name": "create-next-app", - "version": "12.0.8-canary.14", + "version": "12.0.8-canary.17", "keywords": [ "react", "next", diff --git a/packages/eslint-config-next/package.json b/packages/eslint-config-next/package.json index c5c9156459dcc..97a558e6f4a10 100644 --- a/packages/eslint-config-next/package.json +++ b/packages/eslint-config-next/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-next", - "version": "12.0.8-canary.14", + "version": "12.0.8-canary.17", "description": "ESLint configuration used by NextJS.", "main": "index.js", "license": "MIT", @@ -9,7 +9,7 @@ "directory": "packages/eslint-config-next" }, "dependencies": { - "@next/eslint-plugin-next": "12.0.8-canary.14", + "@next/eslint-plugin-next": "12.0.8-canary.17", "@rushstack/eslint-patch": "^1.0.8", "@typescript-eslint/parser": "^5.0.0", "eslint-import-resolver-node": "^0.3.4", diff --git a/packages/eslint-plugin-next/package.json b/packages/eslint-plugin-next/package.json index 90f4d1398f0b6..c25236678930a 100644 --- a/packages/eslint-plugin-next/package.json +++ b/packages/eslint-plugin-next/package.json @@ -1,6 +1,6 @@ { "name": "@next/eslint-plugin-next", - "version": "12.0.8-canary.14", + "version": "12.0.8-canary.17", "description": "ESLint plugin for NextJS.", "main": "lib/index.js", "license": "MIT", diff --git a/packages/next-bundle-analyzer/package.json b/packages/next-bundle-analyzer/package.json index 6bc81b90abe5e..9f0b2fcb47532 100644 --- a/packages/next-bundle-analyzer/package.json +++ b/packages/next-bundle-analyzer/package.json @@ -1,6 +1,6 @@ { "name": "@next/bundle-analyzer", - "version": "12.0.8-canary.14", + "version": "12.0.8-canary.17", "main": "index.js", "license": "MIT", "repository": { diff --git a/packages/next-codemod/package.json b/packages/next-codemod/package.json index 0432bebf22ddf..f4d5bbf559895 100644 --- a/packages/next-codemod/package.json +++ b/packages/next-codemod/package.json @@ -1,6 +1,6 @@ { "name": "@next/codemod", - "version": "12.0.8-canary.14", + "version": "12.0.8-canary.17", "license": "MIT", "dependencies": { "chalk": "4.1.0", diff --git a/packages/next-env/package.json b/packages/next-env/package.json index 47a277a0aaaa1..261cf37790415 100644 --- a/packages/next-env/package.json +++ b/packages/next-env/package.json @@ -1,6 +1,6 @@ { "name": "@next/env", - "version": "12.0.8-canary.14", + "version": "12.0.8-canary.17", "keywords": [ "react", "next", diff --git a/packages/next-mdx/package.json b/packages/next-mdx/package.json index 9e3157f7bd6da..10a51f853ae26 100644 --- a/packages/next-mdx/package.json +++ b/packages/next-mdx/package.json @@ -1,6 +1,6 @@ { "name": "@next/mdx", - "version": "12.0.8-canary.14", + "version": "12.0.8-canary.17", "main": "index.js", "license": "MIT", "repository": { diff --git a/packages/next-plugin-storybook/package.json b/packages/next-plugin-storybook/package.json index 6403a1dac08b5..7792749f169c6 100644 --- a/packages/next-plugin-storybook/package.json +++ b/packages/next-plugin-storybook/package.json @@ -1,6 +1,6 @@ { "name": "@next/plugin-storybook", - "version": "12.0.8-canary.14", + "version": "12.0.8-canary.17", "repository": { "url": "vercel/next.js", "directory": "packages/next-plugin-storybook" diff --git a/packages/next-polyfill-module/package.json b/packages/next-polyfill-module/package.json index 867e70fecbae4..34924c34e3f15 100644 --- a/packages/next-polyfill-module/package.json +++ b/packages/next-polyfill-module/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-module", - "version": "12.0.8-canary.14", + "version": "12.0.8-canary.17", "description": "A standard library polyfill for ES Modules supporting browsers (Edge 16+, Firefox 60+, Chrome 61+, Safari 10.1+)", "main": "dist/polyfill-module.js", "license": "MIT", diff --git a/packages/next-polyfill-nomodule/package.json b/packages/next-polyfill-nomodule/package.json index 0e73a87939b48..c7a2fc585bc0f 100644 --- a/packages/next-polyfill-nomodule/package.json +++ b/packages/next-polyfill-nomodule/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-nomodule", - "version": "12.0.8-canary.14", + "version": "12.0.8-canary.17", "description": "A polyfill for non-dead, nomodule browsers.", "main": "dist/polyfill-nomodule.js", "license": "MIT", diff --git a/packages/next-swc/package.json b/packages/next-swc/package.json index 57df6bef350e8..8da471a5622b1 100644 --- a/packages/next-swc/package.json +++ b/packages/next-swc/package.json @@ -1,6 +1,6 @@ { "name": "@next/swc", - "version": "12.0.8-canary.14", + "version": "12.0.8-canary.17", "private": true, "scripts": { "build-native": "napi build --platform --cargo-name next_swc_napi native", diff --git a/packages/next/bin/next.ts b/packages/next/bin/next.ts index e8df92a3c8ae8..283e0996b7477 100755 --- a/packages/next/bin/next.ts +++ b/packages/next/bin/next.ts @@ -23,6 +23,7 @@ const commands: { [command: string]: () => Promise } = { lint: () => Promise.resolve(require('../cli/next-lint').nextLint), telemetry: () => Promise.resolve(require('../cli/next-telemetry').nextTelemetry), + info: () => Promise.resolve(require('../cli/next-info').nextInfo), } const args = arg( diff --git a/packages/next/build/index.ts b/packages/next/build/index.ts index be3f4e04e8d33..08adb67428e13 100644 --- a/packages/next/build/index.ts +++ b/packages/next/build/index.ts @@ -1400,6 +1400,13 @@ export default async function build( 'utf8' ) + const middlewareManifest: MiddlewareManifest = JSON.parse( + await promises.readFile( + path.join(distDir, SERVER_DIRECTORY, MIDDLEWARE_MANIFEST), + 'utf8' + ) + ) + const outputFileTracingRoot = config.experimental.outputFileTracingRoot || dir @@ -1412,7 +1419,8 @@ export default async function build( distDir, pageKeys, outputFileTracingRoot, - requiredServerFiles.config + requiredServerFiles.config, + middlewareManifest ) }) } @@ -1961,13 +1969,6 @@ export default async function build( ) } - const middlewareManifest: MiddlewareManifest = JSON.parse( - await promises.readFile( - path.join(distDir, SERVER_DIRECTORY, MIDDLEWARE_MANIFEST), - 'utf8' - ) - ) - await promises.writeFile( path.join( distDir, @@ -2032,7 +2033,8 @@ export default async function build( path.relative(outputFileTracingRoot, distDir), SERVER_DIRECTORY, 'pages' - ) + ), + { overwrite: true } ) } diff --git a/packages/next/build/swc/options.js b/packages/next/build/swc/options.js index 6e2a852bfc0fc..103119885e47b 100644 --- a/packages/next/build/swc/options.js +++ b/packages/next/build/swc/options.js @@ -7,6 +7,7 @@ const regeneratorRuntimePath = require.resolve( function getBaseSWCOptions({ filename, + jest, development, hasReactRefresh, globalWindow, @@ -50,15 +51,17 @@ function getBaseSWCOptions({ }, optimizer: { simplify: false, - globals: { - typeofs: { - window: globalWindow ? 'object' : 'undefined', - }, - envs: { - NODE_ENV: development ? '"development"' : '"production"', - }, - // TODO: handle process.browser to match babel replacing as well - }, + globals: jest + ? null + : { + typeofs: { + window: globalWindow ? 'object' : 'undefined', + }, + envs: { + NODE_ENV: development ? '"development"' : '"production"', + }, + // TODO: handle process.browser to match babel replacing as well + }, }, regenerator: { importPath: regeneratorRuntimePath, @@ -86,6 +89,7 @@ export function getJestSWCOptions({ }) { let baseOptions = getBaseSWCOptions({ filename, + jest: true, development: false, hasReactRefresh: false, globalWindow: !isServer, diff --git a/packages/next/build/utils.ts b/packages/next/build/utils.ts index 6140d8c4388ef..b0332a1f5a898 100644 --- a/packages/next/build/utils.ts +++ b/packages/next/build/utils.ts @@ -16,6 +16,7 @@ import { SSG_GET_INITIAL_PROPS_CONFLICT, SERVER_PROPS_GET_INIT_PROPS_CONFLICT, SERVER_PROPS_SSG_CONFLICT, + MIDDLEWARE_ROUTE, } from '../lib/constants' import prettyBytes from '../lib/pretty-bytes' import { recursiveReadDir } from '../lib/recursive-readdir' @@ -40,6 +41,7 @@ import { NextConfigComplete } from '../server/config-shared' import isError from '../lib/is-error' import { recursiveDelete } from '../lib/recursive-delete' import { Sema } from 'next/dist/compiled/async-sema' +import { MiddlewareManifest } from './webpack/plugins/middleware-plugin' const { builtinModules } = require('module') const RESERVED_PAGE = /^\/(_app|_error|_document|api(\/|$))/ @@ -1156,7 +1158,8 @@ export async function copyTracedFiles( distDir: string, pageKeys: string[], tracingRoot: string, - serverConfig: { [key: string]: any } + serverConfig: { [key: string]: any }, + middlewareManifest: MiddlewareManifest ) { const outputPath = path.join(distDir, 'standalone') const copiedFiles = new Set() @@ -1202,6 +1205,23 @@ export async function copyTracedFiles( } for (const page of pageKeys) { + if (MIDDLEWARE_ROUTE.test(page)) { + const { files } = + middlewareManifest.middleware[page.replace(/\/_middleware$/, '')] + + for (const file of files) { + const originalPath = path.join(distDir, file) + const fileOutputPath = path.join( + outputPath, + path.relative(tracingRoot, distDir), + file + ) + await fs.mkdir(path.dirname(fileOutputPath), { recursive: true }) + await fs.copyFile(originalPath, fileOutputPath) + } + continue + } + const pageFile = path.join( distDir, 'server', @@ -1226,16 +1246,7 @@ const NextServer = require('next/dist/server/next-server').default const http = require('http') const path = require('path') -const nextServer = new NextServer({ - dir: path.join(__dirname), - dev: false, - conf: ${JSON.stringify({ - ...serverConfig, - distDir: `./${path.relative(dir, distDir)}`, - })}, -}) - -const handler = nextServer.getRequestHandler() +let handler const server = http.createServer(async (req, res) => { try { @@ -1246,12 +1257,26 @@ const server = http.createServer(async (req, res) => { res.end('internal server error') } }) -const currentPort = process.env.PORT || 3000 +const currentPort = parseInt(process.env.PORT, 10) || 3000 + server.listen(currentPort, (err) => { if (err) { console.error("Failed to start server", err) process.exit(1) } + const addr = server.address() + const nextServer = new NextServer({ + hostname: 'localhost', + port: currentPort, + dir: path.join(__dirname), + dev: false, + conf: ${JSON.stringify({ + ...serverConfig, + distDir: `./${path.relative(dir, distDir)}`, + })}, + }) + handler = nextServer.getRequestHandler() + console.log("Listening on port", currentPort) }) ` diff --git a/packages/next/build/webpack-config.ts b/packages/next/build/webpack-config.ts index 37c918d622e4d..bbac49486d94a 100644 --- a/packages/next/build/webpack-config.ts +++ b/packages/next/build/webpack-config.ts @@ -615,6 +615,8 @@ export default async function getBaseWebpackConfig( : 'react-dom/cjs/react-dom-server.browser.production.min', } : {}), + + setimmediate: 'next/dist/compiled/setimmediate', }, ...(targetWeb ? { @@ -632,7 +634,7 @@ export default async function getBaseWebpackConfig( https: require.resolve('next/dist/compiled/https-browserify'), os: require.resolve('next/dist/compiled/os-browserify'), path: require.resolve('next/dist/compiled/path-browserify'), - punycode: require.resolve('punycode'), + punycode: require.resolve('next/dist/compiled/punycode'), process: require.resolve('next/dist/compiled/process'), // Handled in separate alias querystring: require.resolve('next/dist/compiled/querystring-es3'), @@ -650,6 +652,7 @@ export default async function getBaseWebpackConfig( vm: require.resolve('next/dist/compiled/vm-browserify'), zlib: require.resolve('next/dist/compiled/browserify-zlib'), events: require.resolve('next/dist/compiled/events/'), + setImmediate: require.resolve('next/dist/compiled/setimmediate'), }, } : undefined), diff --git a/packages/next/cli/next-info.ts b/packages/next/cli/next-info.ts new file mode 100755 index 0000000000000..b0e957bc8dcc7 --- /dev/null +++ b/packages/next/cli/next-info.ts @@ -0,0 +1,76 @@ +#!/usr/bin/env node +import os from 'os' +import childProcess from 'child_process' + +import chalk from 'next/dist/compiled/chalk' +import arg from 'next/dist/compiled/arg/index.js' +import { printAndExit } from '../server/lib/utils' +import { cliCommand } from '../bin/next' +import isError from '../lib/is-error' + +const nextInfo: cliCommand = async (argv) => { + const validArgs: arg.Spec = { + // Types + '--help': Boolean, + // Aliases + '-h': '--help', + } + let args: arg.Result + try { + args = arg(validArgs, { argv }) + } catch (error) { + if (isError(error) && error.code === 'ARG_UNKNOWN_OPTION') { + return printAndExit(error.message, 1) + } + throw error + } + + if (args['--help']) { + console.log( + ` + Description + Prints relevant details about the current system which can be used to report Next.js bugs + + Usage + $ next info + + Learn more: ${chalk.cyan( + 'https://nextjs.org/docs/api-reference/cli#info' + )}` + ) + return + } + + console.log(` + Operating System: + Platform: ${os.platform()} + Arch: ${os.arch()} + Version: ${os.version()} + Binaries: + Node: ${process.versions.node} + npm: ${getBinaryVersion('npm')} + Yarn: ${getBinaryVersion('yarn')} + pnpm: ${getBinaryVersion('pnpm')} + Relevant packages: + next: ${getPackageVersion('next')} + react: ${getPackageVersion('react')} + react-dom: ${getPackageVersion('react-dom')}`) +} + +export { nextInfo } + +function getPackageVersion(packageName: string) { + try { + return require(`${packageName}/package.json`).version + } catch { + return 'N/A' + } +} + +function getBinaryVersion(binaryName: string) { + try { + return childProcess.execSync(`${binaryName} --version`).toString().trim() + } catch { + return 'N/A' + } +} diff --git a/packages/next/compiled/punycode/package.json b/packages/next/compiled/punycode/package.json new file mode 100644 index 0000000000000..cf52cbab85fed --- /dev/null +++ b/packages/next/compiled/punycode/package.json @@ -0,0 +1 @@ +{"name":"punycode","main":"punycode.js","author":{"name":"Mathias Bynens","url":"https://mathiasbynens.be/"},"license":"MIT"} diff --git a/packages/next/compiled/punycode/punycode.js b/packages/next/compiled/punycode/punycode.js new file mode 100644 index 0000000000000..ae4e2f0f0b46a --- /dev/null +++ b/packages/next/compiled/punycode/punycode.js @@ -0,0 +1 @@ +(function(){"use strict";var t={701:function(t){const e=2147483647;const o=36;const n=1;const r=26;const c=38;const s=700;const i=72;const f=128;const u="-";const l=/^xn--/;const a=/[^\0-\x7E]/;const p=/[\x2E\u3002\uFF0E\uFF61]/g;const d={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"};const _=o-n;const h=Math.floor;const w=String.fromCharCode;function error(t){throw new RangeError(d[t])}function map(t,e){const o=[];let n=t.length;while(n--){o[n]=e(t[n])}return o}function mapDomain(t,e){const o=t.split("@");let n="";if(o.length>1){n=o[0]+"@";t=o[1]}t=t.replace(p,".");const r=t.split(".");const c=map(r,e).join(".");return n+c}function ucs2decode(t){const e=[];let o=0;const n=t.length;while(o=55296&&r<=56319&&oString.fromCodePoint(...t);const basicToDigit=function(t){if(t-48<10){return t-22}if(t-65<26){return t-65}if(t-97<26){return t-97}return o};const digitToBasic=function(t,e){return t+22+75*(t<26)-((e!=0)<<5)};const adapt=function(t,e,n){let i=0;t=n?h(t/s):t>>1;t+=h(t/e);for(;t>_*r>>1;i+=o){t=h(t/_)}return h(i+(_+1)*t/(t+c))};const decode=function(t){const c=[];const s=t.length;let l=0;let a=f;let p=i;let d=t.lastIndexOf(u);if(d<0){d=0}for(let e=0;e=128){error("not-basic")}c.push(t.charCodeAt(e))}for(let i=d>0?d+1:0;i=s){error("invalid-input")}const u=basicToDigit(t.charCodeAt(i++));if(u>=o||u>h((e-l)/c)){error("overflow")}l+=u*c;const a=f<=p?n:f>=p+r?r:f-p;if(uh(e/d)){error("overflow")}c*=d}const u=c.length+1;p=adapt(l-f,u,f==0);if(h(l/u)>e-a){error("overflow")}a+=h(l/u);l%=u;c.splice(l++,0,a)}return String.fromCodePoint(...c)};const encode=function(t){const c=[];t=ucs2decode(t);let s=t.length;let l=f;let a=0;let p=i;for(const e of t){if(e<128){c.push(w(e))}}let d=c.length;let _=d;if(d){c.push(u)}while(_=l&&eh((e-a)/i)){error("overflow")}a+=(s-l)*i;l=s;for(const s of t){if(se){error("overflow")}if(s==l){let t=a;for(let e=o;;e+=o){const s=e<=p?n:e>=p+r?r:e-p;if(t=0){e._idleTimeoutId=setTimeout((function onTimeout(){if(e._onTimeout)e._onTimeout()}),t)}};n(619);t.setImmediate=typeof self!=="undefined"&&self.setImmediate||typeof global!=="undefined"&&global.setImmediate||this&&this.setImmediate;t.clearImmediate=typeof self!=="undefined"&&self.clearImmediate||typeof global!=="undefined"&&global.clearImmediate||this&&this.clearImmediate}};var t={};function __nccwpck_require__(n){var a=t[n];if(a!==undefined){return a.exports}var i=t[n]={exports:{}};var o=true;try{e[n].call(i.exports,i,i.exports,__nccwpck_require__);o=false}finally{if(o)delete t[n]}return i.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var n=__nccwpck_require__(832);module.exports=n})(); \ No newline at end of file +(function(){var e={832:function(e,t,i){var o=typeof global!=="undefined"&&global||typeof self!=="undefined"&&self||window;var n=Function.prototype.apply;t.setTimeout=function(){return new Timeout(n.call(setTimeout,o,arguments),clearTimeout)};t.setInterval=function(){return new Timeout(n.call(setInterval,o,arguments),clearInterval)};t.clearTimeout=t.clearInterval=function(e){if(e){e.close()}};function Timeout(e,t){this._id=e;this._clearFn=t}Timeout.prototype.unref=Timeout.prototype.ref=function(){};Timeout.prototype.close=function(){this._clearFn.call(o,this._id)};t.enroll=function(e,t){clearTimeout(e._idleTimeoutId);e._idleTimeout=t};t.unenroll=function(e){clearTimeout(e._idleTimeoutId);e._idleTimeout=-1};t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;if(t>=0){e._idleTimeoutId=setTimeout((function onTimeout(){if(e._onTimeout)e._onTimeout()}),t)}};i(505);t.setImmediate=typeof self!=="undefined"&&self.setImmediate||typeof global!=="undefined"&&global.setImmediate||this&&this.setImmediate;t.clearImmediate=typeof self!=="undefined"&&self.clearImmediate||typeof global!=="undefined"&&global.clearImmediate||this&&this.clearImmediate},505:function(e){"use strict";e.exports=require("next/dist/compiled/setimmediate")}};var t={};function __nccwpck_require__(i){var o=t[i];if(o!==undefined){return o.exports}var n=t[i]={exports:{}};var r=true;try{e[i].call(n.exports,n,n.exports,__nccwpck_require__);r=false}finally{if(r)delete t[i]}return n.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var i=__nccwpck_require__(832);module.exports=i})(); \ No newline at end of file diff --git a/packages/next/package.json b/packages/next/package.json index 23686a9cab205..e7442ee8955a3 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -1,6 +1,6 @@ { "name": "next", - "version": "12.0.8-canary.14", + "version": "12.0.8-canary.17", "description": "The React Framework", "main": "./dist/server/next.js", "license": "MIT", @@ -71,8 +71,8 @@ ] }, "dependencies": { - "@next/env": "12.0.8-canary.14", - "@next/react-refresh-utils": "12.0.8-canary.14", + "@next/env": "12.0.8-canary.17", + "@next/react-refresh-utils": "12.0.8-canary.17", "caniuse-lite": "^1.0.30001283", "jest-worker": "27.0.0-next.5", "node-fetch": "2.6.1", @@ -125,10 +125,10 @@ "@hapi/accept": "5.0.2", "@napi-rs/cli": "1.2.1", "@napi-rs/triples": "1.0.3", - "@next/polyfill-module": "12.0.8-canary.14", - "@next/polyfill-nomodule": "12.0.8-canary.14", - "@next/react-dev-overlay": "12.0.8-canary.14", - "@next/swc": "12.0.8-canary.14", + "@next/polyfill-module": "12.0.8-canary.17", + "@next/polyfill-nomodule": "12.0.8-canary.17", + "@next/react-dev-overlay": "12.0.8-canary.17", + "@next/swc": "12.0.8-canary.17", "@peculiar/webcrypto": "1.1.7", "@taskr/clear": "1.1.0", "@taskr/esnext": "1.1.0", @@ -237,6 +237,7 @@ "postcss-scss": "3.0.5", "postcss-value-parser": "4.1.0", "process": "0.11.10", + "punycode": "2.1.1", "querystring-es3": "0.2.1", "raw-body": "2.4.1", "react-server-dom-webpack": "0.0.0-experimental-13455d26d-20211104", @@ -246,6 +247,7 @@ "schema-utils3": "npm:schema-utils@3.0.0", "semver": "7.3.2", "send": "0.17.1", + "setimmediate": "1.0.5", "source-map": "0.6.1", "stream-http": "3.1.1", "string-hash": "1.1.3", diff --git a/packages/next/pages/_document.tsx b/packages/next/pages/_document.tsx index c1c00608dc5fb..8d314577f4584 100644 --- a/packages/next/pages/_document.tsx +++ b/packages/next/pages/_document.tsx @@ -452,21 +452,30 @@ export class Head extends Component< makeStylesheetInert(node: ReactNode): ReactNode[] { return React.Children.map(node, (c: any) => { if ( - c.type === 'link' && - c.props['href'] && + c?.type === 'link' && + c?.props?.href && OPTIMIZED_FONT_PROVIDERS.some(({ url }) => - c.props['href'].startsWith(url) + c?.props?.href?.startsWith(url) ) ) { - const newProps = { ...(c.props || {}) } - newProps['data-href'] = newProps['href'] - newProps['href'] = undefined + const newProps = { + ...(c.props || {}), + 'data-href': c.props.href, + href: undefined, + } + + return React.cloneElement(c, newProps) + } else if (c?.props?.children) { + const newProps = { + ...(c.props || {}), + children: this.makeStylesheetInert(c.props.children), + } + return React.cloneElement(c, newProps) - } else if (c.props && c.props['children']) { - c.props['children'] = this.makeStylesheetInert(c.props['children']) } + return c - }) + }).filter(Boolean) } render() { diff --git a/packages/next/shared/lib/utils.ts b/packages/next/shared/lib/utils.ts index 34b948691263e..bbee6dc34aa6c 100644 --- a/packages/next/shared/lib/utils.ts +++ b/packages/next/shared/lib/utils.ts @@ -456,6 +456,6 @@ export interface CacheFs { readFile(f: string): Promise readFileSync(f: string): string writeFile(f: string, d: any): Promise - mkdir(dir: string): Promise + mkdir(dir: string): Promise stat(f: string): Promise<{ mtime: Date }> } diff --git a/packages/next/taskfile.js b/packages/next/taskfile.js index 7b088e7d4e0bc..f0c348e9c57c9 100644 --- a/packages/next/taskfile.js +++ b/packages/next/taskfile.js @@ -510,6 +510,32 @@ export async function ncc_util(task, opts) { .target('compiled/util') } +// eslint-disable-next-line camelcase +export async function ncc_punycode(task, opts) { + await task + .source(opts.src || relative(__dirname, require.resolve('punycode/'))) + .ncc({ + packageName: 'punycode', + externals, + mainFields: ['browser', 'main'], + target: 'es5', + }) + .target('compiled/punycode') +} + +// eslint-disable-next-line camelcase +export async function ncc_set_immediate(task, opts) { + await task + .source(opts.src || relative(__dirname, require.resolve('setimmediate/'))) + .ncc({ + packageName: 'setimmediate', + externals, + mainFields: ['browser', 'main'], + target: 'es5', + }) + .target('compiled/setimmediate') +} + // eslint-disable-next-line camelcase export async function ncc_timers_browserify(task, opts) { await task @@ -518,7 +544,10 @@ export async function ncc_timers_browserify(task, opts) { ) .ncc({ packageName: 'timers-browserify', - externals, + externals: { + ...externals, + setimmediate: 'next/dist/compiled/setimmediate', + }, mainFields: ['browser', 'main'], target: 'es5', }) @@ -1444,6 +1473,8 @@ export async function ncc(task, opts) { 'ncc_querystring_es3', 'ncc_string_decoder', 'ncc_util', + 'ncc_punycode', + 'ncc_set_immediate', 'ncc_timers_browserify', 'ncc_tty_browserify', 'ncc_vm_browserify', diff --git a/packages/react-dev-overlay/package.json b/packages/react-dev-overlay/package.json index 883681d2d01c0..a22e41895c55c 100644 --- a/packages/react-dev-overlay/package.json +++ b/packages/react-dev-overlay/package.json @@ -1,6 +1,6 @@ { "name": "@next/react-dev-overlay", - "version": "12.0.8-canary.14", + "version": "12.0.8-canary.17", "description": "A development-only overlay for developing React applications.", "repository": { "url": "vercel/next.js", diff --git a/packages/react-refresh-utils/package.json b/packages/react-refresh-utils/package.json index a639b283b6154..447adca6df43d 100644 --- a/packages/react-refresh-utils/package.json +++ b/packages/react-refresh-utils/package.json @@ -1,6 +1,6 @@ { "name": "@next/react-refresh-utils", - "version": "12.0.8-canary.14", + "version": "12.0.8-canary.17", "description": "An experimental package providing utilities for React Refresh.", "repository": { "url": "vercel/next.js", diff --git a/test/integration/polyfill-node-modules/test/index.test.js b/test/development/basic/node-browser-polyfills.test.ts similarity index 70% rename from test/integration/polyfill-node-modules/test/index.test.js rename to test/development/basic/node-browser-polyfills.test.ts index 0b10c4d09c546..de6352b400231 100644 --- a/test/integration/polyfill-node-modules/test/index.test.js +++ b/test/development/basic/node-browser-polyfills.test.ts @@ -1,22 +1,22 @@ -/* eslint-env jest */ - import { join } from 'path' import webdriver from 'next-webdriver' -import { findPort, launchApp, killApp } from 'next-test-utils' +import { createNext, FileRef } from 'e2e-utils' +import { NextInstance } from 'test/lib/next-modes/base' -const appDir = join(__dirname, '../') -let appPort -let app +describe('theme-ui SWC option', () => { + let next: NextInstance -describe('Basic Features', () => { beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) + next = await createNext({ + files: { + pages: new FileRef(join(__dirname, 'node-browser-polyfills/pages')), + }, + }) }) - afterAll(() => killApp(app)) + afterAll(() => next.destroy()) - it('should polyfill Node.js modules', async () => { - const browser = await webdriver(appPort, '/node-browser-polyfills') + it('should have polyfilled correctly', async () => { + const browser = await webdriver(next.url, '/') await browser.waitForCondition('window.didRender') diff --git a/test/integration/polyfill-node-modules/pages/node-browser-polyfills.js b/test/development/basic/node-browser-polyfills/pages/index.js similarity index 69% rename from test/integration/polyfill-node-modules/pages/node-browser-polyfills.js rename to test/development/basic/node-browser-polyfills/pages/index.js index 46fd712929db3..8f3c6e39be1f9 100644 --- a/test/integration/polyfill-node-modules/pages/node-browser-polyfills.js +++ b/test/development/basic/node-browser-polyfills/pages/index.js @@ -19,6 +19,7 @@ import timers from 'timers' import tty from 'tty' import util from 'util' import zlib from 'zlib' +import 'setimmediate' export default function NodeBrowserPolyfillPage() { const [state, setState] = useState({}) @@ -50,26 +51,28 @@ export default function NodeBrowserPolyfillPage() { assert.ok(!!util.inspect) assert.ok(!!zlib.Gzip) - setState({ - assert: true, - buffer: Buffer.from('hello world').toString('utf8'), - constants: constants.E2BIG, - hash: crypto.createHash('sha256').update('hello world').digest('hex'), - domain: true, - os: os.EOL, - path: path.join('/hello/world', 'test.txt'), - process: process.title, - querystring: querystring.stringify({ a: 'b' }), - stream: closedStream, - stringDecoder: true, - sys: true, - timers: true, - tty: true, - util: true, - http: true, - https: true, - vm: vm.runInNewContext('a + 5', { a: 100 }), - zlib: true, + setImmediate(() => { + setState({ + assert: true, + buffer: Buffer.from('hello world').toString('utf8'), + constants: constants.E2BIG, + hash: crypto.createHash('sha256').update('hello world').digest('hex'), + domain: true, + os: os.EOL, + path: path.join('/hello/world', 'test.txt'), + process: process.title, + querystring: querystring.stringify({ a: 'b' }), + stream: closedStream, + stringDecoder: true, + sys: true, + timers: true, + tty: true, + util: true, + http: true, + https: true, + vm: vm.runInNewContext('a + 5', { a: 100 }), + zlib: true, + }) }) }, []) diff --git a/test/integration/cli/test/index.test.js b/test/integration/cli/test/index.test.js index 3ed7724fe325c..e4ff3f49099c4 100644 --- a/test/integration/cli/test/index.test.js +++ b/test/integration/cli/test/index.test.js @@ -400,4 +400,47 @@ describe('CLI Usage', () => { expect(stderr).not.toContain('UnhandledPromiseRejectionWarning') }) }) + + describe('info', () => { + test('--help', async () => { + const help = await runNextCommand(['info', '--help'], { + stdout: true, + }) + expect(help.stdout).toMatch( + /Prints relevant details about the current system which can be used to report Next\.js bugs/ + ) + }) + + test('-h', async () => { + const help = await runNextCommand(['info', '-h'], { + stdout: true, + }) + expect(help.stdout).toMatch( + /Prints relevant details about the current system which can be used to report Next\.js bugs/ + ) + }) + + test('should print output', async () => { + const info = await runNextCommand(['info'], { + stdout: true, + }) + expect(info.stdout).toMatch( + new RegExp(` + Operating System: + Platform: .* + Arch: .* + Version: .* + Binaries: + Node: .* + npm: .* + Yarn: .* + pnpm: .* + Relevant packages: + next: .* + react: .* + react-dom: .* +`) + ) + }) + }) }) diff --git a/test/integration/font-optimization/fixtures/make-stylesheet-inert-regression/pages/_document.js b/test/integration/font-optimization/fixtures/make-stylesheet-inert-regression/pages/_document.js new file mode 100644 index 0000000000000..34851fcae15cb --- /dev/null +++ b/test/integration/font-optimization/fixtures/make-stylesheet-inert-regression/pages/_document.js @@ -0,0 +1,36 @@ +import Document, { Html, Head, Main, NextScript } from 'next/document' + +class MyDocument extends Document { + static async getInitialProps(ctx) { + const initialProps = await Document.getInitialProps(ctx) + return { ...initialProps } + } + + render() { + return ( + + + <> + {false && } + + + + + + +
+ + + + ) + } +} + +export default MyDocument diff --git a/test/integration/font-optimization/fixtures/make-stylesheet-inert-regression/pages/index.js b/test/integration/font-optimization/fixtures/make-stylesheet-inert-regression/pages/index.js new file mode 100644 index 0000000000000..136175234f558 --- /dev/null +++ b/test/integration/font-optimization/fixtures/make-stylesheet-inert-regression/pages/index.js @@ -0,0 +1,8 @@ +export default function Home() { + return ( +

+ Falsey values contained in an element contained in Head should not result + in an error! +

+ ) +} diff --git a/test/integration/font-optimization/test/index.test.js b/test/integration/font-optimization/test/index.test.js index a4d6f216f65a3..f4a4bdd18c6b4 100644 --- a/test/integration/font-optimization/test/index.test.js +++ b/test/integration/font-optimization/test/index.test.js @@ -328,4 +328,10 @@ describe('Font Optimization', () => { const { code } = await nextBuild(appDir) expect(code).toBe(0) }) + + test('makeStylesheetInert regression', async () => { + const appDir = join(fixturesDir, 'make-stylesheet-inert-regression') + const { code } = await nextBuild(appDir) + expect(code).toBe(0) + }) }) diff --git a/test/integration/polyfill-node-modules/next.config.js b/test/integration/polyfill-node-modules/next.config.js deleted file mode 100644 index cc17cf48c578f..0000000000000 --- a/test/integration/polyfill-node-modules/next.config.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - onDemandEntries: { - // Make sure entries are not getting disposed. - maxInactiveAge: 1000 * 60 * 60, - }, -} diff --git a/test/production/required-server-files.test.ts b/test/production/required-server-files.test.ts index 22459d8c1c343..61794732f0410 100644 --- a/test/production/required-server-files.test.ts +++ b/test/production/required-server-files.test.ts @@ -107,6 +107,22 @@ describe('should set-up next', () => { if (server) await killApp(server) }) + it('should output middleware correctly', async () => { + // the middleware-runtime is located in .next/static/chunks so ensure + // the folder is present + expect( + await fs.pathExists(join(next.testDir, 'standalone/.next/static/chunks')) + ).toBe(true) + expect( + await fs.pathExists( + join( + next.testDir, + 'standalone/.next/server/pages/middleware/_middleware.js' + ) + ) + ).toBe(true) + }) + it('should output required-server-files manifest correctly', async () => { expect(requiredFilesManifest.version).toBe(1) expect(Array.isArray(requiredFilesManifest.files)).toBe(true) diff --git a/test/production/required-server-files/pages/middleware/_middleware.js b/test/production/required-server-files/pages/middleware/_middleware.js new file mode 100644 index 0000000000000..c07ee4d1f4f82 --- /dev/null +++ b/test/production/required-server-files/pages/middleware/_middleware.js @@ -0,0 +1,3 @@ +export async function middleware(req) { + return new Response('hello from middleware') +} diff --git a/test/unit/jest-next-swc.test.ts b/test/unit/jest-next-swc.test.ts new file mode 100644 index 0000000000000..55e10a32998cd --- /dev/null +++ b/test/unit/jest-next-swc.test.ts @@ -0,0 +1,7 @@ +/* eslint-env jest */ + +describe('jest next-swc preset', () => { + it('should have correct env', async () => { + expect(process.env.NODE_ENV).toBe('test') + }) +}) diff --git a/yarn.lock b/yarn.lock index d991d307b0cb1..e81e097372622 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4694,9 +4694,10 @@ dependencies: "@types/node" "*" -"@types/node@*", "@types/node@>= 8": - version "13.1.4" - resolved "https://registry.yarnpkg.com/@types/node/-/node-13.1.4.tgz#4cfd90175a200ee9b02bd6b1cd19bc349741607e" +"@types/node@*", "@types/node@13.11.0", "@types/node@>= 8": + version "13.11.0" + resolved "https://registry.yarnpkg.com/@types/node/-/node-13.11.0.tgz#390ea202539c61c8fa6ba4428b57e05bc36dc47b" + integrity sha512-uM4mnmsIIPK/yeO+42F2RQhGUIs39K2RFmugcJANppXe6J1nvH87PvzPZYpza7Xhhs8Yn9yIAVdLZ84z61+0xQ== "@types/node@10.12.18": version "10.12.18" @@ -16277,14 +16278,14 @@ punycode@1.3.2: resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.3.2.tgz#9653a036fb7c1ee42342f2325cceefea3926c48d" integrity sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0= +punycode@2.1.1, punycode@^2.1.0, punycode@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" + punycode@^1.2.4: version "1.4.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" -punycode@^2.1.0, punycode@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" - pupa@^2.0.1: version "2.1.1" resolved "https://registry.yarnpkg.com/pupa/-/pupa-2.1.1.tgz#f5e8fd4afc2c5d97828faa523549ed8744a20d62" @@ -17565,7 +17566,7 @@ set-value@^2.0.0, set-value@^2.0.1: is-plain-object "^2.0.3" split-string "^3.0.1" -setimmediate@^1.0.4: +setimmediate@1.0.5, setimmediate@^1.0.4: version "1.0.5" resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" integrity sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU= @@ -19016,10 +19017,83 @@ tunnel-agent@^0.6.0: dependencies: safe-buffer "^5.0.1" -turbo@1.0.14: - version "1.0.14" - resolved "https://registry.yarnpkg.com/turbo/-/turbo-1.0.14.tgz#42ace0d1c699f0c1cb19b589b6d629dfa72b62b4" - integrity sha512-FfKP1rjx8LF/n8eibVOVlv7XzTszMHCg43RHCLFxGAEKluDCw3hyFAFNJumECktiGOt19M54h+HEGW/BDZeW2g== +turbo-darwin-64@1.0.24: + version "1.0.24" + resolved "https://registry.yarnpkg.com/turbo-darwin-64/-/turbo-darwin-64-1.0.24.tgz#f135baff0e44f9160c9b027e8c4dd2d5c8bb10a7" + integrity sha512-A65Wxp+jBMfI3QX2uObX6DKvk+TxNXTf7ufQTHvRSLeAreB8QiVzJdYE0nC6YdrRwfPgFY3L72dhYd2v8ouXDg== + +turbo-darwin-arm64@1.0.24: + version "1.0.24" + resolved "https://registry.yarnpkg.com/turbo-darwin-arm64/-/turbo-darwin-arm64-1.0.24.tgz#c360d7cc6a7403855733e3aebb841b1227fbbb2e" + integrity sha512-31zfexqUhvk/CIfAUk2mwjlpEjIURXu4QG8hoWlGxpcpAhlnkIX6CXle+LoQSnU3+4EbNe2SE92fYXsT/SnHAg== + +turbo-freebsd-64@1.0.24: + version "1.0.24" + resolved "https://registry.yarnpkg.com/turbo-freebsd-64/-/turbo-freebsd-64-1.0.24.tgz#9ef8914e7d1aaa995a8001a0ad81f7cc4520d332" + integrity sha512-vZYbDkOHH5eeQrxsAYldrh2nDY884irtmgJdGbpjryJgnJx+xzriZfoFalm/d1ZfG3ArENRJqGU+k6BriefZzw== + +turbo-freebsd-arm64@1.0.24: + version "1.0.24" + resolved "https://registry.yarnpkg.com/turbo-freebsd-arm64/-/turbo-freebsd-arm64-1.0.24.tgz#12644e8f1b077f9d7afb367f2b8c2a2e0592ca72" + integrity sha512-TDIu1PlyusY8AB69KGM4wGrCjtfbzmVF4Hlgf9mVeSWVKzqkRASorOEq1k8KvfZ+sBTS2GBMpqwpa1KVkYpVhw== + +turbo-linux-32@1.0.24: + version "1.0.24" + resolved "https://registry.yarnpkg.com/turbo-linux-32/-/turbo-linux-32-1.0.24.tgz#6129f7560f5c48214c1724ae7e8196dedc56de21" + integrity sha512-lhhK7914sUtuWYcDO8LV7NQkvTIwpAZlYH0XEOC/OTiYRQJvtKbEySLvefvtwuGjx7cGNI6OYraUsY3WWoK3FA== + +turbo-linux-64@1.0.24: + version "1.0.24" + resolved "https://registry.yarnpkg.com/turbo-linux-64/-/turbo-linux-64-1.0.24.tgz#221e3e14037e8fc3108e12a62de209d8a47f0348" + integrity sha512-EbfdrkwVsHDG7AIVQ1enWHoD6riAApx4VRAuFcQHTvJU9e+BuOQBMjb7e9jO4mUrpumtN3n20tP+86odRwsk5g== + +turbo-linux-arm64@1.0.24: + version "1.0.24" + resolved "https://registry.yarnpkg.com/turbo-linux-arm64/-/turbo-linux-arm64-1.0.24.tgz#95891e7d4375ccbf2478677568557948be33717a" + integrity sha512-H4rqlgP2L7G3iAB/un/7DclExzLUkQ1NoZ0p/1Oa7Wb8H1YUlc8GkwUmpIFd5AOFSPL75DjYvlS8T5Tm23i+1A== + +turbo-linux-arm@1.0.24: + version "1.0.24" + resolved "https://registry.yarnpkg.com/turbo-linux-arm/-/turbo-linux-arm-1.0.24.tgz#f5acb74170a8b5a787915e799e7b52840c7c6982" + integrity sha512-lCNDVEkwxcn0acyPFVJgV5N5vKAP4LfXb+8uW/JpGHVoPHSONKtzYQG05J1KbHXpIjUT+DNgFtshtsdZYOewZQ== + +turbo-linux-mips64le@1.0.24: + version "1.0.24" + resolved "https://registry.yarnpkg.com/turbo-linux-mips64le/-/turbo-linux-mips64le-1.0.24.tgz#f2cc99570222ac42fdcc0d0638f13bc0176859f9" + integrity sha512-AmrgQUDIe9AdNyh5YrI6pfMTUHD/gYfbylNmedLuN5Al3xINdZObcISzd/7VWd+V8wNW/1b9lUnt70Rv/KExfA== + +turbo-linux-ppc64le@1.0.24: + version "1.0.24" + resolved "https://registry.yarnpkg.com/turbo-linux-ppc64le/-/turbo-linux-ppc64le-1.0.24.tgz#4d9508290d24cfdbaca24e57d8bcd0127281e2ed" + integrity sha512-+6ESjsfrvRUr1AsurNcRTrqYr+XHG8g763+hXLog1MP9mn1cufZqWlAyE4G8/MLXDHsEKgK+tXqPLIyLBRjLEw== + +turbo-windows-32@1.0.24: + version "1.0.24" + resolved "https://registry.yarnpkg.com/turbo-windows-32/-/turbo-windows-32-1.0.24.tgz#2bf906c0cc9d675afc4693221fc339ade29e6c13" + integrity sha512-pqRys+FfHxuLVmW/AariITL5qpItp4WPAsYnWLx4u7VpCOO/qmTAI/SL7/jnTm4gxjBv3uf//lisu0AvEZd+TA== + +turbo-windows-64@1.0.24: + version "1.0.24" + resolved "https://registry.yarnpkg.com/turbo-windows-64/-/turbo-windows-64-1.0.24.tgz#5dd30b10110f2bb69caa479ddd72b4c471fb0dea" + integrity sha512-YHAWha5XkW0Ate1HtwhzFD32kZFXtC8KB4ReEvHc9GM2inQob1ZinvktS0xi5MC5Sxl9+bObOWmsxeZPOgNCFA== + +turbo@1.0.24: + version "1.0.24" + resolved "https://registry.yarnpkg.com/turbo/-/turbo-1.0.24.tgz#5efdeb44aab2f5e97b24a3e0ed4a159bfcd0a877" + integrity sha512-bfOr7iW48+chDl+yKiZ5FIWzXOF6xOIyrAGPaWI+I5CdD27IZCEGvqvTV/weaHvjLbV7otybHQ56XCybBlVjoA== + optionalDependencies: + turbo-darwin-64 "1.0.24" + turbo-darwin-arm64 "1.0.24" + turbo-freebsd-64 "1.0.24" + turbo-freebsd-arm64 "1.0.24" + turbo-linux-32 "1.0.24" + turbo-linux-64 "1.0.24" + turbo-linux-arm "1.0.24" + turbo-linux-arm64 "1.0.24" + turbo-linux-mips64le "1.0.24" + turbo-linux-ppc64le "1.0.24" + turbo-windows-32 "1.0.24" + turbo-windows-64 "1.0.24" tweetnacl@^0.14.3, tweetnacl@~0.14.0: version "0.14.5"