Commit graph

15120 commits

Author SHA1 Message Date
konomae
5cf4219686
Fix URL anchor position in going-to-production.md (#47056)
Fix an anchor currently not working properly.
2023-03-13 06:01:37 +00:00
JJ Kasper
acb174455f
Fix generateStaticParams check in app dir (#47051)
This ensures our `params` checking works properly with `app` dir. 

x-ref: [slack thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1678659475821299)
2023-03-13 00:05:35 +00:00
Jiachi Liu
0bee9e6f92
test: update amp test to always check redbox (#47050) 2023-03-12 20:44:23 +00:00
Tim Neutkens
287ad83399 v13.2.5-canary.1 2023-03-11 20:41:30 +01:00
Jiachi Liu
fdfd9beb5f
Add /route subpath to metadata static routes (#47030)
Set the output bundle file path to `/<metadata route>/route.js` to align with other custom app routes, in order to make it easier being handled by app routes in both nextjs and vercel
2023-03-11 19:22:01 +00:00
Yangshun Tay
c110dfd57c
fix: exclude 'mdx-bundler' from being bundled in server components (#46992)
`mdx-bundler` is used for server-side transformation of MDX files and currently using it within server components will throw a `Module parse failed: Unexpected token` error.

Adding `serverComponentsExternalPackages: ['mdx-bundler']` to `next.config.js` fixes the issue, but it's probably good to add to the default exclusion list as `mdx-bundler` is a relatively popular approach for using MDX in Next.js apps.
2023-03-11 02:12:10 +00:00
Maksym Anisimov
74891fde18
Add auto-detection of image/x-icon content type (#47013)
Added auto-detection of image/x-icon content type by analyzing response buffer

fixes https://github.com/vercel/next.js/discussions/45998

Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2023-03-10 20:36:33 +00:00
Tobias Koppers
2e51690143 avoid sending modules in parent for dynamic imports (vercel/turbo#4056)
### Description

Keeps track of available modules when importing new chunk groups. Omits
assets that are already available in the parent chunk group(s) when
determining assets to be included in chunks.

### Testing Instructions

Dynamic imports should not include modules that are already in the
parent chunks

<!--
  When the below is checked (default) our PR bot will automatically
  assign labels to your PR based on the content to help the team
  organize and review it faster.
-->

- [x] Auto label
fixes WEB-599
2023-03-10 19:42:22 +00:00
Jesse Koldewijn
84104af63e
fix: added jsdom & canvas to the external packages list - fixes #46893 (#46990)
fixes #46893

### What?
fixing compile issue reguarding the dompurify package.

### Why?
To allow the usage of dompurify

### How?
Added jsdom and canvas to the external packages list which are used by dompurify and throw errors if not added to this list.
2023-03-10 19:27:41 +00:00
Hannes Bornö
c75c4e56c5
Update next/font/google data (#46988)
Add the new fonts to `next/font/google`.
2023-03-10 18:27:58 +00:00
OJ Kwon
4bea437c7d feat(ecmascript): transform ts input with runtime flags (vercel/turbo#4142)
### Description

Another attempt to close WEB-659.

The crux is same as previous PR, but attempt to change the location
where it read config / bubble down the config values to the actual
transform stage. Mainly, `enable_typescript_transform` is now accepting
an option instead of boolean flag to down to
`EcmaInputTransform::Typescript`, and `get_*_module_context()` reads the
config value as needed.
2023-03-10 18:23:29 +00:00
Tim Neutkens
7d48edfe8e v13.2.5-canary.0 2023-03-10 18:06:16 +01:00
Tobias Koppers
7e5881b72a
update turbopack (#46994)
# Bugfixes

* https://github.com/vercel/turbo/pull/4149
* https://github.com/vercel/turbo/pull/4151

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-03-10 17:59:48 +01:00
Jiachi Liu
fd6b93d46e
Generate fixed route path for favicon.ico (#46997)
Generate `/favicon.ico` route when favicon.ico is placed into `app/`.

Still collect favicon metadata image information through
metadata-image-loader but don't emit the file to static dist anymore.
Also collect favicon through metadata routes, and render it as static
routes. Also remove the `hash` we generated before, not needed anymore.

Change metadata static routes rendering process: collect static metadata
assets, read the buffer of the file data and return it in the response.

Closes NEXT-791
2023-03-10 17:12:44 +01:00
Shu Ding
d200e5fa1d
Support default arrow function export in server boundary (#46977
This PR adds basic support for default export of an async arrow
function:

```js
export default async (a, b) => { console.log(a, b) }
```

In upcoming PRs I'll refactor named export handling and inlined
declarations.
2023-03-10 14:38:51 +01:00
Shu Ding
10f2268f4e
Add Zod and router state validation (#46962)
This PR adds Zod to the precompiled libraries, and use it to create schemas for the router state tree for validation. In other planned features/changes, Zod will also be used to do run-time data validation.

Fixes NEXT-135.
2023-03-10 13:37:45 +00:00
Tobias Koppers
01f2524392 fix pathname for data requests (vercel/turbo#4149)
### Description

| input file         | HTML pathname | Data pathname    |
| ------------------ | ------------- | ---------------- |
| index.tsx          | /             | .../index.json   |
| blog.tsx           | /blog         | .../blog.json    |
| pricing/index.tsx  | /pricing      | .../pricing.json |
2023-03-10 08:40:43 +00:00
JJ Kasper
05f6de1086
v13.2.4 2023-03-09 16:41:28 -08:00
JJ Kasper
1ce3b36179
v13.2.4-canary.9 2023-03-09 14:46:45 -08:00
Noemi
71dbcacf17
Do not re-assign process.env (#46914)
## Checklist

- [ ] Related issues linked using `fixes #number` 
  - no related issue exists, happy to open one if desired
- [x] Tests added
- not sure if specific tests are needed? there is an integration test
for environment variables, and Next.js relies a lot on passing
information through environment variables; i'd expect everything to
break if this change broke environment variable handling
- [x] Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md
  - no new errors, does not apply

### What?

Re-assigning `process.env` substitutes the "magic object" that sets
environment variables at the process level with an ordinary JavaScript
object. This causes environment variables that are set after
`process.env` is re-assigned to not be visible to native add-ons.

See [this Node.js issue][issue] and [this reproduction case][repro] for
details.

[issue]: https://github.com/nodejs/node/issues/46996
[repro]: https://github.com/unflxw/nodejs-process-env-addons-repro

### Why?

In general, paraphrasing the maintainer in the Node.js issue,
re-assigning `process.env` is not a thing you should do. More
specifically, I'm trying to use Next.js' experimental OpenTelemetry
support with AppSignal's Node.js integration, which also uses
OpenTelemetry.

The AppSignal Node.js package sets environment variables in order to
configure a long-running process, which is then launched through a
native add-on. Because of the re-assignment of `process.env` that occurs
early in Next.js' lifecycle process, by the time the AppSignal Node.js
package sets environment variables, it's setting them in an ordinary
JavaScript object that Next.js left in the global `process` object, not
in the magic one created by the Node.js runtime.

This means that these environment variables are not _actually_ being set
for the process at the OS level, and therefore they're also not set for
the native add-on, or for the long-running process it spawns.

### How?

A `replaceProcessEnv` function is implemented that takes an environment
object as an argument, and applies the difference between that
environment object and the current environment to the existing
`process.env` object. This function is used instead of re-assigning
`process.env`.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-03-09 14:41:50 -08:00
Seiry Yu
9f08ef8daf
fix: Add NODE_OPTIONS for debugging in next-dev (#46757)
<!--
Thanks for opening a PR! Your contribution is much appreciated.
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(s) that you're making:
-->

## Bug
fix #46948 
- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/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`
- [ ]
[e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Documentation / Examples

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

Co-authored-by: Seiry Yu <seiry@squareup.com>
2023-03-09 14:12:54 -08:00
JJ Kasper
9be98e4aec
Use turbo remote cache for build-native-test (#46975)
This ensures we leverage the turbo remote cache when able to for the dev
swc binary as well.

x-ref:
https://github.com/vercel/next.js/actions/runs/4378909387/jobs/7664237608
2023-03-09 14:06:05 -08:00
Justin Ridgewell
8e14b672cc
Update Turbopack to 230309.2 (#46971)
# New Features
- https://github.com/vercel/turbo/pull/3975

# Bug Fixes
- https://github.com/vercel/turbo/pull/4129
- https://github.com/vercel/turbo/pull/4134
- https://github.com/vercel/turbo/pull/4062

# Performance
- https://github.com/vercel/turbo/pull/4093
2023-03-09 13:24:24 -08:00
Hannes Bornö
9a41ba9ac4
Improve RSC compiler error in external module (#46953)
When the RSC compiler error was caused by an external package, make the
error message display which import caused the error. Also don't show
node_module files in the import trace.

Continuation of https://github.com/vercel/next.js/pull/45484

Before

![image](https://user-images.githubusercontent.com/25056922/224032476-6811a1d5-d690-48be-9602-781f459edc70.png)

After

![image](https://user-images.githubusercontent.com/25056922/224032177-2d0b2977-098f-46bd-8e30-9e6bc21b9153.png)

Updates the format of the files, from `app/page.js` to `./app/page.js`
to align it with other import traces.

![image](https://user-images.githubusercontent.com/25056922/224030420-1d3ff0ba-5747-4ed3-8b0b-9c4deace54ea.png)


Closes NEXT-523
2023-03-09 12:27:57 -08:00
Hannes Bornö
09d21d6e99
Move error overlay recovery tests to new file (#46965)
Move error overlay recovery tests in `ReactRefreshLogBox.test.ts` to a
new file. This is already done for the app router tests, but this does
it for the old router as well. Makes `ReactRefreshLogBox.test.ts` faster
to run.
2023-03-09 12:15:30 -08:00
Jiachi Liu
1e7f4a58fe
Update vendored react (#46970)
Update to latest next channel of react

mainly for https://github.com/facebook/react/pull/26353

```
-  3706edb81 [Float][Fizz]: Don't preload nomodule scripts (#26353) (Josh Story)
-  2b003a5cc Split out ServerReferenceMetadata into Id and Bound Arguments (#26351) (Sebastian Markbåge)
-  62cd5af08 Codemod redundant async act scopes (#26350) (Andrew Clark)
-  037378202 Internal `act`: Call scope function after an async gap (#26347) (Andrew Clark)
-  d8e49f2af Use setTimeout to schedule work on the server in Edge environments (#26348) (Sebastian Markbåge)
-  83643778b Internal test helpers: Use Node's MessageChannel to queue task (#26345) (Andrew Clark)
-  f36ab0e37 Remove timers from ReactDOMSuspensePlaceholder tests (#26346) (Andrew Clark)
-  44d380794 Move internalAct to internal-test-utils package (#26344) (Andrew Clark)
-  8c100620c Build: specify Node.js 16 as minimum for dev (#26343) (Jan Kassens)
-  d81447304 [Internal API only] Delete non-awaited form of act (#26339) (Andrew Clark)
-  702fc984e Codemod act -> await act (4/?) (#26338) (Andrew Clark)
-  9fb2469a6 Restore definition of NativeMethods as an object for React Native (#26341) (Rubén Norte)
-  aef930314 [DevTools] upgrade electron to latest version & security improvements (#26337) (Mengdi Chen)
-  161f6ae42 Codemod act -> await act (3/?) (#26336) (Andrew Clark)
-  58605f798 Codemod act -> await act (2/?) (#26335) (Andrew Clark)
```
2023-03-09 11:44:33 -08:00
Jiachi Liu
36ca1598d5
Support static file robots.txt and sitemap.xml as metadata route (#46963)
Support top level static `robots.txt` and `sitemap.xml` as metadata
route in app directory. When those files are placed in top root
directory

Refactored a bit the page files matching logic, to reuse it between dev
server and build

Closes NEXT-267
2023-03-09 11:10:18 -08:00
Tobias Koppers
511b244f4a improve introspection (vercel/turbo#4135)
### Description

Add more details to introspection and make it more robust to errors
during introspection

### Testing Instructions

go to http://localhost:3000/__turbopack__/
2023-03-09 16:08:03 +00:00
Tobias Koppers
42fa76a3f7 fix app dir with latest next.js (vercel/turbo#4134)
### Description

* [fix manifest for
__ssr_module_mapping__](4abd87312d)
* [add missing styled-jsx
alias](d9b4a4df7f)

### Testing Instructions

layout-playground
2023-03-09 16:05:29 +00:00
Alex Kirszenberg
2ffcc59ea7 Merge EcmascriptChunkUpdates before sending them to the client (vercel/turbo#3975)
This diff:
* introduces the `VersionedContentMerger` trait, which allows for
merging the updates of versioned contents within the same chunk group;
* implements this for `EcmascriptChunkContent`/`EcmascriptChunkUpdate`,
turning them into
`EcmascriptMergedChunkContent`/`EcmascriptMergedChunkUpdate`;
* creates a new `ChunkList` asset which is capable of merging chunk
updates of chunks within the same chunk group, and create such an asset
for dynamic chunks (through manifest/loader_item.rs) and chunk group
files assets.

This fixes a bunch of edge cases related to HMR:
* HMR of dynamic imports now works;
* Chunks getting added/deleted/renamed now also works with HMR, since
we're listening to updates at the chunk group level;
* CSS chunks get reloaded in the right order, with respect for
precedence.

There are still known edge cases with HMR:
* CSS chunks added through HMR are not inserted at the right position to
respect precedence (WEB-652).
* Update aggregation is disabled because we don't want a critical issue
to stop all HMR (WEB-582) . This would be fixed by applying aggregated
updates when dismissing the error modal, but there are some edge cases
with this too (e.g. what happens when an HMR update also causes an error
on top of an existing error).
2023-03-09 11:13:04 +00:00
JJ Kasper
715f96fb49
v13.2.4-canary.8 2023-03-08 16:06:57 -08:00
Shu Ding
ddff41a908
Support re-exporting unnamed function expression (#46936)
Add support for cases like:

```js
const foo = async function () {}
export default foo

const bar = async function() {}
export { bar }
```

Also fix a bug where nested async function declarations are mistakenly
counted as actions.

Fixes NEXT-800.
2023-03-08 15:07:31 -08:00
Tobias Koppers
e6103ae6dd update next.js version (vercel/turbo#4130) 2023-03-08 22:34:04 +00:00
JJ Kasper
80f2293a01
Revalidate generateStaticParams/Paths in background in dev (#46940)
Follow-up to https://github.com/vercel/next.js/pull/46906 this ensures
we revalidate `generateStaticParams`/`getStaticPaths` in the background
in development so that we aren't blocking refreshes an much
un-necessarily if the paths cache is already populated.

Fixes: https://github.com/vercel/next.js/issues/44646
Fixes: https://github.com/vercel/next.js/issues/38757
x-ref:
https://github.com/vercel/next.js/discussions/17977#discussioncomment-142104
x-ref: https://github.com/vercel/next.js/discussions/20076
x-ref: https://github.com/vercel/next.js/discussions/14378
2023-03-08 14:33:28 -08:00
Hannes Bornö
de6a1e3d76
Rename FontLoaderManifest to NextFontManifest and add better comments (#46922)
Rename FontLoaderManifest to NextFontManifest to make it more obvious
that it has to do with `next/font`.

There's a change to how the plugin determines if a module is generated
by `next/font`. Instead of looking at the target CSS file
https://github.com/vercel/next.js/blob/v13.2.4-canary.6/packages/next/src/build/webpack/plugins/font-loader-manifest-plugin.ts#L37-L49.
It simply looks if the module has `next-font-loader` in its loaders:
https://github.com/vercel/next.js/compare/canary...hanneslund:next.js:next-font-build-cleanup?expand=1#diff-34d7972c68687e875c868847f782f369c3af162a9af10949f3577660775afcb2R65-R74

Also more comments added to the manifest plugin and the `next/font`
postcss plugin.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-03-08 13:58:57 -08:00
Shu Ding
bae5d6fcd4
Validate the router state header on the server (#46925)
Ensure that the router tree state header is one single, valid value.

Fixes NEXT-136.
2023-03-08 13:44:17 -08:00
Shu Ding
b3220fe322
Validate req.url in renderer (#46923)
It's possible that the request is missing or having an invalid URL, and
got passed to the renderer.

Fixes NEXT-139.
2023-03-08 13:16:42 -08:00
Hannes Bornö
02eb34db01
Use https_proxy environment variable in next/font/google (#46822)
When fetching CSS or font files from Google Fonts, it won't work if
you're required to use a proxy. This change makes it look for the
`http(s)_proxy` environment variable, and if it's defined it creates a
fetch agent using
[https-proxy-agent](https://github.com/TooTallNate/node-https-proxy-agent).

Also fixes fetch errors not being properly logged.

Fixes #45034
Closes NEXT-690

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/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`
- [ ]
[e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2023-03-08 12:23:32 -08:00
JJ Kasper
f99ae5af97
v13.2.4-canary.7 2023-03-08 11:52:58 -08:00
Justin Ridgewell
612d578188
Update Turbopack to 230308.3 (#46935)
# Bug Fixes
- https://github.com/vercel/turbo/pull/4121
- https://github.com/vercel/turbo/pull/4111
2023-03-08 11:25:23 -08:00
Hannes Bornö
0e073366da
Reduce the number of hydration error tests (#46930)
`test/development/acceptance-app/hydration-error.test.ts` has a lot of tests because I ported all the tests in https://github.com/facebook/react/blob/main/packages/react-dom/src/__tests__/ReactDOMHydrationDiff-test.js. Running all those tests takes a lot of time, and to include all the different cases is overkill.

This PR removes most tests but keeps one test case per type of hydration error, and also one using suspense. This makes more sense, it should only test that all the different hydration error messages are picked up.
2023-03-08 16:41:21 +00:00
Will Binns-Smith
074630e7ce WEB-415: next/font/google: Use next's bundled font-data.json (vercel/turbo#4111)
This removes the duplicated (and possibly mismatching) font data file in
favor of loading the copy bundled with next, using `load_next_json`
introduced in vercel/turbo#4086. It also removes the associated workflow and
generation script.
2023-03-08 08:25:22 -08:00
Shu Ding
8ca0233d08
Support default export expression for variables (#46896)
Similar to #46888, this PR adds support for the case:

```js
async function foo () {}
export default foo
```

...where you export an ident as a default export expression.

Closes NEXT-770

~Should be landed after #46881.~
2023-03-08 14:45:32 +00:00
Donny/강동윤
37b0349731
Update turbopack to 230308.1 (#46909)
## Bugfixes

 - https://github.com/vercel/turbo/pull/3526
 - https://github.com/vercel/turbo/pull/4084
 - https://github.com/vercel/turbo/pull/4083
 - https://github.com/vercel/turbo/pull/4067
 - https://github.com/vercel/turbo/pull/3959
 - https://github.com/vercel/turbo/pull/4060
 - https://github.com/vercel/turbo/pull/4081
 - https://github.com/vercel/turbo/pull/4103
 - https://github.com/vercel/turbo/pull/4100
 - https://github.com/vercel/turbo/pull/4108
 - https://github.com/vercel/turbo/pull/4101
 - https://github.com/vercel/turbo/pull/4112
 - https://github.com/vercel/turbo/pull/3956
 - https://github.com/vercel/turbo/pull/4118
 - https://github.com/vercel/turbo/pull/4117

## Feature

 - https://github.com/vercel/turbo/pull/4058
  - https://github.com/vercel/turbo/pull/4013
  - https://github.com/vercel/turbo/pull/4005
  - https://github.com/vercel/turbo/pull/4001
  - https://github.com/vercel/turbo/pull/3839
  - https://github.com/vercel/turbo/pull/4017
  - https://github.com/vercel/turbo/pull/4086
  - https://github.com/vercel/turbo/pull/4067

## Performance

  - https://github.com/vercel/turbo/pull/4040
  - https://github.com/vercel/turbo/pull/4110

## Refactor

 - https://github.com/vercel/turbo/pull/4098
2023-03-08 13:51:28 +00:00
Jiachi Liu
292f65f6d3
Fix unexpected hoist meta tags by react in app dir (#46917)
### Bug Fix

Update vendor react to fix the unexpected hoist tags issue

x-ref: https://github.com/facebook/react/pull/26256

* Fixes #42648
* Closes NEXT-655
* tests added
2023-03-08 11:34:51 +00:00
Jan Kaifer
8b50b80cde
eslint rule for script strategy should work properly in app/ (#46609)
fixes https://github.com/vercel/next.js/issues/46549

The docs are wrong for now, this limitation is just in `pages/`, you can
use it anywhere in `app/`.

Since `app/` is still not stable we will emit that warning in all files
outside of `app/`.
2023-03-08 11:28:52 +01:00
JJ Kasper
bfc3849b1f
Update generateStaticParams handling with fetch cache (#46906)
This ensures we leverage the fetch cache when calling
`generateStaticParams` and also ensures paths with
`generateStaticParams` without `dynamicParams = false` don't error when
only partial params are provided.

x-ref: [slack
thread](https://vercel.slack.com/archives/C035J346QQL/p1678149362238089)
2023-03-07 22:59:06 -08:00
Shu Ding
2dea520ae2 fix(turbopack): Update app-renderer (vercel/turbo#4102)
### Description

This PR mirrors some related manifest changes in Next.js:
https://github.com/vercel/next.js/pull/46881.

### Testing Instructions

<!--
  Give a quick description of steps to test your changes.
-->

---------

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
2023-03-08 05:47:50 +00:00
Tobias Koppers
db5e2ea401 fix assert alias (vercel/turbo#4114)
### Description

typo, causing resolve failure
2023-03-08 03:32:21 +00:00
Tobias Koppers
c4b64405fd disable issue_path again (vercel/turbo#4118)
### Description

Performance is just too bad
2023-03-08 02:18:31 +01:00