Commit graph

48 commits

Author SHA1 Message Date
OJ Kwon
72af59a1c1
build(cargo): bump up turbopack (#59032)
### What?

Bump up turbopack which includes url rewrite related improvements. This makes `test/integration/url` test passes.

Note there are some lacking behavior around edge runtime + url behavior, it is being tracked in PACK-2014.

Closes PACK-2051
2023-11-28 20:42:26 +00:00
Leah
bb3d5cf4c3
fix(turbopack): e2e/404-page-router test (#58146) 2023-11-22 19:30:26 +01: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
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
Zack Tanner
24b2ff16ab
remove optimistic navigation behavior when prefetch is false (#58413)
### What?
When navigating between pages (via `prefetch: false`) within a dynamic
segment, the shared layout is re-rendered. This can cause unexpected
behavior like layout data changing when navigating between child
segments.

### Why?
When prefetch is false, we're currently opting into an "optimistic
navigation" codepath, which will optimistically render layout-routers up
to the point where data is missing, while kicking off data fetches. It
attempts to determine where refetching needs to happen by traversing the
router cache nodes and checking where data is missing. However, it
locates these cache nodes by using "segments" obtained by
[deconstructing the
URL](https://github.com/vercel/next.js/blob/fix/optimistic-bailout/packages/next/src/client/components/router-reducer/reducers/navigate-reducer.ts#L142),
which won't accurately contain dynamic segment data. For ex, `/en` which
corresponds with `/app/[lang]/page.tsx` will have a cache node key of
`lang|en|d`, not `en`. Similarly, the optimistic tree that gets
constructed will also be incorrect, since it uses the URL segment.

### How?
My initial fix was to match the dynamic segment against the segment
constructed by the URL. But after discussion with @sebmarkbage and the
team, it seems more correct to remove the optimistic case all together
as there's no guarantee that the url will actually match to that
segment.

Fixes #50670

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-11-16 11:58:17 +01: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
Tobias Koppers
1ee50b8e57
add test case to failing list for turbopack (#58435) 2023-11-14 15:22:03 +01:00
Leah
b2c926f7c2
fix(turbopack): support middleware in src (#58218)
### What?

We previously marked `/src/middleware` as a missing page

Fixes #42921

Closes PACK-1926

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-11-10 14:48:20 +01:00
Leah
25bc6afa1f
fix(ci): exclusion regex now actually works instead of ignoring all tests (#58259) 2023-11-09 21:43:35 +01:00
OJ Kwon
e65d4a1be3
fix(next-core): correct assets url reference condition (#58101)
### What

Corrects how urlassetreference reads its assets path to allow to resolve image assets correctly.

There is a test failure in the integration/url still, that involves probably larger refactoring so making this PR first to enable baseline, ensure further refactoring does not breaks anything.
2023-11-07 16:12:41 +00:00
Vercel Release Bot
da0f2ea11a
Update Turbopack test manifest (#58122)
This auto-generated PR updates the integration test manifest used when testing Turbopack.

Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com>
2023-11-07 14:33:43 +00:00
Will Binns-Smith
c95ef234fc
Move ReactRefreshLogBox-builtins tests to inline snapshots (#57952)
This avoids separate snapshots for both Turbopack and Webpack, and correctly reflects that these fail.
2023-11-02 21:32:52 +00:00
OJ Kwon
cce9f0d34f
fix(metadata): align metadata suffix hash between turbopack (#57544)
### What?

Wraps up metadata-dynamic-routes tests fixes for the turbopack. There is 1 remaining failing test due to lacks of supporting `import.meta.url` which need to be addressed separately.

I spent amount of time why turbopack cannot find the route for the dynamic metadata for a certain route. In the end, found there are mismatching expectations for the route due to different hash for the certain route. We do use the same djb2 hash between next.js and turbopack both, so it was quite confusing why we don't get deterministic hash.

After trying some experiments, found out root cause was how 2 different runtimes handle overflow for given type of numbers. In rust + turbpack we use u32 and do 32-bit hash calculation for given string, while in js we implicitly used number type as is, in result overflow occurs with default 53-bit float. 

Originally I tried to adjust hash in turbopack side to preserve js hash as-is, but so far I found it was non trivial to do so as rust there's no out of the box types we can coerce to the js number type. In result, unlike other fixes in turbopack this PR changes how js hash is being generated. I hope this woulndn't be a breaking changes; expect so since this is a metadata specific hash that we do not have written spec for it.

Closes WEB-1890
2023-10-30 19:56:55 +00:00
Tobias Koppers
27bfd2d230
update manifest (#57523)
update test manifest from daily test run

Closes WEB-1889
2023-10-26 20:35:50 +00:00
Justin Ridgewell
df0fb70c8c
turbopack: Support Actions in both RSC and Client layers (#57475)
### What?

Adds support for Server Actions imported by both server and client.

### Why?

If an Action is imported by both the Client and RSC layers, we need to
support them as if they're the same action.

### How?

First, we need to ensure both layers create the same action hash ids,
which we can then use to deduplicate actions imported by both layers. If
a conflict is found, we prefer the RSC layer's action.

Closes WEB-1879

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-10-26 08:32:04 +02:00
Leah
74311274db
Revert "fix turbopack invalidations (#57362)" (#57480)
### Why?

breaks hmr and causes some duplicate react instances (it was also
supposed to fix some of those, seems neither version is correct)

Closes WEB-1882
2023-10-26 08:14:11 +02:00
Tobias Koppers
001abee56c
update manifest (#57468)
update manifest for daily test run

Closes WEB-1876
2023-10-26 07:21:59 +02:00
Leah
c80fb27446
fix turbopack invalidations (#57362)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-10-26 07:04:04 +02:00
Justin Ridgewell
7c0e66f8d8
turbopack: Fix Server Actions in Edge runtime (#57462)
### What?

Changes Server Actions to use a lazy `require()` statement instead of a
lazy dynamic `import()`, to fix SA in the Edge runtime.

### Why?

The Edge runtime has a restriction that it's not allowed to lazy load
more files. The problem is that dynamic `import()` does exactly that, it
defers importing those files until the call time. `require()` doesn't
have this issue, because the chunks it would load are included instead
of deferred.

### How?

Just needed to modify the actions loader entry point… after hours of
trying to get the action loader to evaluate in the node runtime and then
import the actions in the edge runtime.


Closes WEB-1874
2023-10-26 05:51:11 +02:00
Leah
c616582d4b
feat(turbopack): add support for parallel routes and route interception (#57450)
### What?

We have to walk the directory tree recursively for every page (instead
of once) to get the correct loaderTree.

With this PR we walk the directory tree and for every
`page.(js,jsx,ts,tsx)` (entrypoint) we find we walk it again to get the
loader tree for that page


Closes WEB-1868
Closes WEB-1609
2023-10-25 18:50:00 -07:00
OJ Kwon
0f55e292cf
fix(next-core): fix determining dynamic route (#57435)
### What

Fixes how to determine if given route is dynamic to match next-dev does:

462b8585b6/packages/next/src/lib/metadata/get-metadata-route.ts (L79)

We were passing calculated route instead to check if it's dynamic, so
`/sitemap` always considered as static since calculated route is
`/sitemap.xml`.

Closes WEB-1864

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-10-26 01:29:39 +02:00
Tobias Koppers
462b8585b6
enable e2e tests with turbopack (#57432)
Closes WEB-1862

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-10-25 19:46:31 +02:00
Tobias Koppers
509b88ae4c
update manifest (#57421)
update manifest from daily test run

Closes WEB-1856
2023-10-25 16:41:30 +02:00
OJ Kwon
8433970213
test(next-image): adjust assertion compatible to turbopack (#57350)
### What

Updating test assertions to work with turbopack as well.


Closes WEB-1843
2023-10-24 22:25:57 +00:00
OJ Kwon
a3e771a338
test(turbopack): update test manifest (#57366)
### What

Enabling test from https://github.com/vercel/next.js/pull/57300. There may be some other test cases passing by fix, but this is the known direct offending test can be enabled.

Closes WEB-1847
2023-10-24 21:55:38 +00:00
Zack Tanner
8461071d83
update turbopack test manifest (#57357) 2023-10-24 22:33:38 +02:00
OJ Kwon
cad1200131
fix(next_core): align remove trailing slash (#57344)
### What

minor fix to match behavior to ae10b5c82b/packages/next/src/shared/lib/router/utils/remove-trailing-slash.ts (L2C4-L9)

as we're seeing a panic when route is /

```
Panic: PanicInfo { payload: Any { .. }, message: Some(byte index 1 is out of bounds of ``), location: Location { file: "packages/next-swc/crates/next-core/src/next_edge/route_regex.rs", line: 202, col: 59 }, can_unwind: true, force_no_backtrace: false }
Backtrace:    0: backtrace::backtrace::libunwind::trace
```

Closes WEB-1841
2023-10-24 19:56:55 +00:00
Tobias Koppers
cf79cbf3b3
update test manifest (#57105)
update test manifest from daily test run

Closes WEB-1809
2023-10-22 19:00:00 +00:00
Josh Story
5528cc6d4e
Remove the experimental serverActions flag (#57145)
Remove the experimental `serverActions` flag

Co-authored-by: Shu Ding <3676859+shuding@users.noreply.github.com>
Co-authored-by: Jiachi Liu <4800338+huozhi@users.noreply.github.com>
2023-10-20 20:45:25 +00:00
Tobias Koppers
040a4f75e8
update test manifest (#56938)
Update test manifest from daily test run

Closes WEB-1792
2023-10-20 00:43:56 +00:00
Tobias Koppers
04bad16bf4
Turbopack: Chunking Refactoring (#56756)
### What?

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

### Turbopack Changes

* https://github.com/vercel/turbo/pull/6116 
* https://github.com/vercel/turbo/pull/6140 
* https://github.com/vercel/turbo/pull/6118 
* https://github.com/vercel/turbo/pull/6128 
* https://github.com/vercel/turbo/pull/6129 
* https://github.com/vercel/turbo/pull/6160 


Closes WEB-1772

Co-authored-by: Justin Ridgewell <112982+jridgewell@users.noreply.github.com>
2023-10-13 11:44:44 +00:00
Tobias Koppers
e8a92a9507
update manifest (#56737)
### What?

updates from daily test run


Closes WEB-1766
2023-10-13 11:19:54 +02:00
Tobias Koppers
52356a0e14
invert test filtering logic to exclude known failing (#56663)
### What?

instead of include known passing tests

also updates the update test manifest

### Why?

Newly added test cases should always pass turbopack (or at least you would need to manually opt-out of it.

### How?

Uses a exclude list of tests instead of an allow list

Closes WEB-1752
2023-10-10 18:26:40 +00:00
Tobias Koppers
542f080524
update test manifest (#56522)
update manifest from daily results

Closes WEB-1728
2023-10-07 11:07:59 +02:00
Leah
515784c277
chore: pass defineEnv from next.js to rust directly (#56216)
### What?

Deduplicates our env var injection between the JS and rust side

Closes WEB-937

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: Zack Tanner <zacktanner@gmail.com>
2023-10-03 22:43:21 +02:00
Tim Neutkens
b79a11f6ad
Fix mjs import for Turbopack test (#56354)
Turbopack currently supports fully-specified `.mjs` imports. Double
check with @sokra to verify if this is correct.

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

-->
2023-10-03 13:33:04 +02:00
Jiachi Liu
7df92b868a
test: add flaky turbopack integration tests to manifest (#56309) 2023-10-03 00:53:09 +02:00
Tobias Koppers
488fc1c003
clear require cache only when needed (#56198)
### What?

clear require cache only when there has been changes

Before we cleared the require.cache after every ensurePage call. This is
too much. The new approach compares the hashes of all emitted files with
the previous hashes and only clears require.cache when they differ.

### Why?

reloading a page and client navigation is slow due the re-requiring
server files


Closes WEB-1686
2023-10-02 10:57:35 +02:00
Tobias Koppers
b8a63f44dd
update test mainfest (#56214)
Closes WEB-1687
2023-10-02 08:45:50 +02:00
Tobias Koppers
b689f84600
Turbopack: update test manifest (#56133)
Closes WEB-1672
2023-09-28 08:23:26 +02:00
Leah
293de45acf
feat(turbopack): port bloom filter to nexturbo (#55678)
Closes WEB-1096
2023-09-28 01:00:49 +00:00
Tobias Koppers
ef4faa5f9c
add flakey test (#56080)
It's flakey for turbopack

Closes WEB-1671

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-09-27 13:24:35 +02:00
Justin Ridgewell
00d9080da5
turbopack: Add more skipped tests (#56052)
Adds more flakey tests to the skipped turbopack list.

Closes WEB-1662
2023-09-26 22:45:44 +00:00
Tobias Koppers
89c5fdf1e9
Turbopack: update test manifest (#56026)
Update from daily test run

also enabled a lot more tests

marked some tests flakey

Closes WEB-1658
2023-09-26 18:28:48 +02:00
Justin Ridgewell
efd6b682b8
turbopack: only skip known flakey test cases (#55976)
### What?

A follow up to https://github.com/vercel/next.js/pull/55975, this will
list every flakey test in the turbopack suite so that we can run the
remaining passing tests.

### Why?

More tests is more better.

### How?

Trial and error. Gonna let CI tell me what's flakey with a few runs.

Closes WEB-1651
2023-09-26 16:58:34 +02:00
Tim Neutkens
60af1969c5
Remove .test.js from dist (#55946)
Noticed a couple of directories had unit tests in `dist` which are being
run and reported during the Turbopack runs. These are generally quite
small so I'm not expecting this to have much effect on the package size
or CI runs, just making sure the data is correct.
<!-- 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 #

-->
2023-09-25 19:05:07 +02:00
Tim Neutkens
cae7833af4
Ensure Turbopack passing test list is sorted (#55948)
I noticed that running the script to pull in the results wasn't
deterministic between test runs, this ensures the list, passing,
pending, and errors are all sorted, which makes the diff only include
what actually changed between runs.

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

-->
2023-09-25 12:59:26 +02:00
Justin Ridgewell
b0aecccaa2
Allow filtering individual test cases inside test files (#55786)
### What?

Updates `run-test.js` to allow running individual test cases inside a test file.

### Why?

So that we can dramatically increase Turbopack's test coverage. Turbopack has implemented most (but not all) necessary features from the webpack bundles. But a single failing test case would prevent us from running any case inside a test file. With case filtering, we're able to run the cases we know will pass and prevent regressions on those.

### How?

Case filtering is only exposed via the `NEXT_EXTERNAL_TESTS_FILTERS` ENV, which points to a JSON file containing a map of test files with the test cases inside those files that are known to pass.

The known-passing test cases can be updated after Turbopack's daily integration test run by running `test/build-turbopack-tests-manifest.js`, which will update the `test/turbopack-tests-manifest.json` manifest.

Closes WEB-1640

Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com>
2023-09-22 21:37:48 +00:00