Commit graph

5053 commits

Author SHA1 Message Date
Steven
228640eedd v12.0.11-canary.10 2022-02-09 09:17:49 -05:00
Gerald Monaco
3e6035937a
Fix: Use react-dom/server.browser when reactRoot: true (#34116)
Since we want to use the streaming renderer when `reactRoot: true`, we have to make sure we use the right server implementation too.
2022-02-09 03:48:52 +00:00
Jiachi Liu
0f5d9dce72
Fix included flight manifest on node runtime (#34113)
We need to switch to json flight manifest on node deployment for RSC
2022-02-09 01:26:50 +00:00
JuniorTour
e2d6c311b5
fix: next/image usage from node_modules (#33559)
fix: image config not work for `node_modules`

Co-authored-by: Steven <steven@ceriously.com>
2022-02-08 19:55:53 -05:00
JJ Kasper
130f8645a2
Update to leverage response-cache for image-optimizer (#34075)
This updates to leverage our `response-cache` used for ISR for our `image-optimizer` as well. 

Co-authored-by: Steven <steven@ceriously.com>
2022-02-08 18:46:59 -05:00
Jiachi Liu
c735de8550 v12.0.11-canary.9 2022-02-08 22:46:00 +01:00
Shu Ding
eb3cba388c
Polyfill pipeTo and pipeThrough (#34112)
* polyfill pipeTo

* add pipeThrough

* covert pipeThrough calls

* use pipe

* invert logic

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-02-08 22:40:25 +01:00
Shu Ding
b5d757e046
Fix static result being piped (#34111)
We need to check if the render result is dynamic or not, before using `pipe`.
2022-02-08 21:03:38 +00:00
Gerald Monaco
df29561ae3
Use renderToStream with React 18 (#34106)
As per React 18 recommendation, we should use e.g. `renderToReadableStream` whenever we use `createRoot`. This is particularly important for currently supported suspense features like `React.lazy` to work properly during SSR.

However, unless you have opted in to streaming support (via [the `runtime` flag](https://github.com/vercel/next.js/pull/34068)), we will wait until `onCompleteAll` before sending it (via the `generateStaticHTML` flag).

---

Fixes #33879
2022-02-08 19:39:27 +00:00
Jiachi Liu
fb80055a1f
fix: arrow function export in rsc client component (#34105)
The `export default xxx` statement is slightly different from estree when exporting an arrow function instead of identifier in swc.
We also need to capture arrow exports.
2022-02-08 19:09:47 +00:00
Syed Basim
708f75180a
add pnpm debug file in gitignore templates (#34091)
Add pnpm debug (`.pnpm-debug.log`) file in gitignore templates.
2022-02-08 18:02:39 +00:00
Tim Neutkens
66062722f1
Remove experimental warning from next/jest (#34096)
## 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-02-08 16:52:05 +00:00
Tobias Koppers
451dfa14f1
remove unneeded and broken plugin (#34087)
fixes #25484
fixes #34064

## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-02-08 15:20:00 +00:00
Tim Neutkens
40329a70a5
Add check for resolveWeak to next/dynamic (#33908)
Fixes #33476

I've added the test for this but it passes either way, even when the change to loadable.js is not made. On the reproduction I was able to reproduce it consistently and it's fixed with this change. 



## 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-02-08 14:02:53 +00:00
Shu Ding
6944074506
Deprecate concurrentFeatures with runtime (#34068) 2022-02-08 14:16:46 +01:00
Donny/강동윤
f1ff0fb626
feat(next-swc): Update swc (#34045)
This applies 

 - https://github.com/swc-project/swc/pull/3462

This resolves https://github.com/vercel/next.js/discussions/30237#discussioncomment-2114870


 - https://github.com/swc-project/swc/pull/3463

This resolves https://github.com/vercel/next.js/discussions/30237#discussioncomment-2109335

 - https://github.com/swc-project/swc/pull/3480

This resolves https://github.com/vercel/next.js/discussions/30237#discussioncomment-2068850
2022-02-08 11:48:25 +00:00
JJ Kasper
d416cd85b5
v12.0.11-canary.8 2022-02-07 22:00:39 -06:00
JJ Kasper
7cd9de34da
Add api-utils helper for testing (#34078) 2022-02-07 21:50:23 -06:00
Gerald Monaco
c0dc008f28
Stop exposing internal render and renderError methods from next/client (#34069)
These should no longer need to be exposed.
2022-02-07 20:16:13 +00:00
Gerald Monaco
81b537c04e
Make Router state immutable (#33925)
Make the external `Router` state immutable, and make it so there's only one place (`set`) where it is changed and announced. This is to prepare for #33919, which ensures that we only create a new router once per tree.
2022-02-07 17:52:41 +00:00
Tim Neutkens
3be21c4f6f
Change SWC minify from beta to release candidate (#34056)
Given we've spent a ton of time testing and fixing minifier bugs the majority of cases should now be covered.



## 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-02-07 16:54:37 +00:00
11koukou
d4b29db8c7
Fix lazyRoot functionality for next/image (#33933)
Fixed lazyRoot functionality (#33290). Changed the unique id for Intersection Observers discrimination since previously they were only identified by the different rootMargins, now each being identified by the rootMargin and the root element as well
Added more Images to the test with different margins and with/without lazyRoot prop. Browser correctly initially loading two of the four Images according to the props' specifications.

Co-authored-by: Steven <steven@ceriously.com>
2022-02-07 10:46:16 -05:00
Tim Neutkens
c74e4f21ff
Add support for async fn / promise in next.config.js/.mjs (#33662)
- Add support for async function / promise export in next.config.js/.mjs
- Update docs

Adds support for https://twitter.com/timneutkens/status/1486075973204422665

But also the simpler version:

```js
module.exports = async () => {
  return {
    basePath: '/docs'
  }
}
```



## 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
- [x] Documentation added

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
2022-02-07 08:48:35 +00:00
JJ Kasper
938eb0e28c
v12.0.11-canary.7 2022-02-06 19:10:52 -06:00
Wouter Raateland
b49717f8db
Allow scroll prevention on hash change (#31921)
* Allow scroll prevention on hash change

Currently, `scrollToHash` is performed on every hash change, even when this change is caused by `<Link scroll={false} {...props} />`.
This change prevents scrolling in this case and allows users to specify the desired scrolling behavior in the router's `hashChangeComplete` event.

* Add test case and apply fixes

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-02-06 18:38:55 -06:00
Adam Pietrasiak
41706d6fd3
Require component rendered as child of Link to pass event to onClick handler (#27723)
Currently, if you render `next/link` like

```ts
<Link>
  <CustomComponent />
</Link>
```

and have 

```tsx
interface Props {
  onClick?: () => void; // <— note we're not passing event as an argument
}

function CustomComponent({ onClick }: Props) {
  return <div onClick={() => onClick?.()}>Hello</div>
}
```

It'll result in error

```
link.js?f421:21 Uncaught TypeError: Cannot read property 'defaultPrevented' of undefined
```

<!--
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

- [ ] 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


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-02-07 00:04:37 +00:00
Neeraj Rajpurohit
6d0bd20ffa
Fixes #31240: Adding a recursive addPackagePath function in webpack-config (#31264)
Fixes: https://github.com/vercel/next.js/issues/31240
Closes: https://github.com/vercel/next.js/pull/32324
Adding a try-catch block to handle situations when packages are found at relative path in getPackagePath function. This is likely to occur when using `preact` instead of `react-dom`, as `scheduler` package will not be found wrt `react-dom`

## Bug

- [x] Related issues linked using `fixes #31240`

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-02-06 22:38:42 +00:00
Chris Midgley
7b19722133
Allow passing nothing as custom jest config. (#32328)
If you don't have any config, currently you need to pass `{}`, which is
less convenient than being able to pass nothing.
2022-02-06 15:19:16 -06:00
Balázs Orbán
5b47639747
fix(cna): add default version (#33006) 2022-02-06 15:03:35 -06:00
Klaas Landsman
b39e49eca9
Fix detection of anchor click events inside svg (#23272)
## Bug

The `nodeName` of an anchor inside an SVG equals the lowercase `a` instead of the html anchor's uppercase `A`.
This behavior can be seen in this plain js demo: https://jsfiddle.net/L2p8f4ve/28/

fixes #23252




## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added

## 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.

## Documentation / Examples

- [ ] Make sure the linting passes

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-02-06 20:53:03 +00:00
Yubin
6090101581
Place 'charset' element at the top of <head> (#28119) 2022-02-06 13:51:51 -06:00
Alexander Akait
65e951e412
fix: data url handling in css-loader (#34034) 2022-02-06 11:10:14 -06:00
Sanna Jammeh
e0c7794208
Add decoratorMetadata flag if enabled by tsconfig (#32914)
fixes #32913
Adds support for decorator metadata in SWC when enabled through ts/jsconfig.

## 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: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-02-06 16:48:09 +00:00
Mohsen Azimi
0fd2f3ba98
Add types to nextConfig in default template (#34029)
Enable editors to suggest properties for the config object. Also let TypeScript check for type errors in the configuration when using TypeScript

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-02-06 15:13:38 +00:00
Phillip Klawansky
0468a56604
Update font-stylesheet-gathering-plugin.ts (#30709)
* Update font-stylesheet-gathering-plugin.ts

For production build, getting an UnhandledPromiseRejectionWarning: Unhandled promise rejection on line 29. Added rejection handling callback to allow for builds.

This breaks deployments to Vercel.

* ensure font css minimizing errors are caught/logged

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-02-05 21:46:47 -06:00
Mohsen Azimi
7286bed4cf
Add JSDoc to config options (#32915)
* Add JSDoc to config options

* Add JSDoc for all non-experimental configurations

* Update packages/next/server/config-shared.ts

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

* Add JSDoc for all non-experimental configurations

* Apply suggestions from code review

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

* updates

* bump

Co-authored-by: Steven <steven@ceriously.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-02-05 19:49:52 -06:00
Jiachi Liu
c8fd6d89eb
Detect per page runtime config for functions manifest (#33945)
## Feature

Follow up for #33770

* When page config specify runtime is "nodejs", remove runtime option in functions manifest;
* If user enable `concurrentFeatures` and filesystem api, use `runtime: "web"` for those pages;


- [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
2022-02-06 01:28:42 +00:00
Hannes Bornö
8aa3620a16
Babel & next-swc: Fix exporting page config with AsExpression (#32702)
fixes #20626

No changes needed in next-swc, see comments from @kdy1 below.

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-02-05 21:15:49 +00:00
Kara
d7de7deb70
Do not warn when application/ld+json scripts are used with next/head (#34021)
In #33968, a warning was added for script tags inserted through the
next/head component. This change unintentionally included
application/ld+json scripts, which shouldn't be triggering the
warnings (as they were originally intended to catch scripts where
loading order or timing could be important). This change adds an
exception for application/ld+json scripts, so they do not log the
warning if they are included through next/head.
2022-02-05 14:45:02 -06:00
Thibaut SABOT
2ea2c81f52
Don't use yarn if a package-lock.json file is found (#31926)
Fixes https://github.com/vercel/next.js/issues/31755
2022-02-05 20:16:25 +00:00
Gerald Monaco
1aeb230839
Fix suffix ordering while streaming (#34011)
* Fix suffix ordering

* Don't start reading until after resolving

* More yak shaving
2022-02-05 13:17:29 -06:00
Gerald Monaco
7e0b8aa4d1
Use ReadableStream in RenderResult (#34005)
Since we're always using `ReadableStream`, we should just get rid of `ResultPiper`.

This also lets us replace things like `bufferedReadFromReadableStream` with a `TransformStream` that does the same thing, so that it's `TransformStream`s all the way down.

Finally, we can get rid of the one-off call to `renderToReadableStream` and just use `renderToStream` whenever we're rendering a concurrent tree.
2022-02-05 01:13:02 +00:00
JJ Kasper
f322d62639
v12.0.11-canary.6 2022-02-04 17:02:00 -06:00
Kara
24fe279751
Warn in dev mode when stylesheets are added using next/head (#34004)
This commit adds a development mode warning in the console
if you try to include <link rel="stylesheet"> tags in
next/head, e.g.

```
<Head>
  <link ref="stylesheet" href="..." />
</Head>
```

The warning message explains that this pattern will not
work well with Suspense/streaming and recommends using a
custom Document component instead.

## Feature

- [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
- [x] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [x] Errors have helpful link attached, see `contributing.md`


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-02-04 22:48:30 +00:00
Daniel Lindenkreuz
f275fcff7a
Update Terser to v5.10.0, fix minification issues (#33045)
Bumping Terser from v5.7.1 to v5.10.0 fixes some minification issues:
- I specifically encountered this bug, where a boolean condition was flipped when a nullish coalescing operator was involved: https://github.com/terser/terser/pull/1045
- See [Terser's changelog](https://github.com/terser/terser/blob/master/CHANGELOG.md) for more fixes

## 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 `yarn lint`
2022-02-04 21:33:10 +00:00
JJ Kasper
103d3ab4fc
Ensure external middleware rewrite is handled correctly (#33962) 2022-02-04 13:32:30 -06:00
Gerald Monaco
0b1d5e17bc
Use react-dom/server.browser in Node.js (#33950)
Instead of branching rendering based on Node.js and browser/web runtimes, we should just use the web version for now, which can run as-is on versions >=16.5.0 of Node.js, polyfilling `ReadableStream` on older versions when necessary.

There are a few potential downsides to this, as React is less able to optimize flushing and execution. We can revisit that in the future though if desired.
2022-02-04 17:52:53 +00:00
JJ Kasper
502a869a68
v12.0.11-canary.5 2022-02-04 11:15:32 -06:00
JJ Kasper
a65e3612d0
Ensure optional chaining in swc matches babel (#33995)
This ensures we always transpile optional chaining and nullish coalescing with swc the same as we do [with babel](4812e22992/packages/next/build/babel/preset.ts (L97-L98)) since it can cause issues with webpack even when the node target supports these features. 

The specific case this seems to cause issues with webpack is when a value is imported and optional chaining is used on the import value webpack is stripping the optional chaining cc @sokra 

## 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/33915
2022-02-04 17:08:01 +00:00
Kara
61ea8efe42
Warn in dev mode when script tags are added with next/head (#33968)
This commit adds a development mode warning in the console
if you try to include <script> tags in next/head, e.g.

```
<Head>
  <script async src="..." />
</Head>
```

The warning message explains that this pattern will not
work well with Suspense/streaming and recommends using the
next/script component instead.

TODO in follow-up PR: add same warning for stylesheets, etc

## Feature

- [x] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [x] Integration tests added
- [x] Documentation added
- [x] Errors have helpful link attached, see `contributing.md`
2022-02-04 13:06:55 +00:00