Skip to content

Commit

Permalink
Merge branch 'canary' into eslint-plugin-glob-paths
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmckeb authored Aug 11, 2021
2 parents c675a67 + e61ea6f commit 5602546
Show file tree
Hide file tree
Showing 36 changed files with 878 additions and 426 deletions.
126 changes: 27 additions & 99 deletions .github/workflows/build_native.yml
Original file line number Diff line number Diff line change
@@ -1,154 +1,82 @@
on:
workflow_dispatch:
pull_request:
types: [opened, synchronize]
paths:
- 'packages/next/build/swc/**'
on: workflow_dispatch

name: Build next-swc native binaries

jobs:
build:
build-native:
strategy:
matrix:
os: [ubuntu-18.04, macos-latest, windows-latest]

name: stable - ${{ matrix.os }} - node@14
description: [default]
include:
- os: ubuntu-18.04
target: x86_64-unknown-linux-gnu
- os: windows-latest
target: x86_64-pc-windows-msvc
- os: macos-latest
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
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:
toolchain: stable
profile: minimal

toolchain: nightly-2021-03-25
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 NPM dependencies
uses: actions/cache@v1
- name: Cache native binary
id: binary-cache
uses: actions/cache@v2
with:
path: node_modules
key: npm-cache-${{ matrix.os }}-node@14-${{ hashFiles('yarn.lock') }}

- name: 'Install dependencies'
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000

