Commit graph

328 commits

Author SHA1 Message Date
Will Binns-Smith
a6631d994f
Turbopack + Relay: correctly implement artifact_directory to fix multi-project test (#67403)
Previously, if `artifact_directory` were set, artifacts would be
resolved at a fixed location relative to each file. This correctly
resolves them from the project root.

Test Plan: `TURBOPACK_BUILD=1 TURBOPACK=1 pnpm test-dev
test/integration/relay-graphql-swc-multi-project/test/index.test.js`

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2024-07-04 14:52:45 +00:00
Benjamin Woodruff
d19862ad0f
[chore] Update turbopack to turbopack-240703.1 (#67406)
Tobias Koppers - fix typo (vercel/turbo#8619)
Benjamin Woodruff - Store aggregate read/execute count statistics
(vercel/turbo#8286)
Tobias Koppers - box InProgress task state (vercel/turbo#8644)
Tobias Koppers - Task Edges Set/List (vercel/turbo#8624)
Benjamin Woodruff - Memory: Use `triomphe::Arc` for `SharedReference`
(vercel/turbo#8622)
Will Binns-Smith - chore: release npm packages (vercel/turbo#8614)
Will Binns-Smith - devlow-bench: add git branch and sha to datapoints
(vercel/turbo#8602)

---

Fixes a `triomphe` package version conflict between turbopack and swc by
bumping it from 0.1.11 to 0.1.13.
2024-07-02 21:45:54 -07:00
hrmny
18b13e04f5
fix(turbopack): add no-op resolveAbsolutePath to browser runtime (#67215)
### What?

The turbopack browser runtime was throwing an error when trying to
access `import.meta.url`.


Closes PACK-3095
Fixes https://github.com/vercel/next.js/issues/66005
2024-06-26 19:18:33 +00:00
Tim Neutkens
5999c78a4b
Upgrade Turbopack (#67209)
* https://github.com/vercel/turbo/pull/8546 <!-- Benjamin Woodruff -
Decrease default scope_stress test size, add env var config -->
* https://github.com/vercel/turbo/pull/8563 <!-- Donny/강동윤 - Update
`swc_core` to `v0.95.4` -->
* https://github.com/vercel/turbo/pull/8556 <!-- Tobias Koppers - avoid
cloning the source code -->
* https://github.com/vercel/turbo/pull/8562 <!-- Will Binns-Smith - HMR:
handle non-Latin characters in text through base64-encoded sourcemaps
-->
* https://github.com/vercel/turbo/pull/8530 <!-- Benjamin Woodruff -
Support turbo tasks inside of `mod` blocks -->
* https://github.com/vercel/turbo/pull/8542 <!-- Benjamin Woodruff -
Handle `#[cfg(...)]` attributes on turbo tasks -->
* https://github.com/vercel/turbo/pull/8529 <!-- Benjamin Woodruff -
Deduplicate persistent task get_function_name logic -->
* https://github.com/vercel/turbo/pull/8547 <!-- Benjamin Woodruff - Add
new ExitHandler API as an alternative to ExitGuard -->
* https://github.com/vercel/turbo/pull/8604 <!-- Benjamin Woodruff -
Delete unused TASK_ID_MAPPING support -->
* https://github.com/vercel/turbo/pull/8605 <!-- Benjamin Woodruff -
Remove nohash-hasher dependency -->
* https://github.com/vercel/turbo/pull/8559 <!-- Tobias Koppers - move
stateful flag into Done state -->
* https://github.com/vercel/turbo/pull/8598 <!-- Tim Neutkens - MDX
support: Ensure development transform is only used in development -->
* https://github.com/vercel/turbo/pull/8557 <!-- Tobias Koppers - reduce
size of task output struct -->
* https://github.com/vercel/turbo/pull/8558 <!-- Tobias Koppers - remove
prepared task type -->


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

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating 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 #

-->
2024-06-26 14:11:23 +02:00
Will Binns-Smith
f03fed0458
Update Turbopack to turbopack-240621.2 (#67110)
Includes:
- vercel/turbo#8562
- vercel/turbo#8556
- vercel/turbo#8563
- vercel/turbo#8546
2024-06-24 09:55:54 -07:00
Donny/강동윤
612fd29ded
Update swc_core to v0.95.4 (#67082)
### What?

This PR updates swc_core from
e640972dae
to
60ae1f75b5


### Why?

To keep in sync and apply performance improvements of SWC.

### How?
2024-06-22 01:58:11 +09:00
Tim Neutkens
b515bbc4bb
Upgrade Turbopack (#67017)
Upgrades Turbopack

* https://github.com/vercel/turbo/pull/8421 <!-- Tim Neutkens - Fix
Turbopack benchmark for next@canary -->
* https://github.com/vercel/turbo/pull/8396 <!-- Tim Neutkens - Rename
dev_runtime to browser_runtime -->
* https://github.com/vercel/turbo/pull/8397 <!-- Tim Neutkens - Rename
runtime/none to runtime/edge -->
* https://github.com/vercel/turbo/pull/8398 <!-- Tim Neutkens - Remove
unused Node.js runtime -->
* https://github.com/vercel/turbo/pull/8399 <!-- Tim Neutkens - Rename
build runtime to nodejs -->
* https://github.com/vercel/turbo/pull/8400 <!-- Tim Neutkens - Rename
dev runtime to browser -->

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

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating 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 #

-->
2024-06-20 09:26:01 +02:00
Donny/강동윤
e931ec671c
build: Update swc_core to v0.95.2 (#66902)
# Turbopack

* https://github.com/vercel/turbo/pull/8473 <!-- Donny/강동윤 - feat: Check
the number of direct dependants while tree shaking -->
* https://github.com/vercel/turbo/pull/8420 <!-- Tobias Koppers - Tree
Shaking grouping of items -->
* https://github.com/vercel/turbo/pull/8510 <!-- Tobias Koppers - read
larger chunks when reading a trace file -->
* https://github.com/vercel/turbo/pull/8509 <!-- Tobias Koppers - avoid
duplicates in primary_modules -->
* https://github.com/vercel/turbo/pull/8508 <!-- Tobias Koppers - only
create spans for nodes that are actually visited -->
* https://github.com/vercel/turbo/pull/8502 <!-- Donny/강동윤 - build:
Update `swc_core` to `v0.95.2` -->


### What?

Update `swc_core`.

- [CHANGELOG](064af5391d/CHANGELOG.md (160---2024-06-15))


### Why?

I improved the performance of the parser by margin.
2024-06-18 03:27:52 +00:00
Tobias Koppers
70df7cfb01
[Turbopack] improve memory measurement suite (#66748)
### What?

* adds next-build-test to the workspace
* use multiple turbo-tasks root tasks to be more realistic
* add tracing support
* run pages in order
* add development mode with HMR
* updates for RcStr

### Why?

### How?
2024-06-15 10:04:29 +00:00
Benjamin Woodruff
0b1209edfa
Revert "Revert "Use turbo-tasks-malloc on all platforms" (#66884)", fix aarch64 compilation in CI (#66885)
We either need GCC >= 4.9 or we need to link with libatomic:
https://github.com/microsoft/mimalloc/issues/443

Unfortunately, manylinux2014-cross ships with GCC 4.8.5:
https://github.com/rust-cross/manylinux-cross/blob/main/manylinux2014/aarch64/Dockerfile#L71

We already appear to override the compiler toolchain in CI for x86_64 to
use clang (which is why mimalloc works there), so let's go ahead and do
that here too. This at least means we're using the same compiler across
both architectures.

I'm leaving the aarch64-musl codepath the same (using gcc) because (1)
we don't use mimalloc there yet and (2) it's a bit harder for me to test
as thoroughly.

# Testing

## Local Compilation

Run bash inside the docker image (I also had to install rosetta2 inside
my Linux VM, as this is an x86_64 image used for cross-compilation to
aarch64):

```
podman run --platform=linux/amd64 -t -i ghcr.io/napi-rs/napi-rs/nodejs-rust:stable-2023-09-17-aarch64 bash -l
```

```
git clone https://github.com/vercel/next.js.git --filter=blob:none --branch canary --single-branch
cd next.js
git checkout 6ae9828cce
```

Run the build locally:

```
apt update &&
apt install -y pkg-config xz-utils dav1d libdav1d-dev &&
export JEMALLOC_SYS_WITH_LG_PAGE=16 &&
rustup show &&
rustup target add aarch64-unknown-linux-gnu &&
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" &&
export CC_aarch64_unknown_linux_gnu=/usr/bin/clang &&
export CFLAGS_aarch64_unknown_linux_gnu="--target=aarch64-unknown-linux-gnu --sysroot=/usr/aarch64-unknown-linux-gnu" &&
cd packages/next-swc && npm run build-native-release -- --target aarch64-unknown-linux-gnu &&
llvm-strip -x native/next-swc.*.node &&
objdump -T native/next-swc.*.node | grep GLIBC_
```

Sanity check that the result is an aarch64 binary

```
$ file native/next-swc.linux-arm64-gnu.node
native/next-swc.linux-arm64-gnu.node: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, not stripped
```

## Verifying the binary works

Copy the next-swc binary into a copy of shadcn-ui I have sitting around:

```
podman cp 4e8f61b17965:/next.js/packages/next-swc/native/next-swc.linux-arm64-gnu.node ~/ui/node_modules/.pnpm/file+..+nextpack+tarballs+next-swc.tar/node_modules/@next/swc/native/next-swc.linux-arm64-gnu.node
```

and then try running the dev server and loading pages from it in the
browser:

```
pnpm --filter=www dev --turbo
```

## In CI


https://github.com/vercel/next.js/actions/runs/9523143080/job/26254016137
2024-06-15 03:39:24 +00:00
JJ Kasper
fd9c524a72
Revert "Use turbo-tasks-malloc on all platforms" (#66884)
Reverting while we investigate further 

Reverts vercel/next.js#66815
2024-06-14 13:36:19 -07:00
Benjamin Woodruff
a00146e001
Use turbo-tasks-malloc on all platforms (#66815)
This was previously disabled on `aarch64-unknown-linux-musl` and `wasm`,
due to compilation errors.
    
I moved the logic to disable `mimalloc` on these platforms into the
`turbo-tasks-malloc` crates in https://github.com/vercel/turbo/pull/8462
(which this PR depends on).
    
In addition to centralizing mimalloc platform support logic, this means
that we can get allocation data from these platforms while using the
system allocator.

**Depends on:** https://github.com/vercel/turbo/pull/8462

Included turbopack changes:
* https://github.com/vercel/turbo/pull/8409 <!-- hrmny -
fix(turbopack-ecmascript-runtime): prevent hanging when top level await
is skipped -->
* https://github.com/vercel/turbo/pull/8466 <!-- hrmny - fix(turbopack):
make external module wrapper return not found instead of panicking -->
* https://github.com/vercel/turbo/pull/8469 <!-- hrmny - fix(turbopack):
add ecmascript options to mdx -->
* https://github.com/vercel/turbo/pull/8447 <!-- Donny/강동윤 - build:
Update `swc_core` to `v0.93.4` -->
* https://github.com/vercel/turbo/pull/8472 <!-- Donny/강동윤 - feat:
Reduce the number of parts created by tree shaking -->
* https://github.com/vercel/turbo/pull/8480 <!-- Will Binns-Smith -
Publish `@vercel/devlow-bench` -->
* https://github.com/vercel/turbo/pull/8481 <!-- Will Binns-Smith -
chore: release npm packages -->
* https://github.com/vercel/turbo/pull/8462 <!-- Benjamin Woodruff -
Update mimalloc, enable for glibc Linux aarch64, explicitly disable for
wasm and musl -->
2024-06-14 04:56:04 +00:00
Donny/강동윤
36192ea36e
build: Update swc_core to v0.93.4 (#66781)
### What?

Update `swc_core` to `v0.93.4`.

### Why?

To apply https://github.com/swc-project/swc/pull/9036 and https://github.com/swc-project/swc/pull/9037. Those PR makes parsing of some files 5x faster.

### How?
2024-06-13 00:37:11 +00:00
Will Binns-Smith
33872bfa1e
Make InvalidImportResolvePlugin a BeforeResolvePlugin (#66622)
https://github.com/vercel/turbo/pull/8165 introduced plugins that
operate before resolving occurs, meaning that plugins like
`InvalidImportResolvePlugin` which never use the initial resolve result
and report issues can avoid that work.

Test Plan: `TURBOPACK_DEV=1 TURBOPACK=1 pnpm test-dev
test/development/acceptance-app/invalid-imports.test.ts`
2024-06-12 22:15:33 +00:00
Tobias Koppers
4398e348ee
use node js chunking context for evaluation (#66710)
### What?

Refactoring to use node.js chunking context for evaluation

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

### Why?

### Turbopack changes

* vercel/turbo#8422
* vercel/turbo#8402
2024-06-12 10:38:28 +00:00
Donny/강동윤
65fd44b892
build: Update swc_core to v0.93.2 (#66698)
# Turbopack

* https://github.com/vercel/turbo/pull/8324 <!-- Tobias Koppers - fix panic in debug mode -->
* https://github.com/vercel/turbo/pull/8395 <!-- Donny/강동윤 - build: Update `swc_core` to `v0.93.2` -->


### What?


Update `swc_core`. 

### Why?

Update `swc_core`. The regression of minifier is fixed by https://github.com/swc-project/swc/pull/9031


### How?
2024-06-11 20:02:10 +00:00
hrmny
6c1d700afc
feat(turbopack-ecmascript): cache external modules with wrapper (#63337)
### What?
This is a fix for a bundle potentially referring to two different
external modules (e.g. `react` because it gets invalided from the
require cache)

See https://github.com/vercel/turbo/pull/7988

### Turbopack Updates
* https://github.com/vercel/turbo/pull/8376 <!-- Tim Neutkens - Rename
ChunkLoading::None to ChunkLoading::Edge -->
* https://github.com/vercel/turbo/pull/8371 <!-- Donny/강동윤 - test: Add
an execution test for `paren_remover` -->
* https://github.com/vercel/turbo/pull/8370 <!-- Tobias Koppers - Tree
Shaking shared state and side effects -->
* https://github.com/vercel/turbo/pull/7988 <!-- hrmny -
feat(turbopack-ecmascript): cache external modules with wrapper -->

Closes PACK-2622
2024-06-10 15:39:40 +00:00
Tobias Koppers
98257314da
Revert "feat: Update swc_core to v0.92.10" (#66640)
Reverts vercel/next.js#66521
2024-06-07 18:23:30 +02:00
Tobias Koppers
c772c9f3d4
update turbopack (#66627)
* https://github.com/vercel/turbo/pull/8347 <!-- Tobias Koppers - Small
tree shaking fix and test case update -->
* https://github.com/vercel/turbo/pull/8348 <!-- Donny/강동윤 - fix: Apply
`paren-remover` while minifying -->
2024-06-07 08:11:36 +00:00
Will Binns-Smith
9c7c92bcab
Update to turbopack-240606.2 (#66606)
Includes:
- https://github.com/vercel/turbo/pull/8346
- https://github.com/vercel/turbo/pull/8344
2024-06-06 21:31:48 +00:00
Tobias Koppers
d028fd1a48
update turbopack (#66575)
* https://github.com/vercel/turbo/pull/8336 <!-- Tobias Koppers - add
client disallowed transform -->
2024-06-05 20:41:27 +00:00
Will Binns-Smith
94d0a3cdb0
Update to turbopack-240605.2 (#66568)
Includes https://github.com/vercel/turbo/pull/8303
2024-06-05 18:12:30 +00:00
Donny/강동윤
3cf225c8ee
feat(turbopack): Introduce RcStr (#66262)
# Turbopack

* https://github.com/vercel/turbo/pull/8272 <!-- Donny/강동윤 - feat:
Update `swc_core` to `v0.92.8` -->
* https://github.com/vercel/turbo/pull/8262 <!-- Alexander Lyon - add
crate to calculate prehashes -->
* https://github.com/vercel/turbo/pull/8174 <!-- Tobias Koppers - use
prehash to avoid rehashing the key in the task cache -->
* https://github.com/vercel/turbo/pull/7674 <!-- Alexander Lyon - [turbo
trace] add ability to filter by value and occurences -->
* https://github.com/vercel/turbo/pull/8287 <!-- Donny/강동윤 - feat:
Update `swc_core` to `v0.92.10` -->
* https://github.com/vercel/turbo/pull/8037 <!-- Alexander Lyon - create
turbo-static for compile time graph analysis -->
* https://github.com/vercel/turbo/pull/8293 <!-- Will Binns-Smith - Sync
Cargo.lock with Next.js -->
* https://github.com/vercel/turbo/pull/8239 <!-- Benjamin Woodruff -
Reduce amount of code generated by ValueDebugFormat -->
* https://github.com/vercel/turbo/pull/8304 <!-- Benjamin Woodruff -
Minor optimizations to the codegen of TaskFnInputFunction -->
* https://github.com/vercel/turbo/pull/8221 <!-- Donny/강동윤 - perf:
Introduce `RcStr` -->


### What?

I tried using `Arc<String>` in
https://github.com/vercel/turbo/pull/7772, but a team member suggested
creating a new type so we can replace underlying implementation easily
in the future.

### Why?

To reduce memory usage.

### How?

Closes PACK-2776
2024-06-05 06:09:28 +00:00
Will Binns-Smith
58019b8684
Sync Cargo.lock with turbo (#66539) 2024-06-04 17:12:45 +00:00
Donny/강동윤
348b7364a6
feat: Update swc_core to v0.92.10 (#66521)
### What?

Update `swc_core`

### Why?

To apply https://github.com/swc-project/swc/pull/9019

It's required to use `swc_ecma_parser/tracing-spans`.

### How?
2024-06-04 16:52:58 +02:00
Will Binns-Smith
b39ae62a3b
Update rust toolchain to nightly-2024-05-31 (#66428)
Depends on https://github.com/vercel/turbo/pull/8256
2024-06-01 03:37:04 +00:00
Will Binns-Smith
fe6ca5e216
Revert "next-swc: Update from tokio 1.32.0 to 1.37.0 (#66087)" (#66391)
This reverts commit 99fff19d97.

See https://github.com/vercel/turbo/pull/8246 for context.
2024-05-31 15:26:25 -07:00
Tim Neutkens
f521cc8fc4
Revert "Reapply "Turbopack: Register react refresh exports in module factory (#8191)"" (#66322)
Reverts vercel/next.js#66298
2024-05-29 13:10:13 +02:00
Will Binns-Smith
d3a5e949a3
Reapply "Turbopack: Register react refresh exports in module factory (#8191)" (#66298) 2024-05-29 13:09:43 +02:00
Will Binns-Smith
f7d3733652
Update turbopack to turbopack-240528.2 (#66293)
This includes an update to lightningcss to 1.0.0-alpha.57

vercel/turbo#7986
vercel/turbo#8218
vercel/turbo#8222
2024-05-28 22:06:20 +00:00
Donny/강동윤
97c92a24f2
feat: Upgrade lightningcss (#66280)
### What?

Update `lightningcss` **crate**.

### Why?

x-ref: https://vercel.slack.com/archives/C04KC8A53T7/p1716896534206159

### How?
2024-05-28 13:49:01 -07:00
Tim Neutkens
216ce33b5b
Implement typeof window inlining for Turbopack (#66128)
## What?

Update: Implemented a feature in Turbopack for `typeof window` inlining:
https://github.com/vercel/turbo/pull/8211. Verified the changes in that
PR + this PR fix the test 💯


Turbopack upgrade:

* https://github.com/vercel/turbo/pull/8081 <!-- Alexander Lyon - add
support for upload speed / remaining in the cache upload step -->
* https://github.com/vercel/turbo/pull/7673 <!-- Alexander Lyon -
[turbo-trace] add additional filter modes for allocs over time -->
* https://github.com/vercel/turbo/pull/8191 <!-- Will Binns-Smith -
Turbopack: Register react refresh exports in module factory -->
* https://github.com/vercel/turbo/pull/8195 <!-- Donny/강동윤 - feat:
Remove lint for `grid-template-areas`" -->
* https://github.com/vercel/turbo/pull/8207 <!-- Benjamin Woodruff -
chore: Remove unused `base16` dependency and dead `hex` wrapper function
-->
* https://github.com/vercel/turbo/pull/8185 <!-- Tim Neutkens - Update
contributing guide to mention snapshot test updating -->
* https://github.com/vercel/turbo/pull/8211 <!-- Tim Neutkens - Add
option for inlining typeof window -->
* https://github.com/vercel/turbo/pull/8214 <!-- Will Binns-Smith -
Revert "Turbopack: Register react refresh exports in module factory
(#8191)" -->

---

Previous PR description::

Implements a failing test for issue #66058.
The test only fails when using Turbopack.

While digging into that issue I found that `typeof window` replacement
is either not applied or does not cause `import()` or `require()` to be
removed. In the reproduction that approach is used to load a particular
package only in Node.js and another only in the browser.

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

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating 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 #

-->
2024-05-26 12:25:40 +02:00
Alexander Lyon
f993ea3d04
add next-build-test binary / library (#64121)
This adds a new target in the next-swc package designed as an entrypoint
for collecting memory benches. Later PRs in the stack add a script to
run the benches and finally a manual-triggered CI step
2024-05-24 15:14:39 +02:00
Benjamin Woodruff
5017a41c75
feat(turbopack): Attempt to detect and warn about slow file IO (#66057)
We'd like to warn users if they have particularly slow file IO, so that they can correct the problem themselves, and don't send us reports of poor performance.

- Feature request: https://vercel.slack.com/archives/C03KAR5DCKC/p1716051650641529
- Tweet about how Bun does this: https://x.com/jarredsumner/status/1637549427677364224
- Bun implementation: 06a9aa80c3/src/install/install.zig (L3038)

**Why 100ms?** Bun used to use 10ms, found it too noisy, and switched to 100ms.

This benchmark should run non-blocking in the background and should not meaningfully slow down server startup (even on slow disks).

## Simulated Testing

I looked around and found https://github.com/schoentoon/slowpokefs/. It hasn't been updated in 10 years, but still seems to build fine.

In a nextjs project directory, turn `.next` into an artifically slow mount point:

```
fusermount -uz .next; rm -rf .next .next.real && mkdir .next .next.real && ~/slowpokefs/slowpokefs -m 50 -M 50 --no-slow-read -F .next.real .next
```

<img width="695" alt="Screenshot 2024-05-21 at 4 14 58 PM" src="https://github.com/vercel/next.js/assets/180404/217d7692-33cf-42b7-bbf7-5a530b9e0df1">

Run `pnpm dev --turbo` and see that the warning is generated.

## "Real World" Testing

The following tests are from a linux VM using virtiofs to connect to a 5400 RPM USB 2.0 HDD with APFS:

Only the .next is on an HDD (bind mount):
Otherwise idle disk: `4.86ms 4.44ms 5.31ms`
Otherwise busy disk (copying files): `69.34ms 53.75ms 25.12ms`

The whole project directory is on the HDD (more realistic):
Otherwise idle disk: `20.29ms 35.61ms 48.12ms`
Otherwise busy disk (copying files): `131.40ms 21.71ms 87.33ms`

Most of the time the threshold was not reached, but the 131.40ms test did trigger the warning!

Fixes PACK-3087
2024-05-23 09:52:33 -07:00
Benjamin Woodruff
99fff19d97
next-swc: Update from tokio 1.32.0 to 1.37.0 (#66087)
Matches the version in turbo, unbreaking our cargo lockfile syncing
mess.
2024-05-23 08:17:15 -07:00
Tim Neutkens
413d1223d8
Upgrade lightningcss, disable grid prefixing (#65986)
## What?

Requires https://github.com/vercel/turbo/pull/8176 first.

Grid scoping in CSS Modules is disabled because Webpack CSS Modules
handling doesn't handle grid currently. This ensures moving from Webpack
to Turbopack doesn't have mismatching behavior around CSS grid.

Fixes #64509
Fixes #63758
Fixes PACK-2976

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

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating 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 #

-->
2024-05-21 19:39:46 +00:00
Will Binns-Smith
5c9949386c
Update lightningcss to 1.0.0-alpha.56 (#66046)
To sync with Turbopack.

x-ref: vercel/turbo#8176
2024-05-21 18:28:59 +00:00
Will Binns-Smith
4ff11d0631
Turbopack: Implement next/font/local with BeforeResolvePlugin and show custom error message (#65870)
Depends on vercel/turbo#8165

This:
- Creates and uses a `BeforeResolvePlugin` to handle requests to
`next/font/local/target.css` instead of `ImportMapping` replacers
- Returns a `ResolveResultItem::Error` which includes a custom
`StyledString` describing the missing font file

Test Plan: `TURBOPACK=1 pnpm test-dev
test/e2e/app-dir/next-font/next-font.test.ts`
2024-05-20 15:46:19 -07:00
Donny/강동윤
138e45cf56
Update turbopack & swc_core (#65450)
### What?

* https://github.com/vercel/turbo/pull/8101 <!-- Tobias Koppers - fix
off-by-one bug while reading heaptrack files -->
* https://github.com/vercel/turbo/pull/8130 <!-- Tobias Koppers -
refactor memory tracking -->
* https://github.com/vercel/turbo/pull/8097 <!-- Donny/강동윤 - build:
Update `swc_core` to `v0.92.5` -->

Update swc_core.


### Why?

To keep in sync and fix styled-jsx issues

### How?

Closes PACK-3042

---------

Co-authored-by: hrmny <8845940+ForsakenHarmony@users.noreply.github.com>
2024-05-17 20:15:51 +02:00
hrmny
25b767eb84
feat(turbopack-ecmascript): use import attributes for annotations (#59370) 2024-05-16 02:58:43 +00:00
Will Binns-Smith
81d5daddf3
Turbopack: Remove EcmascriptChunkingContext (#65716)
Depends on vercel/turbo#8133. See that PR for rationale.
2024-05-15 15:51:08 +00:00
Tim Neutkens
ac6e41292b
Reapply "Implement Turbopack trace server bindings" (#65419) (#65527)
Applies #65419 with the latest version of Turbopack that uses a
different websocket library.

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

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating 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 #

-->


Closes NEXT-3363
2024-05-13 18:59:59 +02:00
Will Binns-Smith
b32946049c
Sync Cargo.lock with Turbo (#65525) 2024-05-08 16:06:39 -07:00
Tobias Koppers
a7ebbdef7e
Turbopack: new graph aggregation (#65206)
* https://github.com/vercel/turbo/pull/8082 <!-- Tobias Koppers - Graph
aggregation refactoring -->
2024-05-08 19:18:09 +00:00
Tobias Koppers
1e127abda4
update turbopack (#65503)
* https://github.com/vercel/turbo/pull/8073 <!-- OJ Kwon -
feat(webpack-loaders): support dummy span interface -->
* https://github.com/vercel/turbo/pull/8083 <!-- OJ Kwon - fix(webpack):
print resource, project path when relative calc fails -->
* https://github.com/vercel/turbo/pull/8094 <!-- Tim Neutkens -
Implement bindings for Turbopack trace server -->
* https://github.com/vercel/turbo/pull/8061 <!-- Tobias Koppers - reduce
memory usage in analyser -->
* https://github.com/vercel/turbo/pull/8077 <!-- Alexander Lyon - Remove
async-trait from a few crates -->
* https://github.com/vercel/turbo/pull/8102 <!-- Tobias Koppers - fix
memory counting without custom allocator -->
* https://github.com/vercel/turbo/pull/8096 <!-- Benjamin Woodruff -
turbo-tasks: Expand `<T as TaskOutput>::Return` values in macros -->
* https://github.com/vercel/turbo/pull/8105 <!-- Benjamin Woodruff -
turbopack-node: Use path.join for postcss loader -->
* https://github.com/vercel/turbo/pull/8099 <!-- Tim Neutkens - Replace
websocket with tungstenite for turbo-trace-server -->
* https://github.com/vercel/turbo/pull/8060 <!-- Donny/강동윤 - feat: Add
lint for `grid-template-areas` -->
* https://github.com/vercel/turbo/pull/8110 <!-- Tobias Koppers - fix
lockfile -->
2024-05-08 12:05:29 +02:00
Tobias Koppers
84602cdf66
make sure children is first in loader tree to fix head css bug on client navigation (#65279)
### What?

make sure children is first in loader tree to fix head css bug on client
navigation

### Why?

### How?

Fixes PACK-3028

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2024-05-08 08:35:25 +02:00
JJ Kasper
aa51bedbbe
Revert "Implement Turbopack trace server bindings" (#65419)
This is failing to compile for some of our targets to reverting to
unblock CI

Reverts vercel/next.js#65410

Closes NEXT-3331
2024-05-06 11:25:38 -07:00
Tim Neutkens
b85210d64e
Implement Turbopack trace server bindings (#65410)
## What?

Implements support for running the Turbopack trace server, which is the
websocket server that powers https://turbo-trace-viewer.vercel.app/ when
using `NEXT_TURBOPACK_TRACING=1 NEXT_TURBOPACK_TRACE_SERVER=1`.

Currently you have to manually run the server through the Turbo
repository which in practice means that only people working on Turbopack
are able to run it.

With the bindings implemented anyone should be able to run the trace
server.

Note that the traces that come out of Turbopack are very low level,
they're meant for optimizing Turbopack like finding slowdowns / large
memory usage / optimizing performance.

However, it's useful for people that want to peek into why their
application is slow to compile. I.e. we've used
https://turbo-trace-viewer.vercel.app to investigate reports in #48748.

This PR adds support for `trace.log` by default, so if you add
`NEXT_TURBOPACK_TRACING=1 NEXT_TURBOPACK_TRACE_SERVER=1` it will
automatically select the `trace.log` for the current instance of
Next.js. You can only have one trace server running at the same time.

### `next internal` 

In order to support running the trace server standalone, which is useful
for investigating trace files other people have shared, I've added a new
subcommand `internal` that is not covered by semver / use at your own
risk. It's meant for internal tools that are useful to be bound to the
version of Next.js, the turbo-trace-server is a great example of that as
it has an internal binary format for storing data that needs to match
the trace.log file.

If you want to take a look at `.next/trace` instead the new `next
internal` subcommand can be used for that:

```sh
# Replace [path] with a path to a file.
next internal turbo-trace-server [path]
```

For example:

```sh
next internal turbo-trace-server ~/Downloads/trace
```

Currently the trace server does not support loading multiple files, just
hasn't been implemented yet. Once we can load two or more files we can
load both `.next/trace` and `trace.log` when
`NEXT_TURBOPACK_TRACE_SERVER=1` and support multiple paths passed to
`next internal turbo-trace-server`.


### Turbopack upgrade


PR includes a Turbopack upgrade:

* https://github.com/vercel/turbo/pull/8073 <!-- OJ Kwon -
feat(webpack-loaders): support dummy span interface -->
* https://github.com/vercel/turbo/pull/8083 <!-- OJ Kwon - fix(webpack):
print resource, project path when relative calc fails -->
* https://github.com/vercel/turbo/pull/8094 <!-- Tim Neutkens -
Implement bindings for Turbopack trace server -->


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

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating 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 #

-->


Closes NEXT-3328
2024-05-06 15:23:40 +00:00
Tim Neutkens
9ec37c120a
Upgrade Turbopack (#65320)
<!-- 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

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating 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 #

-->


Closes NEXT-3311
2024-05-04 13:18:08 +02:00
Tobias Koppers
77706b68a7
Turbopack: rename source map prefix (#64965)
### What?

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

### Why?

### How?
2024-05-01 05:21:50 +00:00