Commit graph

2150 commits

Author SHA1 Message Date
vercel-release-bot
6fd3c3b992 v14.0.4-canary.21 2023-11-28 17:00:46 +00:00
vercel-release-bot
113a125a93 v14.0.4-canary.20 2023-11-28 16:44:35 +00:00
Leah
9c79186610
fix(turbopack): add list of packages that should never be marked as e… (#59020)
### What?

Turbopack was missing the list of modules / requests that should never
be marked as external:

8d1c619ad6/packages/next/src/build/handle-externals.ts (L188)

This could lead to errors with i.e. `next/image` not receiving the
correct image config.

Closes PACK-2047

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-11-28 17:41:28 +01:00
OJ Kwon
048ab21f6b
fix(turbopack): treat .mdx as valid ecma asset (#58985)
### What

Pairing with https://github.com/vercel/turbo/pull/6602, enables
ecma-related transform support in mdx. notably fixes test cases in
https://github.com/vercel/next.js/pull/58968 .

With turbopack side fix, still modularize imports are not being applied
as we limite it to .js* extension only. PR expands it to include mdx if
mdx is enabled. PR is failling until turbopack side fix lands.

Closes PACK-2045

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-11-28 13:54:46 +01:00
vercel-release-bot
7ff3e3e32d v14.0.4-canary.19 2023-11-27 23:22:35 +00:00
Tobias Koppers
f1511515fd
Trace server updates (#58694)
### What?

some refactoring updates


Closes PACK-1994
2023-11-27 15:29:41 +01:00
Donny/강동윤
8e6d51f4fa
Update swc_core to v0.86.81 (#58517)
### What?

Update swc crates.

Diff:
09b3003e58...c566b73bfb

### Why?

To fix bugs, and improve minification.

### How?

turbopack counterpart: https://github.com/vercel/turbo/pull/6472

- Closes PACK-1972

- Closes #30802

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-11-27 11:02:25 +01:00
vercel-release-bot
7874ad2659 v14.0.4-canary.18 2023-11-26 23:21:26 +00:00
Tobias Koppers
9f69766cfa
Turbopack: enable some node.js builtin in edge runtime (#58850)
### What?

Edge runtime allow additional node.js builtins

see https://github.com/vercel/turbo/pull/6562


Closes PACK-2031

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2023-11-26 19:55:23 +01:00
vercel-release-bot
12a683b925 v14.0.4-canary.17 2023-11-25 23:21:36 +00:00
vercel-release-bot
f6070c807b v14.0.4-canary.16 2023-11-24 23:21:37 +00:00
vercel-release-bot
1496d50f68 v14.0.4-canary.15 2023-11-24 19:37:49 +00:00
Tobias Koppers
4465b1856f
fix uniqueness of layers (#58872)
### What?

* rename `ssr` in app to `app-ssr`
* rename `_` to `-` in layer names

### Why?

`ssr` layer name was used twice, but it must be unique to avoid hanging
compilation


Closes PACK-2036
2023-11-24 17:53:28 +01:00
Dima Voytenko
b8a18f6e13
OpenTelemetry: propagate context to sandbox (#58791)
The sandboxed request processing do not share the same async context with the `BaseServer` and thus the context should be propagated independently.

Notably, the `headers` API is different in `BaseServer` (`Record<string, string | string[]>`) vs in the sandbox (`Headers`), so additionally, we have to use the right `getter`.

Co-authored-by: Leah <8845940+ForsakenHarmony@users.noreply.github.com>
2023-11-24 15:02:19 +00:00
vercel-release-bot
b27a3525c7 v14.0.4-canary.14 2023-11-24 13:41:03 +00:00
Tobias Koppers
2e28fa113e
Turbopack: align automatic externals code with webpack (#58851)
### What?

* remove the additional check which verifies identity of resolved and
external module.
* `serverComponentsExternals` will force it being an external

### Why?

### How?


Closes PACK-2032

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2023-11-24 12:16:13 +01:00
vercel-release-bot
6bfd1458b2 v14.0.4-canary.13 2023-11-23 23:22:46 +00:00
vercel-release-bot
936becb8b6 v14.0.4-canary.12 2023-11-23 15:15:06 +00:00
Tim Neutkens
f514684bbc
Enable .mjs extension config in Turbopack (#58825)
Enable `.mjs` resolving in Turbopack to match the current webpack config.

Added an additional tests for this.
2023-11-23 14:17:36 +00:00
Tobias Koppers
2f07579a50
place virtual module inside the project directory (#58798)
### What?

This virtual module was created in a weird path/filesystem: [node]/.next/server/app/.../page/actions.js. It's in the output filesystem, which can't access the monorepo root, so it can't resolve the tsconfig. But it shouldn't be in that filesystem in first place.


Closes PACK-2025
2023-11-22 23:57:42 +00:00
vercel-release-bot
0155ec70d7 v14.0.4-canary.11 2023-11-22 23:22:02 +00:00
vercel-release-bot
8f9e494cb5 v14.0.4-canary.10 2023-11-22 12:48:53 +00:00
Will Binns-Smith
154268a144
Turbopack: Use styled issue titles and details (#58743)
This uses styled issue titles and details introduced in
vercel/turbo#6535, which also moves "Module not found" messaging to the
title field for those issues.


Closes PACK-2013

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
Co-authored-by: Leah <github.leah@hrmny.sh>
Co-authored-by: Zack Tanner <zacktanner@gmail.com>
2023-11-22 13:39:24 +01:00
vercel-release-bot
c0bafcb354 v14.0.4-canary.9 2023-11-22 02:11:25 +00:00
vercel-release-bot
f6b50ae32b v14.0.4-canary.8 2023-11-21 23:22:46 +00:00
Tobias Koppers
3467116794
fix node externals resolving (#58129)
### What?

Various fixes in handling of externals in node.js

* add extensions to builtin externals to allow node.js ESM to work
* improve the auto-externals logic to detect more edge cases
* prepare for `esmExternals` support, but that's blocked by client
manifest missing the async flag
* currently only `esmExternals: false` is supported

### Why?

### Turbopack Changes

* https://github.com/vercel/turbo/pull/6531 <!-- Leah - fix(turbopack):
postcss should be applied to `@import`ed CSS files -->
* https://github.com/vercel/turbo/pull/6530 <!-- Tobias Koppers - fix
node.js externals -->

---------

Co-authored-by: Leah <github.leah@hrmny.sh>
Co-authored-by: Zack Tanner <zacktanner@gmail.com>
2023-11-21 23:58:14 +01:00
vercel-release-bot
8b11264ea9 v14.0.4-canary.7 2023-11-21 19:04:07 +00:00
Shu Ding
9471fb854f
Improve Server Actions compiler (#58391)
Currently to make inline-defined Server Actions work, the compiler hoists the actual `"use server"` function to the module level and convert the inlined function to a parentheses expression that creates a noop wrapper function and wraps it with the proxy. This works fine however expressions are still different from declarations (#57392). So there're some details that can't be aligned well.

With this change, we're going to make the compilation for the two types of inline-defined Server Actions more robust and more lightweight:

#### 1. Expressions

```jsx
const action = async () => { "use server" ... }
const action = async function () { "use server" ... }
const action = async function named () { "use server" ... }
foo={async function () { "use server" ... }}
...
```

These expressions can directly be replaced with a new expression `createActionProxy("id", hoisted_action)`. A `.bind(...)` member call can be followed if it needs to bind any variables from the closure level.

#### 2. Declarations

```js
async function named () { "use server" ... }
```

In this case, we replace all the same `named` idents to be the expression `createActionProxy("id", hoisted_action)`, and removed that function declaration.

With these changes, these will be fewer structural changes to the AST and the code is more performant.

The PR also changes it to use React's `registerServerReference` method directly instead of our in-house implementation inside `createActionProxy`.

Another small change is to stabilize the comment header to use `BTreeMap` inside the SWC transform. Otherwise the test snapshots will randomly mismatch.

Closes #57392.
2023-11-21 13:35:10 +00:00
vercel-release-bot
0a4f26f1ef v14.0.4-canary.6 2023-11-20 23:22:25 +00:00
Donny/강동윤
94771bf3cc
refactor: Add lightningcss mode for turbopack-css (#58471)
### What?

We are experimenting with `lightningcss`. This is about replacing
`swc_css` with `lightningcss` in turbopack, and the main reason for this
is to reduce the maintenance burden.
But when I tried, it introduced several regressions, so I'm putting it
behind an experimental flag.

You can enable `lightningcss` mode for **turbopack** by adding a flag to
the next config file.

```js
/**
 * @type {import('next').NextConfig}
 */
const nextConfig = {
  experimental: {
    useLightningcss: true,
  },
}

module.exports = nextConfig

```

Note that this is only for turbopack because we were not using `swc_css`
for non-turbopack mode of next.js



x-ref:
https://vercel.slack.com/archives/C03EWR7LGEN/p1700025496732229?thread_ts=1700019629.866549&cid=C03EWR7LGEN


### Why?

We should avoid regressions.

### How?

---

turbopack PR: https://github.com/vercel/turbo/pull/6456


Closes PACK-1966

---------

Co-authored-by: Leah <github.leah@hrmny.sh>
2023-11-20 18:09:36 +01:00
vercel-release-bot
32c9ce6805 v14.0.4-canary.5 2023-11-19 23:21:38 +00:00
vercel-release-bot
43b075eb7e v14.0.4-canary.4 2023-11-18 23:21:24 +00:00
Will Binns-Smith
024a0ef24d
Update rust-toolchain to 2023-11-16 (#58558)
This updates the rust toolchain to 2023-11-16 and:

- Removes now-unnecessary `#![feature(async_fn_in_trait)]`
- Applies auto-fixable lint fixes
- Uses `Cargo.toml` new `lint` section instead of command line rustc flags

Test Plan: Tested with updated turbo in a create-next-app


Closes PACK-1979

Co-authored-by: OJ Kwon <1210596+kwonoj@users.noreply.github.com>
2023-11-18 00:29:50 +00:00
vercel-release-bot
c0e5d6584d v14.0.4-canary.3 2023-11-17 23:22:09 +00:00
OJ Kwon
1f3178e743
fix(next-core): allow runtime segment option in pages/api (#58409)
### What

This PR fixes turbopack to allow runtime segment option (https://nextjs.org/docs/app/building-your-application/rendering/edge-and-nodejs-runtimes#segment-runtime-Option) in pages/api. 

Previously it only allows config object (https://nextjs.org/docs/app/building-your-application/routing/middleware#matcher), so the single runtime export like `export const runtime = 'edge'` didn't work. PR updates logic to parse config in the module to allow single segment export as well.

It doesn't allow _both_, if config object is exported it'll short-curcuit to read values as config object should able to specify runtime without separate runtime segment.

Closes PACK-1961
2023-11-17 20:59:01 +00:00
vercel-release-bot
6984ac4b86 v14.0.4-canary.2 2023-11-17 15:05:24 +00:00
vercel-release-bot
82beef92a4 v14.0.4-canary.1 2023-11-16 23:22:02 +00:00
Justin Ridgewell
85a77c4c34
turbopack: Fix pageExtensions with dots (#58504)
### What?

Fixes finding Page/App pages when using a `pageExtension` that itself contains a `.`. Eg, `pages/index.page.js` should match as a Page when using `pageExtensions: ["page.js"]`

### Why?

Matching webpack configurations.

### How?

We split in reverse direction, meaning we'd have a `(basename, ext)` of `('index.page', 'js')`. Webpack [uses forward splitting](9ab8828f72/packages/next/src/build/webpack/loaders/next-metadata-route-loader.ts (L27-L31)), giving a proper `('index', 'page.js')`.

Closes PACK-1970
Fixes https://github.com/vercel/turbo/issues/6106
Fixes https://github.com/vercel/next.js/issues/57603
2023-11-16 23:03:27 +00:00
vercel-release-bot
1ae13b5d9f v14.0.4-canary.0 2023-11-16 21:40:51 +00:00
vercel-release-bot
391471b315 v14.0.3 2023-11-16 18:37:33 +00:00
vercel-release-bot
32875e4fe4 v14.0.3-canary.12 2023-11-16 16:00:52 +00:00
Jiachi Liu
d6d6d56133
Remove client only dynamic chunks from edge bundle (#56761)
### Issue

In the client components world, when you're using `next/dynamic` with `ssr: false` to split chunks in pages of edge runtime, you could get the dynamic imported module still bundled in the server bundle for edge runtime. This could easily hit the bundle limit on edge runtime if you're loading a large size of non-SSR module.

This is caused by the whole chunk is still being included when we're creating the client entry. Since the client entry is imported eagerily, webpack will bundle all the modules under it, unless it's explicitly marked not being included.

### Fix

For client components, SSR rendering layer of bundle, non-SSR `next/dynamic` calls, we're transform the result of `dynamic()` call from to conditional import the dynamic loaded module.

From
```js
dynamic(() => import(...))
```
To
```js
dynamic(() => {
  require.resolveWeak(...)
}, { ssr: false })
```

This will only be applied to SSR layer bundle client components non-SSR `next/dynamic` calls and only when webpack is bundling since turbopack doesn't need this. In this way, the server side will be stripped but it can still enter the module graph since we need to traverse if there's SA in client modules with using webpack API `require.resolveWeak`. And for client side bundle will still include the actual module.

Close NEXT-1703
2023-11-16 15:10:28 +00:00
vercel-release-bot
c8bfda4367 v14.0.3-canary.11 2023-11-15 23:22:09 +00:00
Will Binns-Smith
5f8be1f0d3
Turbopack: Use structured styled text in issue descriptions (#58156)
Requires vercel/turbo#6388

This uses the structure implemented in vercel/turbo#6388 to support formatted text when reporting. Right now only the `Line` and basic `String` cases are handled.
2023-11-15 22:33:14 +00:00
vercel-release-bot
a5515693bc v14.0.3-canary.10 2023-11-15 21:51:36 +00:00
Will Binns-Smith
9ab8828f72
Apply next/font to foreign code (#58461)
This applies next/font to third party code like that in `node_modules`


Closes PACK-1964
2023-11-15 18:52:09 +00:00
vercel-release-bot
7281cd3fc4 v14.0.3-canary.9 2023-11-15 13:00:05 +00:00
Justin Ridgewell
52e8c4d10b
turbopack: Don't error with legacy server actions boolean (#58416)
### What?

This stops Turbopack from erroring out when trying to parse apps using NextConfig's legacy `experimental.serverActions` boolean value.

### Why?

Old apps may not have removed the legacy boolean flag, but should still run.

### How?

At first I attempted updating Zod's configuration to use a default option config when a boolean was encountered, and passing the updated config to Turbopack, but this would hide the warning message. Then I tried implementing a custom `Deserializer` on the Rust side to handle boolean values and default. But, it was just so much easier to implement with a enum supporting both the current and the legacy configuration.

Closes PACK-1962
2023-11-15 04:33:14 +00:00
vercel-release-bot
44613dc045 v14.0.3-canary.8 2023-11-14 23:23:29 +00:00
vercel-release-bot
08e5424ddc v14.0.3-canary.7 2023-11-14 10:25:41 +00:00