Commit graph

5344 commits

Author SHA1 Message Date
JJ Kasper
74dead2489
Add experimental onlyGenereated flag for unstable_revalidate (#36108)
* Add experimental ifGenereated flag for unstable_revalidate

* Apply suggestions from code review

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

* update ifGenerated -> onlyGenerated

* rename const as well

Co-authored-by: Steven <steven@ceriously.com>
2022-04-13 11:56:58 -05:00
Naoyuki Kanezawa
1d8165bd79
fix: do not add locale prefix to api route on NextURL (#36118)
Fixes https://github.com/vercel/next.js/issues/35694

## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-04-13 15:30:03 +00:00
Donny/강동윤
4bf01d4ec8
feat(next-swc): Update css parser (#36114)
This only applies 81370d16cb

This fixes parsing of legacy `calc`s.
2022-04-13 09:09:52 +00:00
Shu Ding
19b625e0c5
Fix export from and native modules in server component (#36072)
This PR fixes a bunch of bugs and it now supports:
- Importing a client component from a nested server component (a.server → b.server → c.client).
- The `export from` syntax in server component (`export { default } from './a.server'`)
- Native modules in server components (currently broken)

## Buga

- [ ] 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-04-13 08:50:36 +00:00
Jiachi Liu
20600ad29f
rsc: remove router injection (#36101) 2022-04-13 10:16:29 +02:00
JJ Kasper
38d17bca0c
v12.1.5 2022-04-12 14:40:16 -05:00
JJ Kasper
9c613aaa66
v12.1.5-canary.7 2022-04-12 13:35:53 -05:00
Kiko Beats
46d3f0e216
fix(next-url): print properly using logger symbol (#36097)
Hello,

This PR adds a method to have a custom inspect for `NextURL`

closes #35519
2022-04-12 15:31:29 +00:00
LongYinan
da6f271d9b
Interpolate module.exports as default import (#36082)
fixes https://github.com/vercel/next.js/issues/34412

## 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`
2022-04-12 14:32:42 +00:00
JJ Kasper
a9d6d9f71a
v12.1.5-canary.6 2022-04-11 16:27:07 -05:00
JJ Kasper
95a8f31d86
Fix outputStandalone with optimizeCss (#36028) 2022-04-11 16:14:28 -05:00
Ethan Arrowood
8c5797959c
update @vercel/nft to 0.18.1 (#36075)
* update @vercel/nft to 0.18.1

* update-compiled

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-04-11 15:45:40 -05:00
JJ Kasper
da39e29c27
v12.1.5-canary.5 2022-04-11 12:00:35 -05:00
Naoyuki Kanezawa
93678b569b
Do not add locale to link for api route and middleware preflight (#35994)
Fixes https://github.com/vercel/next.js/issues/33578

This PR fixes `Link` component as well to not add locale for api routes since both preflight redirect and link should work the same.

Additionally, it fixes the webdriver method `browser.waitForCondition()` for playwright to not wrap with function string.

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-04-11 15:59:07 +00:00
LongYinan
aaa823c3fa
Interpolate default exports is now unnecessary (#36065)
## 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-04-11 15:36:25 +00:00
Donny/강동윤
16f7084e7f
feat(next-swc): Update swc crates (#35996)
* Move

* Adjust

* publish = false

* Tree

* Move tests

* fixup

* Split `emotion`

* Split `styled_jsx`

* Split `styled_jsx`

* fmt

* `--fix`

* clippy

* Update crates

* fixup

* publish

* Bump

* Rename

* authors

* Update

* More update

* Oh

* Update test refs

* Update test refs

* Update again

* Fix
2022-04-11 11:59:16 +02:00
LongYinan
01109734ce
Interpolate default exports (#35933)
* Add failing test for next/link next/image with "type": "module"

* Interpolate default exports

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2022-04-11 16:43:44 +08:00
Shu Ding
1ed38dd2d0
Support export all syntax in client components (#36027)
This PR adds the support of the `export * from './foo'` syntax in client components.

## 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-04-09 01:26:16 +00:00
Steven
0a04ab7478
Fix leaking internal config to user-defined loader prop in next/image (#36013)
The `config` was changed from a global variable to a function parameter of the `loader()` function in PR https://github.com/vercel/next.js/pull/33559 as an implementation detail, not as a public API. It was not meant to be used by the end user which is why it was [undocumented](https://nextjs.org/docs/api-reference/next/image#loader).

This config is meant for the default Image Optimization API. Since the `loader` prop bypasses the default Image Optimization API in favor of a custom function, that config is no longer be relevant because the function can implement the optimization url however it desires.

- Fixes #35115
2022-04-08 22:19:25 +00:00
Tobias Koppers
f4fbb83d4a
allow to provide postcss plugin options as a string (#35173)
fixes https://github.com/vercel/next.js/issues/35117

@balazsorban44 this needs a test case

## Bug

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


Co-authored-by: Balázs Orbán <18369201+balazsorban44@users.noreply.github.com>
2022-04-08 16:58:50 +00:00
Jiachi Liu
eddf1715ee
Use renderToString for flush effects (#35999)
Use render to string call to render flush effects instead of rendering with stream plus converting to string
2022-04-08 14:22:25 +00:00
Shu Ding
d8623bb90f
Use eager import to include client modules (#35979)
Eager import does almost the same thing as `require()` but it instead also supports loading an ES module.

## 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-04-08 10:53:02 +00:00
Jiachi Liu
630bf80a22
Support shared component with next built-in client components (#35975)
Fixes #35449

Include the shared components (from source code) is in client bundles, previously we lost them so that the client components imported by them are lost in module graph

* let flight server loader apply to all pages and imported modules (except node_modules at the moment)
* if it's a shared component from source code, include it in client bundle
* ignore handling node_modules at the moment (due to the limitation support of esm imports with RSC)

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have helpful link attached, see `contributing.md`
2022-04-07 19:45:33 +00:00
Shu Ding
51d7153ea8
Add test case for module resolution in node_modules from different contexts (#35978)
The same module should be created as 2 instances if it's imported from different contexts (server or client).

## 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-04-07 19:16:02 +00:00
JJ Kasper
345f5cc351
v12.1.5-canary.4 2022-04-07 11:41:10 -05:00
JJ Kasper
26aacb04fb
Ensure minimalMode previousCache expire time is capped (#35954) 2022-04-07 11:32:45 -05:00
Tobias Koppers
0164ac60f2
update webpack (#35867)
https://github.com/webpack/webpack/releases/tag/v5.70.0
https://github.com/webpack/webpack/releases/tag/v5.71.0
https://github.com/webpack/webpack/releases/tag/v5.72.0
2022-04-07 16:00:26 +00:00
Jake Jarvis
f308826603
Add .eslintrc.cjs to list of supported next lint config files (#35440)
The logic for finding a user's custom `.eslintrc` config file is missing a check for `.eslintrc.cjs`, which is listed as one of the valid filenames in ESLint's docs:

https://eslint.org/docs/user-guide/configuring/configuration-files#configuration-file-formats

...so this PR makes `next lint`'s list of possible config files consistent with ESLint's.

I stumbled upon this when trying to rename my own config file, since I've pretty much moved completely to ESM by now... but [ESLint doesn't support modules yet](https://github.com/eslint/eslint/issues/14137#issuecomment-785421664), so renaming the file to `.cjs` just keeps things cleaner (and VS Code happier). This is my first PR here so even though I've only changed a couple of lines, please let me know if I'm overlooking something! 😊

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-04-07 15:03:40 +00:00
Shu Ding
049bb22c1c
Update polyfill of web streams (#35571)
* attach pipeTo and pipeThrough polyfills to instance

* remove transformer polyfill

* remove polyfill

* fix missing polyfill in sandbox

* always polyfill the runtime

* always polyfill web streams in renderer

* fix missing AbortController and AbortSignal

* type fix

* fix type generation

* use global

Co-authored-by: Shu Ding <shu@shus-mac-studio.localdomain>
2022-04-07 16:26:30 +02:00
John Daly
9110b5a4f1
Emotion SWC Plugin - Allow for jsxImportSource to be configurable (#35963)
* Allowing the jsxImportSource to be configurable when using the Emotion SWC plugin

* Adding test case

* Addressing PR feedback

* Moving getEmotionOptions call back to where it was previously

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-04-07 14:33:38 +02:00
Naoyuki Kanezawa
633050402f
fix: add locale prefix to middleware preflight url (#35911)
Fixes part of https://github.com/vercel/next.js/issues/34274

Navigating to `/` causes to redirect preflight request to a url of browser language like `/en`. 
This PR fixes to add the locale prefix always so that the redirect does not happen anymore and middleware can get a correct locale.

## 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-04-07 11:39:49 +00:00
JJ Kasper
211ce73c87
v12.1.5-canary.3 2022-04-06 13:34:56 -05:00
Shu Ding
d0bf3ee64c
Code refactoring (#35937)
Clean up some code in the renderer and make it more readable.

## 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-04-06 15:45:06 +00:00
Samuel
cb565d69cf
Update: Add appropriate error message when for getServerSideProps invalid return value (#35887) 2022-04-06 10:25:27 -05:00
Naoyuki Kanezawa
9805399faa
Revert "fix the dynamic routing of middleware" (#35932)
Reverts vercel/next.js#32601
2022-04-06 14:35:52 +00:00
Shu Ding
d3af135f99
Fix data encoder and decoder to use stream in renderer (#35936)
There are several places where the decoder should have `stream: true`. Also changed the `encodeText(extraChunk + decodeText(chunk))` pattern to just emit two chunks.

## 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-04-06 13:34:24 +00:00
JJ Kasper
e146168c3b
v12.1.5-canary.2 2022-04-05 18:34:29 -05:00
Steven
cec388cde2
Fix Firefox flash of white on next/image with placeholder=blur (#35889)
## History

In PR #24153, `placeholder=blur` was added and it set `element.style.backgroundImage = 'none'` instead of using react state to re-render. Then in PR  #25916, a delay was added to handle removing the blur placeholder. Then in PR #25994, `img.decode()` was utilized but we found this caused problems in Firefox in #26011.

## Today

This PR changes the the blur placeholder removal to use react state to re-render. This _should_ prevent Firefox from erroring although we should probably keep the catch() just in case. This was pointed out when React 18 caused subtle differences in Firefox in this comment https://github.com/vercel/next.js/issues/30128#issuecomment-1086754374
2022-04-05 22:47:55 +00:00
JJ Kasper
4a7ab34baf
Update repo to use react 18 by default (#35888)
This updates our `yarn next` command to leverage react v18 by default and removes the need for the test require hook/config modifying when testing react 18. There are some fixtures we need to investigate react 18 support in follow-ups:

- `test/integration/client-navigation-a11y`
- `test/integration/critical-css`
- `test/integration/custom-error-page-exception`
- `test/integration/font-optimization`
- AMP specific tests
2022-04-05 21:51:47 +00:00
Jiachi Liu
67d25a58a4
Custom app for switchable runtime (#35666)
x-ref: #33149
RFCs:
- #30996
- #31506 

## 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
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`
2022-04-05 19:46:17 +00:00
JJ Kasper
b1a7b88890
Add warning when importing "next" directly (#35884)
* Add warning when importing "next" directly

* Apply suggestions from code review

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* Apply suggestions from code review

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

* add example

Co-authored-by: Balázs Orbán <info@balazsorban.com>
Co-authored-by: Steven <steven@ceriously.com>
2022-04-05 10:57:45 -05:00
Sukka
081e7b0027
fix: reset visible state when src/href changed (#35287)
* fix(#35286): reset visible state when image src changed

* fix(#35286): reset visible state when link href changed

* test(image): image with new src should be re-lazyloaded

* test: apply code suggestions from @styfle's review

* test: incorrect condition of image load check
2022-04-04 14:18:49 -04:00
JJ Kasper
4db8c49cc3
v12.1.5-canary.1 2022-04-04 10:29:32 -05:00
Alex Castle
352e60dedd
Fix layout="raw" image element sizes prop (#35809)
This fixes an issue with how the sizes prop was being applied to images with the experimental raw layout. The only effects were on the raw layout, so won't effect any non-experimental functionality.
2022-04-01 16:41:02 +00:00
Shu Ding
0eb9f7e76d
Initial implementation of statically optimized flight data of server component pages (#35619)
Part of #31506 and https://github.com/vercel/next.js/discussions/34179. This PR ensures that in the `nodejs` runtime, the flight data is statically stored as a JSON file if possible. Most of the touched code is related to conditions of static/SSG/SSR when runtime and/or RSC is involved.

## 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-04-01 16:13:38 +00:00
LongYinan
8b9ae8314e
Collect packages are used and eliminated in getServerSideProps (#35404)
Collect telemetry info about packages are used and eliminated in `getServerSideProps`

https://github.com/vercel/next-telemetry/pull/71


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-04-01 15:08:44 +00:00
JJ Kasper
3069d4b770
v12.1.5-canary.0 2022-03-31 18:27:09 -05:00
JJ Kasper
e148d2bdbd
Continue testing react v17 with e2e tests (#35787)
* Continue testing react v17 with e2e tests

* update react 17 expected error

* Update env variable name and add log

* fix starter cache version

* remove extra setup condition

* Revert "remove extra setup condition"

This reverts commit 5760a9f8867213f95a9fac073fe27a9ec01b780f.

* update basepath test

* remove log

* stabilize test
2022-03-31 17:35:00 -05:00
Jiachi Liu
d165836d88
Use ReadableStream in client hydration for Firefox compatibility (#35796)
Firefox doesn't support `TransformStream` but `ReadableStream` at the moment, change the implmentation of hydration to make firefox work with RSC

## Bug

Fixes #35763
x-ref: https://github.com/vercel/next-react-server-components/issues/38

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have helpful link attached, see `contributing.md`
2022-03-31 21:26:46 +00:00
Houssein Djirdeh
aa93109156
[Script] Use __non_webpack_require__ to fetch partytown server-side (#35793)
A few errors about Next.js not correctly handling the missing partytown dependency in `_document.js` have been flagged. Instead of `/* webpackIgnore: true */`, this PR switches to use [`__non_webpack_require__`](https://webpack.js.org/api/module-variables/#__non_webpack_require__-webpack-specific) to ensure webpack doesn't process fetching the dep server-side. 

-----

Related issues: 

- #35645 
- https://github.com/vercel/next.js/issues/35630#issuecomment-1084365365
2022-03-31 19:44:15 +00:00