Skip to content

Commit

Permalink
Merge branch 'canary' into shu/0e73
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] committed May 13, 2022
2 parents ee5db41 + 9e568da commit a7a3f98
Show file tree
Hide file tree
Showing 105 changed files with 1,289 additions and 857 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/build_test_deploy.yml
Expand Up @@ -873,6 +873,7 @@ jobs:
- build
- build-wasm
- build-native
- build-native-freebsd
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN_ELEVATED }}
steps:
Expand Down Expand Up @@ -1303,6 +1304,66 @@ jobs:
name: next-swc-binaries
path: packages/next-swc/native/next-swc.*.node

build-native-freebsd:
if: ${{ needs.build.outputs.isRelease == 'true' }}
needs: build
name: stable - x86_64-unknown-freebsd - node@16
runs-on: macos-10.15
steps:
- name: tune mac network
run: sudo sysctl -w net.link.generic.system.hwcksum_tx=0 && sudo sysctl -w net.link.generic.system.hwcksum_rx=0
- uses: actions/checkout@v3
- name: Delete useless files
run: |
rm -rf bench
rm -rf docs
rm -rf errors
rm -rf examples
rm -rf scripts
rm -rf test
- name: Build
id: build
uses: vmactions/freebsd-vm@v0.1.6
env:
DEBUG: napi:*
RUSTUP_HOME: /usr/local/rustup
CARGO_HOME: /usr/local/cargo
RUSTUP_IO_THREADS: 1
# Disable LTO, or the lld may crash with OOM
CARGO_PROFILE_RELEASE_LTO: false
with:
envs: DEBUG RUSTUP_HOME CARGO_HOME RUSTUP_IO_THREADS CARGO_PROFILE_RELEASE_LTO NAPI_CLI_VERSION TURBO_VERSION RUST_TOOLCHAIN
usesh: true
mem: 6000
prepare: |
pkg install -y curl node14
curl -qL https://www.npmjs.com/install.sh | sh
npm install -g yarn
curl https://sh.rustup.rs -sSf --output rustup.sh
sh rustup.sh -y --profile minimal --default-toolchain stable
export PATH="/usr/local/cargo/bin:$PATH"
echo "~~~~ rustc --version ~~~~"
rustc --version
echo "~~~~ node -v ~~~~"
node -v
run: |
export PATH="/usr/local/cargo/bin:$PATH"
pwd
ls -lah
whoami
env
freebsd-version
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}"
yarn --cwd packages/next-swc build-native --release --target x86_64-unknown-freebsd
rm -rf node_modules
rm -rf packages/next-swc/target
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: next-swc-binaries
path: packages/next-swc/native/next-swc.*.node
if-no-files-found: error

build-wasm:
needs: build
if: ${{ needs.build.outputs.isRelease == 'true' }}
Expand Down
129 changes: 129 additions & 0 deletions docs/advanced-features/ci-build-caching.md
@@ -0,0 +1,129 @@
---
description: Learn how to configure CI to cache Next.js builds
---

# Continuous Integration (CI) Build Caching

To improve build performance, Next.js saves a cache to `.next/cache` that is shared between builds.

To take advantage of this cache in Continuous Integration (CI) environments, your CI workflow will need to be configured to correctly persist the cache between builds.