path: packages/next/native/**
key: next-swc-nightly-2021-03-25-${{ matrix.target }}-${{ hashFiles('packages/next/build/swc/**') }}
- name: 'Build'
run: yarn --cwd packages/next build-native
if: steps.binary-cache.outputs.cache-hit != true
run: yarn build-native --target ${{ matrix.target }}
env:
MACOSX_DEPLOYMENT_TARGET: '10.13'

- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: next-swc-binaries
path: packages/next/native

- name: Clear the cargo caches
run: |
cargo install cargo-cache --no-default-features --features ci-autoclean
cargo-cache
build-apple-silicon:
name: stable - aarch64-apple-darwin - node@14
runs-on: macos-latest

steps:
- uses: actions/checkout@v2

- name: Setup node
uses: actions/setup-node@v2
with:
node-version: 14

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
override: true
toolchain: nightly-2021-03-25
target: aarch64-apple-darwin

- name: Install dependencies
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000

- name: Cross build aarch64
run: yarn --cwd packages/next build-native --target aarch64-apple-darwin

working-directory: packages/next
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: next-swc-binaries
path: packages/next/native

path: packages/next/native/next-swc.*.node
- name: Clear the cargo caches
run: |
cargo install cargo-cache --no-default-features --features ci-autoclean
cargo-cache
commit:
needs: [build, build-apple-silicon]
needs: build-native
runs-on: ubuntu-18.04

steps:
- uses: actions/checkout@v2
if: ${{ github.event_name == 'workflow_dispatch' }}
- uses: actions/download-artifact@v2
with:
name: next-swc-binaries
path: packages/next/native
if: ${{ github.event_name == 'workflow_dispatch' }}
- uses: EndBug/add-and-commit@v7
with:
add: 'packages/next/native --force'
message: 'Build next-swc binaries'
if: ${{ github.event_name == 'workflow_dispatch' }}

check:
needs: [build, build-apple-silicon]
runs-on: ubuntu-18.04

steps:
- uses: actions/checkout@v2
if: ${{ github.event_name == 'pull_request' }}
- uses: actions/download-artifact@v2
with:
name: next-swc-binaries
path: packages/next/native
if: ${{ github.event_name == 'pull_request' }}
- run: git diff --exit-code
if: ${{ github.event_name == 'pull_request' }}

test:
runs-on: ubuntu-18.04

steps:
- uses: actions/checkout@v2
if: ${{ github.event_name == 'pull_request' }}
- name: Install
if: ${{ github.event_name == 'pull_request' }}
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2021-03-25
profile: minimal
- run: cd packages/next/build/swc && cargo test
if: ${{ github.event_name == 'pull_request' }}
96 changes: 92 additions & 4 deletions .github/workflows/build_test_deploy.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
on:
push:
branches: [canary]
tags: [v*]
pull_request:
types: [opened, synchronize]

Expand Down Expand Up @@ -40,12 +41,13 @@ jobs:
with:
path: ./*
key: ${{ github.sha }}
- run: ./scripts/check-manifests.js
- run: yarn lint

checkPrecompiled:
name: Check Pre-compiled
runs-on: ubuntu-latest
needs: build
needs: [build, build-native]
env:
NEXT_TELEMETRY_DISABLED: 1
steps:
Expand All @@ -55,6 +57,10 @@ jobs:
with:
path: ./*
key: ${{ github.sha }}
- uses: actions/download-artifact@v2
with:
name: next-swc-binaries
path: packages/next/native
- run: ./scripts/check-pre-compiled.sh
if: ${{needs.build.outputs.docsChange != 'docs only change'}}

Expand Down Expand Up @@ -239,9 +245,10 @@ jobs:
if: ${{needs.build.outputs.docsChange != 'docs only change'}}

publishRelease:
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
name: Potentially publish release
runs-on: ubuntu-latest
needs: build
needs: [build, build-native]
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
steps:
Expand All @@ -250,10 +257,14 @@ jobs:
with:
path: ./*
key: ${{ github.sha }}

- uses: actions/download-artifact@v2
with:
name: next-swc-binaries
path: packages/next/native
- run: ./scripts/prepublish-native.js
- run: ./scripts/publish-release.sh

prStats:
releaseStats:
name: Release Stats
runs-on: ubuntu-latest
needs: [publishRelease]
Expand All @@ -267,3 +278,80 @@ jobs:
- uses: ./.github/actions/next-stats-action
env:
PR_STATS_COMMENT_TOKEN: ${{ secrets.PR_STATS_COMMENT_TOKEN }}

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
- os: windows-latest
target: x86_64-pc-windows-msvc
- os: macos-latest
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
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-03-25
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-03-25-${{ matrix.target }}-${{ hashFiles('packages/next/build/swc/**') }}
- 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
with:
name: next-swc-binaries
path: packages/next/native/next-swc.*.node
- name: Clear the cargo caches
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
- name: Install
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2021-03-25
profile: minimal
- run: cd packages/next/build/swc && cargo test
2 changes: 1 addition & 1 deletion docs/basic-features/data-fetching.md
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ When a page with `getStaticProps` is pre-rendered at build time, in addition to
This JSON file will be used in client-side routing through `next/link` ([documentation](/docs/api-reference/next/link.md)) or `next/router` ([documentation](/docs/api-reference/next/router.md)). When you navigate to a page that’s pre-rendered using `getStaticProps`, Next.js fetches this JSON file (pre-computed at build time) and uses it as the props for the page component. This means that client-side page transitions will **not** call `getStaticProps` as only the exported JSON is used.
When using Incremental Static Generation `getStaticProps` will be executed out of band to generate the JSON needed for client-side navigation. You may see this in the form of multiple requests being made for the same page, however, this is intended and has no impact on end-user performance
When using Incremental Static Generation `getStaticProps` will be executed out of band to generate the JSON needed for client-side navigation. You may see this in the form of multiple requests being made for the same page, however, this is intended and has no impact on end-user performance.
#### Only allowed in a page
Expand Down
8 changes: 8 additions & 0 deletions errors/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,14 @@
{
"title": "sharp-missing-in-production",
"path": "/errors/sharp-missing-in-production.md"
},
{
"title": "max-custom-routes-reached",
"path": "/errors/max-custom-routes-reached.md"
},
{
"title": "module-not-found",
"path": "/errors/module-not-found.md"
}
]
}
Expand Down
16 changes: 16 additions & 0 deletions packages/next/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,22 @@ export default async function build(
return returnValue
})

if (isNextImageImported) {
try {
if (process.env.NEXT_SHARP_PATH) {
require(process.env.NEXT_SHARP_PATH)
} else {
require.resolve('sharp', {
paths: [path.join(dir, 'node_modules')],
})
}
} catch (e) {
Log.warn(
'Detected `next/image` usage without `sharp`. https://nextjs.org/docs/messages/sharp-missing-in-production'
)
}
}

if (customAppGetInitialProps) {
console.warn(
chalk.bold.yellow(`Warning: `) +
Expand Down
3 changes: 3 additions & 0 deletions packages/next/build/swc/npm/next-swc-darwin-arm64/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `next-swc-darwin-arm64`

This is the **aarch64-apple-darwin** binary for `next-swc`
18 changes: 18 additions & 0 deletions packages/next/build/swc/npm/next-swc-darwin-arm64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "next-swc-darwin-arm64",
"version": "0.0.0",
"os": [
"darwin"
],
"cpu": [
"arm64"
],
"main": "next-swc.darwin-arm64.node",
"files": [
"next-swc.darwin-arm64.node"
],
"license": "MIT",
"engines": {
"node": ">= 10"
}
}
3 changes: 3 additions & 0 deletions packages/next/build/swc/npm/next-swc-darwin-x64/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `next-swc-darwin-x64`

This is the **x86_64-apple-darwin** binary for `next-swc`
Loading

0 comments on commit 5602546

Please sign in to comment.