Commit graph

15932 commits

Author SHA1 Message Date
Tim Neutkens
cf9591cd23
Ensure App Router and Pages Router modules can't share chunks (#50327)
## What?

Ensures the name of the chunk is not the same between two modules in different layers.
E.g. if you import 'button-library' in App Router and Pages Router we don't want these to be bundled in the same chunk as they're never used on the same page.

## How?

Added the layer to the chunk name hash generation in splitChunks. Ensures the two modules don't have the same chunk name generated, as discussed with @sokra.

Follow-up to #50324
2023-05-25 23:14:35 +00:00
Jiachi Liu
5831d0c124
Fix static metadata routes runtime when root layout is in edge runtime (#50351)
Since the static metadata routes should always be static that can be
optimized, they should be marked as default runtime (or basically no
runtime). This PR change the runtime detection, if it's a static
metadata route file, its runtime will be erased.

So that it won't be picked up by `edge-app-route-loader` and then by
`next-image-loader` which emits the unexpected static file

Fixes NEXT-1238
2023-05-25 15:39:57 -07:00
vercel-release-bot
26835bdba5 v13.4.4 2023-05-25 22:02:44 +00:00
vercel-release-bot
8c17a4b688 v13.4.4-canary.13 2023-05-25 21:31:39 +00:00
조상현
2b5205a910
makeDir should use func (#50136)
Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2023-05-25 20:11:27 +00:00
vercel-release-bot
0c968b8e2a v13.4.4-canary.12 2023-05-25 18:50:55 +00:00
Shu Ding
592f592b07
Fix SWC loader options for files outside of RSC layers (#50341)
The React Server Component transform of SWC shouldn't be enabled for
files that are not part of "app layers", for example middleware.
2023-05-25 19:49:26 +02:00
vercel-release-bot
3870abf049 v13.4.4-canary.11 2023-05-25 16:20:33 +00:00
Tobias Koppers
187d1bff40
remove allowlist, only use denylist, enable newly passing tests (#50325)
### What?

* remove allowlist
* add script to print enabled test cases
* enable test suites that turbopack is newly passing
2023-05-25 15:37:28 +02:00
Shu Ding
25ce787d76
Fix missing error when using Actions on the client layer without enabling the feature flag (#50257)
If using Server Actions on the client layer without enabling the
`serverActions` feature, the build should error. Add a test case to
ensure #50199 works.
2023-05-25 14:22:27 +02:00
Jiachi Liu
8725b6c376
Add missing react-dom/client alias (#50324)
Fixes #50312
fix NEXT-1235
2023-05-25 12:10:02 +00:00
Tobias Koppers
46369f5746
do not apply sass loader on existing loaders (#50308)
follow up for #50259

---------

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
2023-05-25 13:42:22 +02:00
Tobias Koppers
06f505c78b
Parallelize Turbopack CI tests (#50292)
### What?

Parallel jobs

### Why?

Timeouts otherwise


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2023-05-25 07:46:02 +00:00
JJ Kasper
3c67583405
Fix middleware e2e deploy test (#50317)
`default` isn't a valid `region` at this point so this removes that.

Fixes:
https://github.com/vercel/next.js/actions/runs/5076047750/jobs/9118043860#step:6:469
2023-05-24 23:50:06 -07:00
vercel-release-bot
831a1a99c3 v13.4.4-canary.10 2023-05-25 04:20:36 +00:00
JJ Kasper
e09efd5e5c
land: Include charset=utf-8 with x-component Content-Type header (#50314)
Lands https://github.com/vercel/next.js/pull/50060 with lint fixes and
updated tests.

Closes: https://github.com/vercel/next.js/pull/50060

---------

Co-authored-by: Leah Lundqvist <leah@pigeon.sh>
2023-05-24 21:05:12 -07:00
JJ Kasper
027aa72f47
Fix catch-all edge app route (#50313)
This ensures we properly normalize app pages in the `web-server` so that
it doesn't fail to match/interpolate properly.

Fixes: https://github.com/vercel/next.js/issues/43384
2023-05-24 20:30:54 -07:00
Justin Ridgewell
12e22edd74
[turbopack]: Serve _devMiddlewareManifest.json from router (#50241)
This change allows the Turbopack's node router to serve
`_next/static/development/_devMiddlewareManifest.json` file, which is
just the matchers for middleware routes. This is usually handled by the
node dev server anyways, but we were filtering out the route so that
Turbopack could handle it.

But, Turbopack doesn't implement the route matching logic at all, it's
all handled by our node router. So Turbopack can't know what the
middleware matchers are. Having the router just handle this like the
normal dev server is both easy and efficient (I don't want to spin up
_another_ node instance just to transform the matchers into the expected
format).

Fixes WEB-979

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-05-24 17:55:29 -07:00
Jiachi Liu
1079c10064
Alias next/server for edge runtime (#50268)
* For edge runtime, map `next/server` to esm assets to get benefit from
tree-shaking
* Mark process.turbo flag as `false` when running with webpack

Closes NEXT-1212

Compare with canary (13.4.4-canary.8)

#### Middleware

##### before vs after
<img width="319" alt="image"
src="https://github.com/vercel/next.js/assets/4800338/ffa3e744-8f14-4c61-9f5a-ccd04b8911f2">
<img width="317" alt="image"
src="https://github.com/vercel/next.js/assets/4800338/fc974a39-49f3-439a-966c-07af3c71db05">



#### Edge route

##### before vs after
<img width="313" alt="image"
src="https://github.com/vercel/next.js/assets/4800338/bea6e7bb-5875-4a6b-899f-94ad6a8df902">

<img width="314" alt="image"
src="https://github.com/vercel/next.js/assets/4800338/1783fb03-b473-496a-bb97-fa613fe58d7a">
2023-05-24 15:34:29 -07:00
vercel-release-bot
ed60646a19 v13.4.4-canary.9 2023-05-24 22:21:36 +00:00
Tobias Koppers
e15eb2a443
fix sass handling after refactoring (#50259)
### What?

Push sass into the css pipeline
2023-05-25 00:10:51 +02:00
Maia Teegarden
e257068b5f
Add root detection utils (#50305)
A previous
[PR](https://github.com/vercel/next.js/pull/49110#discussion_r1183282878)
tried to reuse `rawNextConfig.experimental.outputFileTracingRoot` before
invoking Turbopack, but that will always be undefined because
`assignDefaults` hasn't been called yet. This creates a shared utility
to be reused.
2023-05-24 14:51:47 -07:00
JJ Kasper
a7a9777ddc
Update unstable_cache key to include args (#50301)
As discussed this includes arguments passed to `unstable_cache` to
cacheKey automatically so users don't have to remember to do this
manually.
2023-05-24 13:46:48 -07:00
JJ Kasper
1619a6a5a9
Update server invoke-request (#50296)
Follow-up to https://github.com/vercel/next.js/pull/50293 we can now
avoid this normalizing which isn't as reliable as being able to rely on
`localhost` directly since we can't assume it maps to `127.0.0.1`
always.

x-ref:
https://github.com/vercel/next.js/actions/runs/5072034311/jobs/9109241689
2023-05-24 12:41:07 -07:00
JJ Kasper
47546ddccc
Update next start listening to behave consistently (#50293)
Fixes next start listening as it currently behaves in-consistently
between dev and start, this shouldn't break any existing behavior as the
default is to listen on all interfaces and if it needs to be locked down
it still can be.

x-ref:
https://github.com/vercel/next.js/actions/runs/5065560220/jobs/9094296465
2023-05-24 11:06:41 -07:00
Javi Velasco
aa91de56ce
Remove static analysis of process.env (#50260)
Since there is no longer a limitation that requires us to static analyze
`process.env`, this PR removes it from the build process and updates the
corresponding documentation.
2023-05-24 08:19:02 -07:00
vercel-release-bot
f1df0d009b v13.4.4-canary.8 2023-05-24 11:08:12 +00:00
Shu Ding
18ba2085b4
Fix edge case in the CJS optimizer (#50258)
Previously we are ignoring idents in all var declarators in the check,
so it's still possible to fail in some edge cases. CC @kdy1
2023-05-24 13:02:22 +02:00
Donny/강동윤
fcfd63065b
feat(next-swc): Add CJS optimizer again (#50249)
### What?

This reverts commit 6ebc725fe6 / #50247.

### Why?

#49972 is reverted due to bugs, and I'm retrying it.

### How?

Closes WEB-1072
Closes WEB-1097
Closes NEXT-1156 (as it's reopened by the revert PR)

fix #48469

---------

Co-authored-by: Shu Ding <g@shud.in>
2023-05-24 09:38:31 +02:00
vercel-release-bot
0e339a8542 v13.4.4-canary.7 2023-05-24 06:12:54 +00:00
JJ Kasper
20b19b5ef4
Fix metadata e2e deploy test (#50252)
x-ref:
https://github.com/vercel/next.js/actions/runs/5061340215/jobs/9085634641#step:6:368
2023-05-23 23:04:31 -07:00
JJ Kasper
b5e8d6531b
Fix free port handling (#50248)
Follow-up to https://github.com/vercel/next.js/pull/48019 ensures we
don't use arbitrary ports by incrementing favoring always getting a
fresh free port instead. Also favors exact address for internal IPC
requests instead of `localhost`.
2023-05-23 22:13:10 -07:00
JJ Kasper
6ebc725fe6
Revert "feat(next-swc): Implement CJS optimizer" (#50247)
This seems to be failing with the WASM builds so this reverts to allow
further investigation

x-ref:
https://github.com/vercel/next.js/actions/runs/5062818601/jobs/9088828339
x-ref:
https://github.com/vercel/next.js/actions/runs/5061364458/jobs/9085596546
x-ref:
https://github.com/vercel/next.js/actions/runs/5062868910/jobs/9092170727

Reverts vercel/next.js#49972
2023-05-23 21:45:37 -07:00
vercel-release-bot
fce5fa6ff0 v13.4.4-canary.6 2023-05-23 23:07:34 +00:00
Jiachi Liu
130fe65bde
Fix alias for react-dom/server (#50238)
A bad alias was introduced in #50128

Fixes #50225
2023-05-23 16:00:59 -07:00
Donny/강동윤
ec8bf53907
feat(next-swc): Implement CJS optimizer (#49972)
### What?


Implement a CJS optimizer for next-swc


### Why?

x-ref: https://vercel.slack.com/archives/C02HY34AKME/p1684341093462309

Assuming most CJS files are transpiled from ESM, we can mimic
tree-shaking using an AST transform.

### How?

Closes WEB-1072
Fixes #48469


fix NEXT-1156

---------

Co-authored-by: Shu Ding <g@shud.in>
2023-05-23 21:38:07 +02:00
vercel-release-bot
ba9aa63417 v13.4.4-canary.5 2023-05-23 19:34:54 +00:00
Tobias Koppers
bf7a556204
enable more test cases for turbopack (#50154)
### What?

Enable more test cases to run with turbopack

### Why?

These test suites are passing and are not flaky.
2023-05-23 20:21:56 +02:00
Cowboy Ho
90331f38cc
fix: NODE_OPTIONS='--inspect' in next dev for debugging (#48019)
## Bug

This fix closes #47083 issue 
This fix closes #47561 issue
This fix closes #48376 issue
**Invalid repetition PRs:** #47671 (this PR changing expired code)
(This issue still exist on
[v13.4.3-canary.1](https://github.com/vercel/next.js/releases/tag/v13.4.3-canary.1)

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

### What?
When running `NODE_OPTIONS='--inspect' next dev`, 
the render server didn't start with `--inspect`. 
In some cases, 
the `--inspect` flag will be passed when `__NEXT_DISABLE_MEMORY_WATCHER`
was set.

### Why?
Since #47208 revamped some startup processes, the `NODE_OPTIONS`
environment parameter is not passed down to the render server worker.

### How?
Just add back the original startup process.


![image](https://user-images.githubusercontent.com/14261588/230398898-791e6909-6f4c-493b-937d-058a7b788849.png)


link NEXT-1176

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-05-23 11:03:08 -07:00
Maia Teegarden
ff070e530b
Use correct casing in filenames (#50223)
My computer ignored the casing change when copying things over, which
causes resolution errors.
2023-05-23 17:49:36 +00:00
Shu Ding
1a40651267
Add special route types to the link type declaration (#50066)
This PR adds generated type definitions for `Link` hrefs with only search, hash or with a protocol.

Closes #49825.
fix NEXT-1203
2023-05-23 17:36:09 +00:00
Tobias Koppers
33b8e6157f
change static path to /_next/static/media (#50207)
### What?

align output path of turbopack and webpack

### Why?

passing test cases

### Turbopack Changes

* https://github.com/vercel/turbo/pull/5072 <!-- Tobias Koppers -
improve asset path -->
2023-05-23 18:39:27 +02:00
vercel-release-bot
9eaf4f5dc8 v13.4.4-canary.4 2023-05-23 16:03:50 +00:00
Jesse Koldewijn
2fa58c3a88
fix: Added blockfrost-js, lucid-cardano & mongoose package to srvExtPackages to prevent issue #49783 from happening. (#49938)
fixes #49783

### What?
Added the following packages to the server component exclusion list
which prevents these packages from going through the currently default
compile pipeline for apps that use the App Router. Packages added are:
"@blockfrost/blockfrost-js", "@jpg-store/lucid-cardano" and "mongoose".
(For instance, mongo was already in this exclusion list)

### Why?
These packages are required by the
"@emurgo/cardano-serialization-lib-nodejs" packages and break when not
added to this list while using the app router.

### How?
I've added these packages to the server-external-packages json file in
the Next.js package's lib directory.
2023-05-23 17:41:59 +02:00
Tim Neutkens
eba9e39ea4
Ensure NEXT_DYNAMIC_NO_SSR_CODE has a unique name (#50219)
## What?

Ensures `NEXT_DYNAMIC_NO_SSR_CODE` has a unique error code value, this
accidentally had the value for dynamic server usage (e.g. calling
cookies()) which caused the warning to be shown as shown in #48442.

## How?

Changed the digest value to something unique.


Fixes NEXT-1125
Fixes #48442

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

## For Contributors

### Improving Documentation or adding/fixing Examples

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

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md



## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->
2023-05-23 08:37:57 -07:00
JJ Kasper
0718dbb7a5
Fix static workers distributing (#50194)
This removes the `computeWorkerKey` from our static workers as this
doesn't work in practice as efficiently as we hoped since a single page
can have thousands of paths to render which won't be distributed to
separate workers if the same worker key is returned.

Fixes: https://github.com/vercel/next.js/issues/49593

**Before**

![before](https://github.com/vercel/next.js/assets/22380829/da1e0a03-8b15-42a6-a2ac-6e4ff29c350d)


**After**

![after](https://github.com/vercel/next.js/assets/22380829/b27354f6-bcdb-4cad-888c-7d6b143e0ee2)
2023-05-23 08:32:05 -07:00
Tobias Koppers
3d40cb01ab
refactor webpack loaders (#49535)
### What?

* allow to apply existing pipeline
* change webpack loader key to glob for more flexibility
* add test cases
* add special error message when using the old config syntax

Old config:

```js
experimental: {
 turbo: {
  loaders: {
   ".mdx": ["mdx-loader"]
  }
 }
}
```

New config

``` js
experimental: {
 turbo: {
  rules: {
   // key is a glob now
   // normal syntax will treat the result as ecmascript code
   "*.mdx": ["mdx-loader"],
   // glob allows more advanced matching
   "./images/**/*.png": {
    loaders: ["image-optimize-loader"],
    // result of loader will be handled in other steps
    // under the same name/path (here .png)
    // This will use the existing .png pipeline (static asset)
    // It might also use other rules matching .png.
    as: "*"
   },
   "*.generate-image.js": {
    loaders: ["image-generation-loader"],
    // It also possible to pass this under a different name
    // into the pipeline. Here it will treat the result as png image
    as: "*.png"
   }
  }
 }
}
```

### Why?

More flexibility and allowing to use the builtin module handling over
non-js types.

fixes WEB-1009

### Turbopack changes

* https://github.com/vercel/turbo/pull/4955 <!-- OJ Kwon -
refactor(turbopack-ecmascript): deprecate enable_emotion, enable_styled*
-->
* https://github.com/vercel/turbo/pull/4880 <!-- Tobias Koppers -
refactor webpack loader execution -->

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-05-23 17:21:25 +02:00
Jiachi Liu
ad79fed1a2
ci: update github token (#50216)
[slack-thread](https://vercel.slack.com/archives/C01LN7C5QR5/p1684849596794369?thread_ts=1684428058.764599&cid=C01LN7C5QR5)
2023-05-23 07:29:58 -07:00
Tim Neutkens
03d6dcc08d
Move debugging variable into useEffect (#50210)
## What?

Ensures the debugging variables are only assigned when the values
change.

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

## For Contributors

### Improving Documentation or adding/fixing Examples

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

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md



## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->
2023-05-23 13:41:01 +02:00
vercel-release-bot
fa9c6021b4 v13.4.4-canary.3 2023-05-23 11:17:35 +00:00