Commit graph

12278 commits

Author SHA1 Message Date
Damien Simonin Feugas
866de41681
docs: documents middleware matcher (#40180)
### 📖 What's in there?

Middleware matchers are powerful, but very few people realized it, because they are not really documented.
This PR tries to bring more clarity, and includes a more advanced example.

The example shows how to exclude several pages (no `/static`, no `/public`), but also allow specific page in excluded paths (`/public/disclaimer`)

### 🧪 How to test?

Run the example: `pnpm next dev examples/middleware-matcher`, then browse to http://localhost:3000
The first 3 links should not match, the last 3 ones should.

Don't forget to clear your localhost cookies if you change the middleware code.

### 🆙 Note to reviewers

Using session cookies to pass information from middleware to the rendered page is not great, because `document.cookie` is not available during SSR, and because cookies persist when refreshing the page (making it hard to try different matchers)

However, I couldn't find a simpler way to convey the information from the middleware to the page, and I meant to have something visual. The other option is to use response headers and curl commands, but...
2022-09-05 13:36:09 +00:00
Jiachi Liu
93830bf04f v12.2.6-canary.9 2022-09-05 14:38:11 +02:00
Avi Goldman
dcd4197c4c
Remove extra "d" in comment (#40212)
Super simple typo fix :)
2022-09-05 02:33:58 +00:00
hiro
17e84fed39
fix: scripts comment typos (#40207)
## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-09-05 02:26:54 +00:00
Donny/강동윤
6356095481
chore: Update swc (#39965)
This PR updates SWC crates to f2a0eef4f1

---


 - Closes #17056

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-09-04 12:13:22 +02:00
Jiachi Liu
03eb4b1d61
Bypass empty pages folder for layouts (#40132)
Check `pagesDir` to bypass empty pages folder when appDir is enabled

* Output empty loadable manifest for now if there's no `pagesDir`
* No custom aliases with all page extensions for `/_app`, `_document` if pagesDir is empty, only keep the built-in ones
* Check pagesDir in build/dev-server/eslint
* Type safe: change arguments of some APIs from optional to required, so that we won't mess up with default arguments
2022-09-03 00:13:47 +00:00
Sukka
f9706e0365
next/script: simplify logic and update tests (#40026)
The PR is the first step toward fixing #40025. The PR makes the `script-loader` integration test run on both dev and production modes.

Some existing test cases are skipped in dev mode because corresponding features are not strict mode resilient and thus will fail. They will be included in dev mode tests in the future.

The PR also merges some duplicated logic in `next/script`, and adds a detailed comment about how `onReady` works.

In the next PR, I will try to fix `onLoad` being called more than once under strict mode.

Co-authored-by: Houssein Djirdeh <houssein.djirdeh@gmail.com>
2022-09-02 15:25:44 -07:00
Yusuke Hayashi
885defd442
Fix typo in error/middleware-upgrade-guide.md (#40176)
No Reponse Body -> No Response Body

<img width="330" alt="スクリーンショット 2022-09-02 16 40 04" src="https://user-images.githubusercontent.com/11132792/188084749-a1dd4ca6-b108-47ef-85d9-5f1602cb8cea.png">
2022-09-02 18:20:22 +00:00
Hassan El Mghari
3647d7344d
Updating the Next.js Logo (#40181)
Updating the Next.js Logo, would love a quick merge
2022-09-02 12:49:45 -03:00
Visnu Pitiyanuvath
abcf991d11
Match data fetch and busting cache key when path URI encodes (#39568)
Fixes #38581
<!--
Thanks for opening a PR! Your contribution is much appreciated.
In order to make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below.
Choose the right checklist for the change that you're making:
-->

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-09-01 21:22:17 -07:00
Jiachi Liu
b9238ec973
Bump styled-jsx (#40165)
x-ref: https://github.com/vercel/styled-jsx/releases/tag/v5.0.5
2022-09-01 20:08:31 -07:00
Steven
8258c872c4
Bump @vercel/nft@0.22.1 (#40164)
Bump `@vercel/nft` to version [0.22.1](https://github.com/vercel/nft/releases/tag/0.22.1)

- Fixes #40130
2022-09-01 14:46:39 -07:00
Thomas Ballinger
b47f0a52e8
Update Convex example to convex 0.1.9 (#40162)
## Documentation / Examples

Update Convex to 0.1.9, now including specific deploy instructions for Vercel.

- [x] Make sure the linting passes by running `pnpm lint`
- [x] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-09-01 19:51:09 +00:00
Tommaso De Rossi
57fdff135d
ignore EEXIST errors when creating symlinks for output standalone (#40150)
I think the `EEXIST` error may be because next already copies some files here
e91cbcc03d/packages/next/build/index.ts (L2442)


partially fixes #36386 when using pnpm linker

## Bug

- [x] Related issues linked using 
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-09-01 18:20:08 +00:00
Balázs Orbán
2de7b43b78
fix: detect ESLint config in package.json (#40158)
Fixes #40133

Fixes a small regression introduced in #39872. We should be able to detect if a non-empty `package.json#eslintConfig` property is present.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-09-01 16:23:03 +00:00
Islam Shehata
9d30ef15e1
adding with-axiom example (#38300)
## Documentation / Examples

- [ X ] Make sure the linting passes by running `pnpm lint`
- [ X ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)


This PR adds an example for using next.js with axiom.

Co-authored-by: Balázs Orbán <info@balazsorban.com>
Co-authored-by: Steven Tey <stevensteel97@gmail.com>
2022-09-01 09:50:03 -05:00
JJ Kasper
008da124ed
v12.2.6-canary.8 2022-08-31 17:47:07 -07:00
Sukka
40767e5ce7
fix(#40066): preserve error status code from serveStatic (#40128)
The PR fixes #40066.

Next.js' `serveStatic` method is powered by the [send](https://github.com/pillarjs/send) module, which could throw errors under specific circumstances.
Currently, Next.js only preserves the 412 Error from send, hence issue #40066 (where 416 Error is not preserved).

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-08-31 23:08:56 +00:00
Steven
4cc7f11da2
Update to stable: next/future/image, remotePatterns, unoptimized (#40142)
This PR updates a few features from experimental to stable status:

- `next/future/image` component
- `remotePatterns` configuration
- `unoptimized` configuration
2022-08-31 22:44:17 +00:00
Will Binns-Smith
643447ed03
Allow port 0 in next dev and next start (#40118)
This addresses a bug where invoking `next dev` or `next start` with `--port 0` would fall back to the default port of 3000 instead of binding to port 0 (which typically results in the operating system assigning a free port).

I couldn't find a straightforward way of adding a test for next-start. It looks like we could add a similar test as for dev, but would need to generate a built project to serve. 

Manual test plan for `next start`:
```
$ ./packages/next/dist/bin/next start --port 0
ready - started server on 0.0.0.0:53508, url: http://localhost:53508
```

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)

Co-authored-by: Steven <steven@ceriously.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Wyatt Johnson <accounts+github@wyattjoh.ca>
2022-08-31 17:13:39 -05:00
Henrik Wenz
92aafcbcf1
[Docs] Add config types to all examples (#40083)
<!--
Thanks for opening a PR! Your contribution is much appreciated.
In order to make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below.
Choose the right checklist for the change that you're making:
-->

## Summary

- Added jsdoc typing for all examples using `next.config.js`
- Added jsdoc typing for all examples using `tailwind.config.js`

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
- [x] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-08-31 16:41:22 -05:00
Ken aka Frosty
e7e567b1fc
[docs] Functional syntax for _document example in Basic Features: Font Optimization (#40140)
## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [X] Make sure the linting passes by running `pnpm lint`
- [X] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-08-31 19:46:55 +00:00
Steven
abddee7413
Change alt to required in next/future/image (#40136)
This `alt` attribute is required by `<img>` according to the HTML spec, so we should also make it required for `next/future/image`. In the cases where it is not needed, it can be set to the empty string.

https://html.spec.whatwg.org/multipage/images.html#alt
2022-08-31 19:10:19 +00:00
Naoyuki Kanezawa
b522b94cce
feat(next): Support has match and locale option on middleware config (#39257)
## Feature

As the title, support `has` match, `local`  that works the same with the `rewrites` and `redirects` of next.config.js on middleware config. With this PR, you can write the config like the following:

```js
export const config = {
  matcher: [
    "/foo",
    { source: "/bar" },
    {
      source: "/baz",
      has: [
        {
          type: 'header',
          key: 'x-my-header',
          value: 'my-value',
        }
      ]
    },
    {
      source: "/en/asdf",
      locale: false,
     },
  ]
}
```

Also, fixes https://github.com/vercel/next.js/issues/39428

related https://github.com/vercel/edge-functions/issues/178, https://github.com/vercel/edge-functions/issues/179

- [x] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-08-31 11:23:30 -05:00
Jiachi Liu
481950c34b
Error for ssg and ssr exports from client components in build time (#40106)
Follow up for #39953

Detect invalid gSSP/gSP exports in page or layout client components in build time instead of checking them in runtime, in this way we can:
* Error to user eariler with traced file path, help user find the incorrect usage easier
* Make the flight client loader simpler, headless, aligned with react

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-08-31 13:13:47 +00:00
Kévin Dunglas
591f341d82
docs(security-headers): interest-cohort has been replaced by browsing-topics (#40113)
See https://github.com/mdn/browser-compat-data/issues/9814

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
- [x] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-08-31 02:01:25 +00:00
JJ Kasper
29582c8b1c
Fix edge rewrite handling (#40115)
Follow-up to https://github.com/vercel/next.js/pull/40076 this ensures we handle rendering correctly when the URL doesn't match the edge function exactly e.g. when rewriting since it looks like we don't currently have access to the `x-matched-path` header like we do for serverless functions. 

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

Fixes: https://github.com/vercel/next.js/runs/8102187444?check_suite_focus=true

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2022-08-30 18:30:49 -05:00
JJ Kasper
68fb39a034
Fix handling with custom _error and pages/500 (#40110)
This ensures we are properly calling `getInitialProps` in `_error` before serving `pages/500` as this has been the expected behavior since we introduced the process exiting behavior when deployed. This also ensures we don't attempt serving the `pages/500` before logging the error and exiting as this file isn't always expected to be present when statically optimized. 

Test deployments from provided reproduction can be seen here: 
- https://next-500-issue-ijdlh0e9y-ijjk-testing.vercel.app/
- https://next-500-issue-acn2vi68j-ijjk-testing.vercel.app/

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

Fixes: https://github.com/vercel/next.js/issues/40065
Fixes: https://github.com/vercel/next.js/issues/39952
2022-08-30 18:14:12 -05:00
JJ Kasper
dddc60df15
v12.2.6-canary.7 2022-08-30 12:57:31 -07:00
JJ Kasper
3bf8b2b4fe
Update to detect GSSP with edge runtime during build (#40076)
This updates to handle detecting `getStaticProps`/`getServerSideProps` correctly during build when `experimental-edge` is being used. This also fixes not parsing dynamic route params correctly with the edge runtime and sets up the handling needed for the static generation for app opened in the below mentioned PR.

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

Fixes: [slack thread](https://vercel.slack.com/archives/C0289CGVAR2/p1661554455121189)
x-ref: https://github.com/vercel/next.js/pull/39884
2022-08-30 18:18:02 +00:00
Wyatt Johnson
0b57a01ae6
Refactor Server Router (#39902)
<!--
Thanks for opening a PR! Your contribution is much appreciated.
In order to make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below.
Choose the right checklist for the change that you're making:
-->

This is intended to refactor the router code to reduce the overhead of executing routes. This is related to #32314 that may help reduce the memory overhead as this also replaced the `Set` with a `WeakMap`.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-08-30 12:56:44 -05:00
JJ Kasper
c89e25eba6
Update flakey tsconfig test (#40105)
Updates this test to not rely on `waitFor` as the amount of time it takes to write the `tsconfig.json` can vary so we should use `check` instead. 

Fixes: https://github.com/vercel/next.js/pull/39902#issuecomment-1231939162
2022-08-30 12:31:38 -05:00
Dueen Eduarda
b760c8dd0a
docs(image): Use hook inside of function component (#40096)
The example broke the [Rules of Hooks](https://reactjs.org/warnings/invalid-hook-call-warning.html#:~:text=Hooks%20can%20only%20be%20called%20inside%20the%20body%20of%20a%20function%20component.) by calling the hook outside of the function component.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-08-30 10:22:55 -05:00
Jesús Ferretti
1bf2ab6a66
docs(testing): add JSDoc typing in jest.config.js (#40090)
This PR improves the Testing documentation in [Setting up Jest (with the Rust Compiler)](https://nextjs.org/docs/testing#setting-up-jest-with-the-rust-compiler). It adds JSDoc typing in `jest.config.js`.

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
2022-08-30 14:38:29 +00:00
Shu Ding
5b3e20a11b
Fix filePath being wrongly stringified (#40070)
Currently when the resolved path is `undefined` it generates `filePath: 'undefined'` in the tree object, but should be `filePath: undefined` instead.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-08-30 04:34:10 +00:00
Steven
e735c51469
Remove <noscript> from next/future/image (#40075)
This PR removes `<noscript>` from `next/future/image` since it is no longer needed now that we use a svg blur placeholder (as opposed to css filter).

- Fixes  #38621 
- Closes #39736
2022-08-30 03:59:15 +00:00
Steven
c3ceeb03ab
Update next/future/image to use svg blur placeholder during next dev (#39992)
This PR updates the `next/future/image` component so that CSS `filter` is never needed. Previously, we used SVG to blur for prod and CSS to blur for dev, but now we use SVG for both.

This required a shared function `getImageBlurSvg()` used between both client and server because `next dev` doesn't create Data URIs and instead defers blur generation until request time. So we also need to defer svg generation to request time (on the server) during next dev.

This is the first step to removing `<noscript>` completely (see #39736).
2022-08-29 17:19:39 -05:00
YK
fdb629d01e
Update debugging.md (--dev -> --save-dev for npm) (#39998)
Reference:
https://docs.npmjs.com/specifying-dependencies-and-devdependencies-in-a-package-json-file#adding-dependencies-to-a-packagejson-file-from-the-command-line

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
- [x] The examples guidelines are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-08-29 12:42:46 -05:00
Titus Moore
b83c5eb85c
Refactored the with-supertokens example to use typescript (#39987)
<!--
Thanks for opening a PR! Your contribution is much appreciated.
In order to make sure your PR is handled as smoothly as possible we
request that you follow the checklist sections below.
Choose the right checklist for the change that you're making:
-->

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
- [x] The examples guidelines are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)

Convert example to use typescript.

Co-authored-by: Titus Moore <tmoore@edgewebware.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-08-29 12:40:26 -05:00
Wyatt Johnson
2e3402e6d9
Remove Unused SQLite file (#40056)
Removes the `packages/next/data.sqlite` file that was committed
alongside a test suite incorrectly.
2022-08-29 12:31:24 -05:00
Jiachi Liu
8668020a54
Upgrade typescript to 4.8.2 (#39979)
Typescript published 4.8.2 today and it fails CI, bump our typescript version to 4.8.2 and tweak some typings to make existing e2e typescript tests work properly

* Bump web-vitals from 3.0.0-beta to 3.0.0 stable for typing fix (there's an undefined type but it wasn't caught by ts 4.7), also force compiled it as CJS for pre-compiled
* Bump ncc to 3.34.0 for ts-loader compatibility for new typescript version, ncc 3.33.x cannot work with ts 4.8
* Update pre-compiled
2022-08-29 16:56:02 +00:00
JJ Kasper
decc00d0d2
v12.2.6-canary.6 2022-08-29 08:53:20 -07:00
Thomas Ballinger
5891dae6f7
Remove semi in Convex example (#40052)
Remove semicolon from Convex example.

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
- [x] The examples guidelines are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-08-29 10:42:00 -05:00
Jiachi Liu
b4f74ee1c1
Handle async module for client components (#39953)
### Problem

esm modules imports from client components will be compiled to `m = import('module-name')` when webpack bundles them for server components flight rendering. In this case, they will all become async modules since dyanmic imports will return a promise which react flight cannot handle it then results into module resolving error on server flight rendering.

### Solution

* React flight renderer supports handling async modules in https://github.com/facebook/react/pull/25138
* On next.js side leverage the module proxy change for each client reference, to make sure it always resolve the correct client module

The idea is wrapping each module with a module proxy, and if the module is async and accessed as thenable, it will return a new module reference with `async` label to tell react to handle it as async modules:

exported client reference `*` --> not async module (non thenable) --> original module reference `''`
exported client reference `*` --> it's async module (thenable) --> wrapped module reference `'*'` with `async` label

### Note

Since we need to check if user having incorrect gSSP/gSP specifying in layout client componet, so we still need to parse it and assign those info to the proxy (Does client module containing `ssr`, `ssg` exports). Otherwise the proxy will return the cached module reference
2022-08-29 14:47:06 +00:00
Yoann Moinet
1b61d1f5df
[docs] Add precision about pageExtensions (#40016)
Adding a precision because when you change the `pageExtensions` configuration in `next.config.js`, `middleware.ts` isn't recognized anymore.

Took me some time to debug this one, not sure if it should be considered a bug or just lack of documentation.
I'll let you be the judge of that.

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
- [x] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-08-28 21:34:59 +00:00
JJ Kasper
4f36064938
Update docker image for stats action (#40032)
Noticed the stats action was leveraging the wasm fallback incorrectly
which seems to be due to the necessary glibc version not being available
in the docker image we were leveraging so this updates the base docker
image used so the wasm fallback isn't needed and the dev binary is
correctly used again.

Fixes:
https://github.com/vercel/next.js/runs/8004433626?check_suite_focus=true
Fixes:
https://github.com/vercel/next.js/runs/7988021570?check_suite_focus=true
2022-08-28 13:43:29 -05:00
Sanjaiyan Parthipan
ca807d66f9
Update script.md (#40017)
Adding id property for inline script 

Co-authored-by: Sukka <isukkaw@gmail.com>
2022-08-28 13:42:11 -05:00
Shu Ding
d592d20673
Avoid bundling next/script in the server build by default (#40013)
We only use `if (child.type === Script)` on the server side to check the
element type, that's unnecessary because we can add a special flag for
that (`__nextScript` in this PR).

This reduces the server bundle by ~13kb if `next/script` is not imported
by the user.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-08-28 13:36:42 -05:00
YK
47dc97cc61
Add local setup info in the with-supabase-auth-realtime-db example's README (#40030)
Co-authored-by: Lee Robinson <9113740+leerob@users.noreply.github.com>
2022-08-28 17:25:00 +00:00
Sukka
e6862e4061
fix(#39993): avoid race condition for next/script onReady (#40002)
Fixes #39993.

Before the PR:

- `next/script` component mount, `useEffect` for `onReady` executes
- The script's cacheKey is not added to `LoadCache`, skip `onReady`
- The second `useEffect` for `loadScript` executes
- The script's cacheKey is added to `LoadCache` even if it might not fully load yet
- Because of React's strict mode, `useEffect` for `onReady` executes again
- Since the script's cacheKey is in `LoadCache`, `onReady` is called (even when the script is not loaded yet)
- After the script is actually loaded, inside the `script.onload` event handler the `onReady` is called again

After the PR:

- `next/script` component mount, `useEffect` for `onReady` executes
- The script's cacheKey is not added to `LoadCache`, `useEffect` skips `onReady`
- The second `useEffect` for `loadScript` executes
- The script's cacheKey is added to `LoadCache` only if it is an inline script
- Because of React's strict mode, `useEffect` for `onReady` executes again
- The script is not yet loaded, its cacheKey is not in `LoadCache`, `useEffect` skips `onReady` again
- After the script is actually loaded, inside the `script.onload` event handler the `onReady` is finally called

In short, the PR resolves a race condition that only occurs under React strict mode (and makes the `next/script` component more concurrent rendering resilient).

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-08-28 08:47:55 +00:00