Commit graph

5220 commits

Author SHA1 Message Date
LongYinan
98d7ee3a06
Add libc fields to Linux platform packages (#35354)
Related: https://github.com/yarnpkg/berry/pull/3981

With `yarn 3.2` +, developers will install one less package on the Linux platform
2022-03-16 09:19:42 -04:00
Shu Ding
91136d231e
Update comments for the web server (#35366)
The web server is used as minimal mode, whereas public file handling, envs and compression are both handled by the upper layer (edge runtime if deployed serverlessly, or node server if self-hosted).

## 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 `yarn lint`
2022-03-16 12:32:30 +00:00
Shu Ding
853442dfc3
Make concurrent features independent from the global runtime option (#35245)
This PR depends on #35242 and #35243. It allows the global runtime to be unset, as well as enables static optimization for Fizz and RSC pages in the Node.js runtime. Currently for the Edge runtime pages are still always SSR'd.

Closes #31317.

## Bug

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

## Feature

- [x] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [x] 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`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`


Co-authored-by: Jiachi Liu <4800338+huozhi@users.noreply.github.com>
2022-03-16 12:11:57 +00:00
Jiachi Liu
99aea513bf
enhance: cover re-exported gsp cases for runtime fallback (#35326)
Cover re-exported gsp cases from #35011
2022-03-15 13:14:18 +00:00
LongYinan
2e16d02faa
SWC emotion transform plugin (#34687) 2022-03-15 08:51:15 +01:00
Steven
6611bfd31c v12.1.1-canary.11 2022-03-14 10:26:50 -04:00
Alex Castle
76bad07bdf
Add new 'raw' image layout (#34339)
This PR adds a new layout mode for images called `raw`, as discussed with the core team a while back. This mode has the following characteristics:
 - No wrapper `span` around the `img` element
 - No sizer svg
 - Almost no styles automatically added to the `img` element
 - `style` parameter is allowed and is passed through to the underlying `img` element

This also adds documentation changes to describe the new component.

There are a few tradeoffs and DX decisions that may warrant discussion/revision before merging. I'll add a few comments to highlight those issues.

- Related to #18637
2022-03-14 10:25:23 -04:00
Jiachi Liu
edce68b40c
Bump styled-jsx to 5.0.1 (#35290)
x-ref: https://github.com/vercel/next-react-server-components/issues/35
x-ref: https://github.com/vercel/styled-jsx/pull/788

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have helpful link attached, see `contributing.md`
2022-03-13 20:31:53 +00:00
Houssein Djirdeh
79016b879f
Adds web worker support to <Script /> using Partytown (#34244)
## Summary

This PR adds a new `worker` strategy to the `<Script />` component that automatically relocates and executes the script in a web worker.

```jsx
<Script 
  strategy="worker"
  ...
/>
```

[Partytown](https://partytown.builder.io/) is used under the hood to provide this functionality.

## Behavior

- This will land as an experimental feature and will only work behind an opt-in flag in `next.config.js`:

  ```js
  experimental: {
    nextScriptWorkers: true
  }
  ```

- This setup use a similar approach to how ESLint and Typescript is used in Next.js by showing an error to the user to install the dependency locally themselves if they've enabled the experimental `nextScriptWorkers` flag.

  <img width="1068" alt="Screen Shot 2022-03-03 at 2 33 13 PM" src="https://user-images.githubusercontent.com/12476932/156639227-42af5353-a2a6-4126-936e-269112809651.png">
- For Partytown to work, a number of static files must be served directly from the site (see [docs](https://partytown.builder.io/copy-library-files)). In this PR, these files are automatically copied to a `~partytown` directory in `.next/static` during `next build` and `next dev` if the `nextScriptWorkers` flag is set to true.

## Checklist

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

This PR fixes #31517.
2022-03-11 22:26:46 +00:00
Shu Ding
3b9864d4f4
Remove the special _document-concurrent component (#35242)
This PR removes the `` const documentPage = `_document${globalRuntime ? '-concurrent' : ''}` `` condition from the config resolution phrase, and only use the built-in one. And later when rendering, we can conditionally convert the default class component into a function component. This change is necessary for the switchable runtime feature (#31506).

## 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 `yarn lint`
2022-03-11 20:38:09 +00:00
C. T. Lin
bc0816f936
fix(Script): allow passing defer=false to Script component (#34850)
## Bug

```jsx
<Script
  async
  defer={false}
  strategy='beforeInteractive'
  src='https://securepubads.g.doubleclick.net/tag/js/gpt.js'
/>
```

output:

```html
<script src="https://securepubads.g.doubleclick.net/tag/js/gpt.js" async="" defer="" data-nscript="beforeInteractive"></script>
```

The `defer` prop is overridden by `!disableOptimizedLoading`, so can't disable it on the particular script.
2022-03-11 16:53:09 +00:00
Balázs Orbán
91455653fe
chore: upgrade cssnano-simple (#35258)
Fixes #35219

## 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 `yarn lint`
2022-03-11 16:25:18 +00:00
JJ Kasper
d7deb852bd
v12.1.1-canary.10 2022-03-11 08:53:10 -06:00
Shu Ding
2b13c2f7fa
Ensure that pages manifest contains pages of both runtimes (#35243)
Previously we only run `PagesManifestPlugin` in the Node server runtime, because the Edge target doesn't need it as the web server and middleware SSR loader specially handled pages manifest. This cases entrypoints with the Edge runtime configured being missing from there and this PR fixes it.

Part of #31317 and #31506.

## Bug

- [ ] 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 `yarn lint`
2022-03-11 13:33:40 +00:00
Donny/강동윤
e57d621fb3
feat(next-swc): Update crates (#35133)
This PR updates crates related to ecmascript to d62ef6498d

I'll update css crates separately.


This PR also reduces the size of binary.
2022-03-11 04:58:01 +00:00
Jiachi Liu
088354d4f7
Render resolved streaming content for static render result (#35221)
* Fix the static streaming render result isn't the resolved streaming rendering content (resolve suspense)
* Update readable stream polyfill to fit the w3c standard
2022-03-10 21:34:40 +00:00
Steven
ceb7bfb29d v12.1.1-canary.9 2022-03-10 08:22:40 -08:00
Huzaifa Arif
ea87415fd9
[Fix] Adds try/catch to gracefully handle performance observer exception (#35202)
* fix: add try/catch to gracefull handle performance observer exception on older browsers

* fix: run prettier

Co-authored-by: Steven <steven@ceriously.com>
2022-03-10 11:06:50 -05:00
Steven
0355e5f63f
Fix next/image when src is webp but browser doesnt support it (#35190)
* Fix `next/image` when src is webp but browser doesnt support it

* Exclude old sharp since it doesnt support AVIF
2022-03-10 15:02:13 +01:00
Eric Ponto
84720697e4
Convert server.js to module.exports (#35181)
If different contexts (using Jest, using Nx, etc), server.js is getting imported when using middleware and throwing the error: "SyntaxError: Unexpected token 'export'".

fixes #32848



## Bug

- [x] 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 `yarn lint`


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-03-09 22:50:07 +00:00
Jiachi Liu
9bff48b9d5
Adopt react 18 rc2 (#35161)
* Adopt react 18 rc2

* execute shouldUseReactRoot only once

* update test

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-03-09 21:12:36 +01:00
Jiachi Liu
81276e213d
Disable the functions manifest plugin (#35155)
Disable the plugin introduced in #33770, will rewrite when manifest consuimg part becomes stable
2022-03-09 15:22:54 +00:00
Jiachi Liu
21994ce591 v12.1.1-canary.8 2022-03-09 14:06:29 +01:00
JJ Kasper
acbd54322f
Ensure mjs files are transformed with jest (#34698)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-03-09 13:49:58 +01:00
Jiachi Liu
6646ffad75
Change to loadBindings for swc parse (#35171)
CI test `TEST_WASM=true xvfb-run node run-tests.js test/integration/production/test/index.test.js` is aways failing in recent PRs

`loadBindingsSync` does not import `next-swc/wasm` unlike `loadBindings`

x-ref: https://github.com/vercel/next.js/runs/5479076388?check_suite_focus=true
x-ref: https://github.com/vercel/next.js/runs/5471650765?check_suite_focus=true
2022-03-09 12:21:01 +00:00
Jiachi Liu
55c063eaac
Delay prefix flushing (#35170)
Only happened with SSR without suspense case

Similar reason to #34474, the prefix (script parts) might be flushed during the render stream causing bad HTML. Use the same tricky to delay the prefix flushing

#### Expected
```html
<div>content</div> <!-- render stream --> 
<script>...</script> <!-- prefix --> 
```


#### Observed
```html
<!-- prefix choked the render stream --> 
<div <script>...</script> >content</div>
```


Test sample:
https://next-react-server-components-r5xocii9r-huozhi.vercel.app/ssr
2022-03-09 11:06:37 +00:00
Shu Ding
201f98e81a
Per-page runtime (#35011)
Partially implements #31317 and #31506. There're also some trade-offs made with this PR: since we can't know if a certain runtime will be used or not beforehand, we have to start both runtime compilers (Node.js and Edge) and then generate entrypoints correspondingly.

Note that with this PR, the global runtime is still required to use the per-page runtime.

## Bug

- [ ] 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 `yarn lint`
2022-03-08 20:55:14 +00:00
Naoyuki Kanezawa
9e4724dea2
fix: hard-navigate when preflight request fails (#35145)
fixes https://github.com/vercel/next.js/issues/34199

Also fixes response code to return `500` when showing error page of preflight request failure on dev mode

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-03-08 19:51:08 +00:00
Naoyuki Kanezawa
eb878459de
fix post request hangs when no body is consumed on middleware (#35131)
fixes https://github.com/vercel/next.js/issues/34966

Wait for reading original request body before overwriting the request properties with `originalBody?.finalize()` call since it caused the problem when middleware does not read request body

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-03-08 19:24:58 +00:00
Naoyuki Kanezawa
d141376772
[next] Fix to not call middleware with shallow push, fix middleware call wit… (#35047)
…h query parameter

Fixes https://github.com/vercel/next.js/issues/32655 and fixes https://github.com/vercel/next.js/issues/35006

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-03-08 19:03:14 +00:00
OJ Kwon
8d0561ebf8
feat(trace): postprocess trace reporter for datadog (#35032)
* feat(trace): include clocktime for span

* build(package): bump up devdependencies

* feat(trace): postprocess trace reporter for datadog

* build(package): update precompile pkgs

* update compiled

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-03-08 08:15:09 -08:00
Tobias Koppers
292636d249
watch node_modules (#35140)
next.js doesn't HMR when installing node_modules.

This fixes it.

## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-03-08 14:12:50 +00:00
Jiachi Liu
c130fd67be v12.1.1-canary.7 2022-03-07 22:47:55 +01:00
Steven
b25f7f84b1
Fix animated png bypass from Image Optimization API (#35120)
- Fixes #34807
- Related commit 69dad3cdf9

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-03-07 20:29:11 +00:00
Artur Kornakov
0e5e8881c0
Normalize root path according to trailingSlash option in default next/image loader #21337 (#22453)
* fix(next/image): normalize root path according to trailingSlash option in defaul loader

* test(image-optimizer): trailingSlash support

* chore(next/image): prettier

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-03-07 18:55:39 +01:00
Gerald Monaco
a666591555
Split up & tweak next/client initialization (#33838)
For streaming, we want the main bundle to be loaded with `async` rather than `defer`. As the first step to doing that, we need an explicit initialization step, rather than occurring as a side effect of being loaded.

For now, I've just split the logic into a `initialization` and `hydrate` (previously `initNext`) functions and called them as a side effect of `next/client/next` and `next/client/next-dev` as before. A follow-up PR will move that to a separate script tag [as recommended](https://github.com/reactwg/react-18/discussions/114).
2022-03-07 17:09:55 +00:00
Jiachi Liu
ff6b75027b
Enable import assertion syntax parsing (#33750)
## Feature

Enable import assertion syntax parsing for ecmascript/typescript. Since webpack has already supported it, enable import assertion parsing and leave them to webpack to handle

#### Upgration
* tooling: `@swc/core`, `@swc/cli`, prettier to support importAssertion related flags
* typescript related: `typescript` >= 4.5
* babel related: `@babel/plugin-syntax-import-assertions`
* lint parser: `@typescript-eslint/parser`


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-03-06 20:41:22 +00:00
Jiachi Liu
7083dcfe44
Generate static html for bots (#35004)
* Generate static html for bots

* fix lint

* refactor error handling against comment

* fix streaming on edge for bots

* inline doResolve
2022-03-03 23:39:26 -08:00
Balázs Orbán
62c33c1eb7
feat: support pnpm with create-next-app (#34947)
* feat: support `pnpm` with `create-next-app`

* test: add `--use-pnpm` tests

* docs: mention `--use-pnpm` flag in docs

* test: remove `only`

* Update test/integration/create-next-app/index.test.ts

Co-authored-by: Steven <steven@ceriously.com>

* chore: add pnpm action setup to tests

* chore: use latest pnpm

* chore: debug

* chore: debug

* fix: fall back to `yarn` instead of `npm`

* test: run all tests

Co-authored-by: Steven <steven@ceriously.com>
2022-03-04 00:49:24 +01:00
io
2c7f8b3d7b
Support colons in Middleware NextResponse.rewrite path (#32543)
* Add failing colon rewrite test

* add test fixture

* better colon rewrite tests

* middleware rewrite colon tests with query parameters

* fix #31523

this addresses the symptom but the real systemic issue is that prepareDestination is called on rewrite/redirect URLs, which have no defined special behavior for colons and they should not be compiled at all

* hack around prepareDestination to skip compiling x-middleware-rewrite

this is a bit nicer than just escaping colons, but ideally we find a way to obviate prepareDestination

* obviate prepareDestination for x-middleware-rewrite handling

* don't clobber rewrite query data

* omit redundant type

* catch up to main

* It looks like newUrl should contain only pathname

Co-authored-by: Naoyuki Kanezawa <naoyuki.kanezawa@gmail.com>
2022-03-03 11:36:53 -08:00
Balázs Orbán
728d82663c
feat: allow dotenv default expansion (#34765)
We currently use `dotenv-expand@5` in `@next/env`, which does not support default expansion. It was added in v6 (https://github.com/motdotla/dotenv-expand/pull/39).

Upgrading to the latest version of `dotenv-expand` and fixing an import, the added test passed.

Fixes #34718

## 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 `yarn lint`
2022-03-03 16:52:20 +00:00
JJ Kasper
81c50f4a87
Handle de-duping revalidations in minimal mode (#34935)
* Handle de-duping revalidations in minimal mode

* fix type

* remove header check

* update other tests

* update test
2022-03-02 15:06:54 -08:00
JJ Kasper
e51d2627d0
Update to re-use cache while revalidate is erroring (#34931) 2022-03-02 14:09:40 -08:00
Steven
937ab16b78
Fix typescript 4.6.2 randomUUID() (#34976)
This PR fixes the latest version of `typescript` (4.6.2) that was failing with the following:

```
Type error: Overload signatures must all be optional or required.
  207 |       array: T
  208 |     ): T
> 209 |     randomUUID?(): string
      |     ^
  210 |   }
  211 | }
```

https://github.com/vercel/next.js/runs/5376232868?check_suite_focus=true#step:8:106

- Related to https://github.com/PeculiarVentures/webcrypto/issues/44

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-03-02 21:51:15 +00:00
Jiachi Liu
e3d0d645af
Adopt react 18 rc1 (#34972)
### Changes

* Remove top-level suspense boundary
* Pipe stream resolved from returned promimse of `renderToReadableStream`
* Remove jsx-runtime alias hack

### Test Changes

Since top level suspense boundary is removed, now content are filled in 1st SSR
2022-03-02 21:21:18 +00:00
Shu Ding
1f1632979c
Fix named export missing from client components (#34974)
Closes #33538.

## 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 `yarn lint`
2022-03-02 20:57:50 +00:00
JJ Kasper
1b17070a29
v12.1.1-canary.6 2022-03-02 12:12:15 -08:00
Steven
65e704daa4
Fix next/image noscript when blur and priority (#34973)
Fixes a bug where browsers with scripts disabled did not work with `<Image placeholder="blur" priority />`.

- Introduced in #32918
2022-03-02 19:59:02 +00:00
Shu Ding
a518036246
Refactor export marks of server components (#34945)
* refactor rsc export marks

* fix failed test
2022-03-02 19:29:54 +01:00
Jiachi Liu
d9d494adaf
Provide page runtime parsing utils (#34922)
* parse runtime config

* add test

* fix typing

* fix lint warning

* change branch purging condition

* dont fallback to global runtime
2022-03-02 09:41:41 -08:00