> If your CI is not configured to persist `.next/cache` between builds, you may see a [No Cache Detected](https://nextjs.org/docs/messages/no-cache) error.
Here are some example cache configurations for common CI providers:

## Vercel

Next.js caching is automatically configured for you. There's no action required on your part.

## CircleCI

Edit your `save_cache` step in `.circleci/config.yml` to include `.next/cache`:

```yaml
steps:
- save_cache:
key: dependency-cache-{{ checksum "yarn.lock" }}
paths:
- ./node_modules
- ./.next/cache
```

If you do not have a `save_cache` key, please follow CircleCI's [documentation on setting up build caching](https://circleci.com/docs/2.0/caching/).

## Travis CI

Add or merge the following into your `.travis.yml`:

```yaml
cache:
directories:
- $HOME/.cache/yarn
- node_modules
- .next/cache
```

## GitLab CI

Add or merge the following into your `.gitlab-ci.yml`:

```yaml
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
- .next/cache/
```

## Netlify CI

Use [Netlify Plugins](https://www.netlify.com/products/build/plugins/) with [`@netlify/plugin-nextjs`](https://www.npmjs.com/package/@netlify/plugin-nextjs).

## AWS CodeBuild

Add (or merge in) the following to your `buildspec.yml`:

```yaml
cache:
paths:
- 'node_modules/**/*' # Cache `node_modules` for faster `yarn` or `npm i`
- '.next/cache/**/*' # Cache Next.js for faster application rebuilds
```

## GitHub Actions

Using GitHub's [actions/cache](https://github.com/actions/cache), add the following step in your workflow file:

```yaml
uses: actions/cache@v2
with:
# See here for caching with `yarn` https://github.com/actions/cache/blob/main/examples.md#node---yarn or you can leverage caching with actions/setup-node https://github.com/actions/setup-node
path: |
~/.npm
${{ github.workspace }}/.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
```

## Bitbucket Pipelines

Add or merge the following into your `bitbucket-pipelines.yml` at the top level (same level as `pipelines`):

```yaml
definitions:
caches:
nextcache: .next/cache
```

Then reference it in the `caches` section of your pipeline's `step`:

```yaml
- step:
name: your_step_name
caches:
- node
- nextcache
```

## Heroku

Using Heroku's [custom cache](https://devcenter.heroku.com/articles/nodejs-support#custom-caching), add a `cacheDirectories` array in your top-level package.json:

```javascript
"cacheDirectories": [".next/cache"]
```

## Azure Pipelines

Using Azure Pipelines' [Cache task](https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/cache), add the following task to your pipeline yaml file somewhere prior to the task that executes `next build`:

```yaml
- task: Cache@2
displayName: 'Cache .next/cache'
inputs:
key: next | $(Agent.OS) | yarn.lock
path: '$(System.DefaultWorkingDirectory)/.next/cache'
```
2 changes: 2 additions & 0 deletions docs/advanced-features/react-18/switchable-runtime.md
Expand Up @@ -2,6 +2,8 @@

By default, Next.js uses Node.js as the runtime for page rendering, including pre-rendering and server-side rendering.

> Note: `runtime` option only effects pages but not middleware
If you have [React 18](/docs/advanced-features/react-18/overview) installed, there is a new experimental feature that lets you switch the page runtime between Node.js and the [Edge Runtime](/docs/api-reference/edge-runtime). Changing the runtime affects [SSR streaming](/docs/advanced-features/react-18/streaming) and [Server Components](/docs/advanced-features/react-18/server-components) features, as well.

## Global Runtime Option
Expand Down
4 changes: 3 additions & 1 deletion docs/advanced-features/source-maps.md
Expand Up @@ -4,7 +4,9 @@ description: Enables browser source map generation during the production build.

# Source Maps

Source Maps are enabled by default during development. During production builds, they are disabled as generating source maps can significantly increase build times and memory usage while being generated.
Source Maps are enabled by default during development. During production builds, they are disabled to prevent you leaking your source on the client, unless you specifically opt in with the configuration flag.

## Configuration flag

Next.js provides a configuration flag you can use to enable browser source map generation during the production build:

Expand Down
13 changes: 11 additions & 2 deletions docs/api-reference/next.config.js/custom-webpack-config.md
Expand Up @@ -4,6 +4,8 @@ description: Extend the default webpack config added by Next.js.

# Custom Webpack Config

> Note: changes to webpack config are not covered by semver so proceed at your own risk
Before continuing to add custom webpack configuration to your application make sure Next.js doesn't already support your use-case:

- [CSS imports](/docs/basic-features/built-in-css-support.md#adding-a-global-stylesheet)
Expand All @@ -22,7 +24,10 @@ In order to extend our usage of `webpack`, you can define a function that extend

```js
module.exports = {
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
webpack: (
config,
{ buildId, dev, isServer, defaultLoaders, nextRuntime, webpack }
) => {
// Important: return the modified config
return config
},
Expand All @@ -36,7 +41,7 @@ The second argument to the `webpack` function is an object with the following pr
- `buildId`: `String` - The build id, used as a unique identifier between builds
- `dev`: `Boolean` - Indicates if the compilation will be done in development
- `isServer`: `Boolean` - It's `true` for server-side compilation, and `false` for client-side compilation
- `nextRuntime`: `String` - The target runtime for server-side compilation; either `"edge"` or `"nodejs"`
- `nextRuntime`: `String | undefined` - The target runtime for server-side compilation; either `"edge"` or `"nodejs"`, it's `undefined` for client-side compilation.
- `defaultLoaders`: `Object` - Default loaders used internally by Next.js:
- `babel`: `Object` - Default `babel-loader` configuration

Expand Down Expand Up @@ -64,6 +69,10 @@ module.exports = {
}
```

#### `nextRuntime`

Notice that `isServer` is `true` when `nextRuntime` is `"edge"` or `"nodejs"`, nextRuntime "`edge`" is currently for middleware and server components in edge runtime only.

## Related

<div class="card">
Expand Down
5 changes: 2 additions & 3 deletions docs/api-routes/api-middlewares.md
Expand Up @@ -165,9 +165,8 @@ export const setCookie = (
const stringValue =
typeof value === 'object' ? 'j:' + JSON.stringify(value) : String(value)

if ('maxAge' in options) {
options.expires = new Date(Date.now() + options.maxAge)
options.maxAge /= 1000
if (typeof options.maxAge === 'number') {
options.expires = new Date(Date.now() + options.maxAge * 1000)
}

res.setHeader('Set-Cookie', serialize(name, stringValue, options))
Expand Down
4 changes: 2 additions & 2 deletions docs/basic-features/built-in-css-support.md
Expand Up @@ -189,10 +189,10 @@ For example, using the exported `primaryColor` Sass variable:

```scss
/* variables.module.scss */
$primary-color: #64FF00
$primary-color: #64ff00;

:export {
primaryColor: $primary-color
primaryColor: $primary-color;
}
```

Expand Down
4 changes: 4 additions & 0 deletions docs/manifest.json
Expand Up @@ -258,6 +258,10 @@
"title": "`src` Directory",
"path": "/docs/advanced-features/src-directory.md"
},
{
"title": "CI Build Caching",
"path": "/docs/advanced-features/ci-build-caching.md"
},
{
"title": "Multi Zones",
"path": "/docs/advanced-features/multi-zones.md"
Expand Down

0 comments on commit a7a3f98

Please sign in to comment.