Commit graph

15442 commits

Author SHA1 Message Date
Jiachi Liu
fae94416ff
Move modularize imports for next/server to next-swc (#47788)
Follow up for #47715 

Moving modularize imports handlign for next/server into `next-swc` side
2023-04-02 13:00:26 +02:00
JJ Kasper
90ac02f7be
Fix failing rust-check (#47811)
This corrects a failing rust-check that slipped through in
https://github.com/vercel/next.js/pull/47677 due to the check not being
marked as required which it now is.

x-ref:
https://github.com/vercel/next.js/actions/runs/4587341207/jobs/8100906394
2023-04-02 01:03:46 -07:00
JJ Kasper
c1a2b4f15e v13.2.5-canary.26 2023-04-02 06:31:25 +00:00
Tim Neutkens
9c99d79209
Fix prefetch only being applied once (#47797)
### What / why?

Currently there is a bug because the `subTreeData` can only be applied
once, however, we reuse the same response when a url was prefetched.
During the first render of the response we apply the cacheNodes and then
these should be reused for subsequent navigations. There's currently a
bug because `fillLazyItemsTillLeafWithHead` creates `LAZY_INITIALIZED`
cache nodes that don't copy the previous cache node `parallelRoutes` and
`subTreeData` value, causing the cache nodes below where the
`subTreeData` is applied to be deleted from the cache, even when they're
not affected by the navigation.

### How?

This PR adds copying of the cache node when it exists already, I've
added a marker for `wasPrefetched` to trigger that behavior but in
talking to @feedthejim about this it seems we can swap to this behavior
always when applying the server response, that needs to be discussed
further though, this is temporary implementation with the fix for routes
that were prefetched.

Fixes NEXT-402

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

-->

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-04-01 23:12:49 -07:00
nivak-monarch
8e8eec3b21
fix: added tab and carriage to isWhitespace function to make robust (#47785) 2023-04-01 22:49:07 -07:00
vinay
2601f55982
(Fix)(Tests)Fix typo in unit testing (#47644)
<!-- 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 #

-->
Fix Typo In Unit Testing
2023-04-01 22:23:15 -07:00
Parbez
83afeb7642
fix(next-types-plugin): add ParamCheck type only for route.ts files (#47739)
<!-- 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

Closes NEXT-
Fixes #

-->

### What?
This pr removes `ParamCheck` type for `page` or `layout` files

### Why?
typescript throws error for unused vars with `"noUnusedLocals": true`
config

### How?
Check for `route` before defining the route
2023-04-01 22:00:05 -07:00
Shu Ding
7ef95ba77a
Add computeWorkerKey to the static optimization worker (#47792)
Since both `exportPage` and `isPageStatic` methods in the static
optimization worker involve loading the actual page component, it's
better to assign the same page to the same worker for these 2 tasks to
avoid unnecessary memory allocation.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-04-01 21:42:40 -07:00
JJ Kasper
8c7e4f9bc4
Fix fetchCache config and On-Demand Revalidate handling (#47803)
This ensures we properly honor the `export const fetchCache` config and
also ensures we properly bypass fetch-cache when an On-Demand
Revalidation is occurring.

The `export const dynamic` handling is not changed here as that was
behaving correctly and should not influence fetch cache handling only
whether a page is prerendered fully or treated as SSR.

Fixes: https://github.com/vercel/next.js/issues/47273
x-ref: [slack
thread](https://vercel.slack.com/archives/C042LHPJ1NX/p1679078572123979)
2023-04-01 21:15:13 -07:00
Jiachi Liu
225e924669
Fix module resolving error in tracer (#47786)
Fix the module resolving error found during development, because now few
app route code is bundled into RSC server layer, it can't resolve
opentelementry properly and will throw the error blow due to the check
of `require('@opentelemetry/api')` to see if it's installed.

```
Module not found: Can't resolve '@opentelemetry/api'
```

Thus I alias it to default `next/dist/compiled/@opentelemetry/api` when
it doesn't have external module

---------
2023-04-01 17:17:11 -07:00
Jiachi Liu
5c6b8ac3f2
Fix flaky css test and remove unused tests deps (#47806)
* use `check` to wait for css change
* remove unused swr deps and update them to latest
* remove swr esm test in `app-dir/app/` since it's already covered in
`app-dir/app-external/`

---------
2023-04-01 16:58:32 -07:00
Jiachi Liu
2a5c558963
Skip favicon.js for metadata (#47790)
For backward compatibility, we only handle `favicon.ico` file to
generate `/favicon.ico` route and link tag. If you want to use other
extension such as `png`, use `icon(\d)?.[ext]`
2023-04-02 01:35:24 +02:00
JJ Kasper
57d51b0e22
Tweak Vercel CLI installing for E2E tests (#47804)
Avoids accidentally running the CLI install twice at the same time due
to concurrency by pre-installing it before starting tests.

x-ref:
https://github.com/vercel/next.js/actions/runs/4581102424/jobs/8090565967
x-ref:
https://github.com/vercel/next.js/blob/canary/test/lib/next-modes/next-deploy.ts#L27
2023-04-01 15:36:21 -07:00
Vishal Jagtap
c8a5bd5eba
Update react-strict-mode.md (#47780)
Updated the old react doc link
2023-04-01 21:34:13 +00:00
JJ Kasper
a5269cf096
Fix docs only check for test-native-integration (#47800)
x-ref:
https://github.com/vercel/next.js/actions/runs/4585187133/jobs/8097219720
x-ref:
https://github.com/vercel/next.js/actions/runs/4585188922/jobs/8097221396
2023-04-01 14:27:38 -07:00
Vishal Jagtap
75c76ea772
Update error-handling.md (#47779)
Updated the react error boundary doc link. old one is depricated

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

-->

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-04-01 14:15:02 -07:00
Sukka
b132efc5c4
fix(export): make static export work with worker_threads (#47784)
Fixes #46993.

The issue is introduced in #46705 by @ijjk 

Next.js uses `jest-worker` for multiprocessing. `jest-worker` supports both `child_process` and `worker_threads` modes. Next.js use `child_process` mode by default, but can also switch to using `worker_threads` mode with an experimental flag `config.experimental.workerThreads`.

In #46705, @ijjk applies a fix that works for the `child_process` mode, which breaks the `worker_threads` mode (`jest-worker`'s `NodeThreadWorker` interface doesn't have the private property `_child`), causing static HTML export to fail with the following error (#46993):

```
> Build error occurred
TypeError: Cannot read properties of undefined (reading 'on')
    at createWorker (/Users/[redacted]/node_modules/next/dist/lib/worker.js:32:31)
    at new Worker (/Users/[redacted]/node_modules/next/dist/lib/worker.js:42:9)
    at /Users/[redacted]/node_modules/next/dist/build/index.js:629:35
    at async Span.traceAsyncFn (/Users/[redacted]/node_modules/next/dist/trace/trace.js:79:20)
    at async Object.build [as default] (/Users/[redacted]/node_modules/next/dist/build/index.js:74:29)
```

The PR fixes that.
2023-04-01 17:43:59 +00:00
Justin Ridgewell
2abc824869
Turbopack: Use SharedError for body streaming (#47677)
Pending https://github.com/vercel/turbo/pull/4392 landing in Turbopack (and https://github.com/vercel/next.js/pull/47476 landing here), this removes `BodyError` and switches to `SharedError`. That should allow us to preserve the source chain of errors for when we finally display it to the dev, aiding debugging.
2023-04-01 11:37:17 +00:00
Tobias Koppers
f978e70053
provide full polyfill for process (#47764)
### What?

see also https://github.com/vercel/turbo/pull/4415

We need a full process polyfill to fix some edge cases

Also disables SourceMap for edge chunks, since they are not used

### Why?

Some packages do weird things, e. g.

```
var isBrowser = process.title === 'browser'
```
2023-04-01 12:06:36 +02:00
JJ Kasper
083dd2a59f
Tweak canary undrafting (#47777)
Fixes:
https://github.com/vercel/next.js/actions/runs/4581084068/jobs/8090349455#step:10:661
2023-03-31 21:06:51 -07:00
JJ Kasper
7c189c5c08 v13.2.5-canary.25 2023-04-01 03:32:33 +00:00
JJ Kasper
fb98b7382f
Update metadata e2e test on deploy (#47776)
x-ref:
https://github.com/vercel/next.js/actions/runs/4579107074/jobs/8087256711
2023-03-31 20:17:32 -07:00
Maia Teegarden
7d27895c57
Fix typo in error overlay (#47762)
<!-- 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-03-31 19:08:01 -07:00
JJ Kasper
6e5eb2c4d2
Update publish canary to undraft automatically (#47775)
x-ref: [slack
thread](https://vercel.slack.com/archives/C04DUD7EB1B/p1680313038895799?thread_ts=1680303743.811339&cid=C04DUD7EB1B)
2023-03-31 19:00:12 -07:00
OJ Kwon
d66236f2d8
test(turbopack): blocking CI for turbopack integration test (#47709)
<!-- 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 #

-->

- closes WEB-766.

This PR enables a new job for running tests, against turbopack. Since we
have observed some flakiness across turbopack test execution, it starts
from absolute minimum set of tests to not block any CI due to unexpected
failure.

Ran manual workflow roughly ~50 times and looks like these set of tests
are fine to make it as blocking check for the PR. In the future, depends
on the stability we'll increase number of test gradually.
2023-03-31 18:50:35 -07:00
Shu Ding
0e5fb49600
Add test to ensure image generation works in the Node.js runtime (#47719)
Check the test case for more details.
2023-03-31 18:36:10 -07:00
JJ Kasper
7f0638869c
Fix skipMiddlewareUrlNormalize with i18n (#47773)
This ensures we don't normalize locales in the URL with the
skipMiddlewareUrlNormalize flag enabled so that casing redirects can be
applied correctly for locales.
2023-03-31 18:24:20 -07:00
Justin Ridgewell
82787dba9d
turbopack: ensure ENV values are available in middleware (#47767)
Turbopack starts up the router process with all ENV values, but the edge
function definition didn't list any `env` keys for the function
invocation. So, middleware couldn't access any ENV values.

Turbopack doesn't currently have a way to determine what ENV keys are
actually used by the source program, so I'm just passing everything
defined. I'm not sure if that's an issue during dev (I could see it
being one for the build process, but that doesn't matter for this case).

Fixes #47766
Fixes WEB-831
Fixes WEB-834
2023-03-31 17:22:27 -07:00
Tobias Koppers
2820f07875
add consistent import sorting/grouping to rustfmt (#47745)
### What?

Better auto format

### Why?

imports are inconsistently grouped and ordered

### How?

configure cargo fmt
2023-03-31 22:12:54 +00:00
JJ Kasper
f798c95f72 v13.2.5-canary.24 2023-03-31 20:58:12 +00:00
Steven
3f35608fdc
fix: improve error message pages for output: export (#47765)
fix NEXT-928 ([link](https://linear.app/vercel/issue/NEXT-928))
2023-03-31 13:23:51 -07:00
Javi Velasco
2adc1f6c54
Document node.js APIs for Edge Runtime (#47760) 2023-03-31 19:54:22 +00:00
JJ Kasper
53e4627ce5
Update app router filter handling (#47761)
This ensures we check if a path is `appRouter` during prefetching so
that we can trigger hard navigations quicker when routing from pages ->
app. An additional config is also exposed to allow configuring the
potential false positive rate for the client filter.

x-ref: [slack
thread](https://vercel.slack.com/archives/C017QMYC5FB/p1680225393243459)
2023-03-31 12:19:47 -07:00
Justin Ridgewell
0413fea8ea
Turobpack: Implement Streaming App/API rendering (#47476)
Paired with https://github.com/vercel/turbo/pull/4329, this implements
streaming responses for App and API renders. This is accomplished by
sending an initial `headers` message (carrying the status code and
headers list), N `body-chunk` messages of bytes, and a final `body-end`
message to signal completion.

Once sent to Turbopack, these chunk messages will be streamed out of the
node rendering process directly into the HTTP server's response.

Closes WEB-27

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-03-31 20:58:04 +02:00
Steven
4c60b7b6ae
feat: bump minimum ts version to 4.5.2 (#47712)
Fixes an issue with newer app directory usage:

```
Failed to compile.
../../node_modules/next/dist/server/future/route-handlers/app-route-route-handler.d.ts:11:15
Type error: ',' expected.
```

---------
2023-03-31 11:37:09 -07:00
Hofer Ivan
9ab6ca5d5f
chore(docs): add typesafe-i18n as a new i18n option (#47315)
<!-- 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-03-31 11:28:28 -07:00
Shu Ding
5ad1b77704
Restart static paths worker after finishing task (#47716)
Noticed this optimization when debugging something else - we restart
this worker if it's not fresh, to make sure module instances are new
created. This has some perf overhead and it happens right before running
the task and it's blocking the request. This PR changes that to be after
the old task, and the difference is noticeable on dev (~20ms).

Before:

<img width="1363" alt="CleanShot-2023-03-30-jTT9W48H@2x"
src="https://user-images.githubusercontent.com/3676859/228965542-e0d6892f-3989-4da5-96a4-5fc8b4155041.png">

After:

<img width="1363" alt="CleanShot-2023-03-30-PRrYQMg7@2x"
src="https://user-images.githubusercontent.com/3676859/228965566-42e04f8d-0cc3-447c-adc8-3840b23b9fa5.png">
2023-03-31 19:16:48 +02:00
Jay
247ea65edb
Linking to SST Next.js tutorial. (#47752)
Updating the SST link to a Next.js tutorial: https://docs.sst.dev/start/nextjs
2023-03-31 17:13:31 +00:00
Leah
5cb370f517
remove next-core package.json dev script (#47746)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-03-31 17:58:17 +02:00
Jiachi Liu
04bfb314e0
Support relative path for metadata alternates urls (#47743)
Allow to use relative paths which starting with dot (e.g. `./[paths]`) for urls under `metadata.alternates`.
This allow user to simplify setting `canonical` or other such like `languages` once in root layout with `metadataBase` and a simple relative path, then next.js will resolve it with current pathname of the page.

For example
```js
export const metadata = {
  metadataBase: new URL('https://mydomain.com'),
  alternates: {
    canonical: './'
  }
}
```
Then:
for page `/` it will generate `https://mydomain.com`;
for page `/about` it will generate `https://mydomain.com/about`

as your cononical url

Closes NEXT-897

### Minor changes

- always remove trailing slash for `URL.href`
2023-03-31 15:44:39 +00:00
Wyatt Johnson
e1a397d750
fix: correctly handle Set-Cookie headers (#47718)
## What

This fix serves to address issues where multiple `Set-Cookie` headers
were combined in some runtimes.

## Why

This is because `set-cookie` behaves differently than other headers in
some cases.

Eg. when iterating on a `Headers` instance, multiple set-cookie headers
are folded. To set them correctly, we need to split them. But it'd not
be enough to naively split on the first occurrence, because `,` is a
valid cookie value when for example it's used in `Expires` in a date
string.

So we use a method to correctly detect where to split the cookie.

This should fix all runtimes.

Note, the spec now has `Headers#getSetCookie` which should be preferred
if it's present. https://github.com/whatwg/fetch/pull/1346. We are using
the [`edge-runtime`](https://github.com/vercel/edge-runtime), so this
should be fixed upstream and then reused in Next.js in the future.

## How

Wherever we can, we reuse the `fromNodeHeaders` and `toNodeHeaders`
methods that have the correct implementation. This should be preferred
in the future in other parts of the codebase. We fixed some related TS
issues as well.

Fixes #46579, supersedes #40579
fix NEXT-735 ([link](https://linear.app/vercel/issue/NEXT-735))

---------

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2023-03-31 16:35:47 +02:00
JJ Kasper
f090f321ee v13.2.5-canary.23 2023-03-31 13:53:10 +00:00
Alex Kirszenberg
5950e2b3b0
Small fixes to copy of Turbopack errors (#47734)
This also removes next-swc's Prettier configuration, which we weren't
following anyway.
2023-03-31 11:12:12 +00:00
Jiachi Liu
6563174176
Add NEXT_RUNTIME process env to turbopack (#47713)
Support `process.env.NEXT_RUNTIME` in turbopack, define it in node server / edge, leave client as undefined
2023-03-31 09:48:15 +00:00
OJ Kwon
a34f02b3d2
feat(next-swc): add compile-time heap profiler flag (#47729)
### What?

This PR adds an internal compile time flags for the `next-swc`, which exposes two runtime apis into next.js to initialize heap-profiling enabled memory allocator and teardown those once next.js exits. While there are newly added 2 js interfaces (`initHeapProfiler`, `teardownHeapProfiler`) underlying napi binary itself have compile time flags to actually  enable those feature: any user who runs npm-published next.js cannot enable this features with any kind of runtime configuration. Only manually built next-swc binary with specific flag can enable this. Since this is primarily for the CI testing workflow only, those flag / configs are not visibily exposed as well.


### Why?

It is for some experiments on the CI to see if it can observe some of memory pressure issues (WEB-593, WEB-804) while it is not easily reproducible on the local machines.
2023-03-31 08:37:17 +00:00
Shu Ding
a52ebf4089
Add tests for Suspensey CSS (#47708)
This PR adds a test to confirm that the component will be committed
after the stylesheet is loaded, by delaying the CSS request in
middleware and then check the active style in `useEffect` (technically
it should be `useLayoutEffect`). Since our current timeout for that is
set to 500ms, I also added a test with 1000ms delay to rule out false
negative cases.
2023-03-31 10:06:17 +02:00
Rishabh Poddar
c9c8f6cde0
Updates with-supertokens example app (#47701)
Co-authored-by: NkxxkN <kevin@supertokens.io>
Co-authored-by: NkxxkN <kevin.antoine@protonmail.com>
Co-authored-by: Lee Robinson <me@leerob.io>
Co-authored-by: Rishabh <rishabh@supertokens.io>
Co-authored-by: Bhumil Sarvaiya <sarvaiyabhumil@gmail.com>
Co-authored-by: jscyo <joelsteve97@hotmail.com>
Co-authored-by: Mihaly Lengyel <mihaly.lengyel@tresorit.com>
Co-authored-by: Balázs Orbán <info@balazsorban.com>
Co-authored-by: Mihaly Lengyel <mihaly@lengyel.tech>
Co-authored-by: Alisher <alisher@supertokens.com>
Co-authored-by: Nemi Shah <nemishah1212@gmail.com>
2023-03-31 05:38:58 +00:00
Wyatt Johnson
2642d0a83e
Combine Route Handlers with Route Modules (#47679)
Based on some suggestions from @sokra, this serves to unify the Route Handlers and Route Modules to provide a unified interface for defining route modules and handlers and defining their dependancies.
2023-03-31 04:52:48 +00:00
Steven
d83f68ccf7
chore(ci): fix codemod tests (#47710)
These tests were failing with the following error:

```
Failed to fetch origin/canary Error: Command failed: git fetch origin canary
fatal: could not read Username for 'https://github.com/': No such device or address
```

https://github.com/vercel/next.js/actions/runs/4220015224/jobs/7325960064#step:5:13

- Follow up to https://github.com/vercel/next.js/pull/46068
2023-03-31 04:27:16 +00:00
Justin Ridgewell
43872c7572
Turbopack: Fix images.remotePatterns port/protocol serialization (#47721)
By default, `serde-json` will transform a `None` into a `null` value, and Next's [default image loader][loader] will perform strict `=== undefined` [equality checks][checks] on the fields. Because `null !== undefined`, a missing `protocol` or `port` will always be checked, and `null` will never match either.

Fixes #46758
Fixes vercel/turbo#4347
Fixes WEB-770
fix NEXT-793 ([link](https://linear.app/vercel/issue/NEXT-793))

[loader]: 35cf930572/packages/next/src/shared/lib/image-loader.ts (L50)
[checks]: 35cf930572/packages/next/src/shared/lib/match-remote-pattern.ts (L5)
2023-03-31 03:26:38 +00:00