Compare commits

...

64 Commits

Author SHA1 Message Date
Vercel Release Bot
9d6088e0b5 Version Packages (#11693)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @vercel/build-utils@8.2.2

### Patch Changes

- Change node 16.x EOL for Vercel
([#11704](https://github.com/vercel/vercel/pull/11704))

- Improve error message and refactor
([#11706](https://github.com/vercel/vercel/pull/11706))

- [built-utils] Handle case of not having lockfile when corepack is
enabled ([#11697](https://github.com/vercel/vercel/pull/11697))

## vercel@34.2.6

### Patch Changes

- [built-utils] Handle case of not having lockfile when corepack is
enabled ([#11697](https://github.com/vercel/vercel/pull/11697))

- Updated dependencies
\[[`5c12ed695`](5c12ed6950),
[`21444a38e`](21444a38e5),
[`fa9789a93`](fa9789a93e),
[`c925dc4a1`](c925dc4a1b),
[`06d2d860e`](06d2d860e4),
[`b735f37fd`](b735f37fd9)]:
    -   @vercel/build-utils@8.2.2
    -   @vercel/next@4.2.16
    -   @vercel/redwood@2.0.10
    -   @vercel/remix-builder@2.1.7
    -   @vercel/node@3.1.7
    -   @vercel/static-build@2.5.11

## @vercel/client@13.2.9

### Patch Changes

- Updated dependencies
\[[`5c12ed695`](5c12ed6950),
[`21444a38e`](21444a38e5),
[`06d2d860e`](06d2d860e4)]:
    -   @vercel/build-utils@8.2.2

## @vercel/gatsby-plugin-vercel-builder@2.0.33

### Patch Changes

- Updated dependencies
\[[`5c12ed695`](5c12ed6950),
[`21444a38e`](21444a38e5),
[`06d2d860e`](06d2d860e4)]:
    -   @vercel/build-utils@8.2.2

## @vercel/next@4.2.16

### Patch Changes

- prevent /index from being incorrectly normalized in rewrites
([#11707](https://github.com/vercel/vercel/pull/11707))

- Upgrade to @vercel/nft 0.27.2 with browser remapping support
([#11700](https://github.com/vercel/vercel/pull/11700))

- ensure unmatched rsc rewrites are routed to correct handler
([#11688](https://github.com/vercel/vercel/pull/11688))

## @vercel/node@3.1.7

### Patch Changes

- Upgrade to @vercel/nft 0.27.2 with browser remapping support
([#11700](https://github.com/vercel/vercel/pull/11700))

- Updated dependencies
\[[`5c12ed695`](5c12ed6950),
[`21444a38e`](21444a38e5),
[`06d2d860e`](06d2d860e4)]:
    -   @vercel/build-utils@8.2.2

## @vercel/redwood@2.0.10

### Patch Changes

- Upgrade to @vercel/nft 0.27.2 with browser remapping support
([#11700](https://github.com/vercel/vercel/pull/11700))

## @vercel/remix-builder@2.1.7

### Patch Changes

- Upgrade to @vercel/nft 0.27.2 with browser remapping support
([#11700](https://github.com/vercel/vercel/pull/11700))

## @vercel/static-build@2.5.11

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/gatsby-plugin-vercel-builder@2.0.33

## @vercel-internals/types@1.0.38

### Patch Changes

- Updated dependencies
\[[`5c12ed695`](5c12ed6950),
[`21444a38e`](21444a38e5),
[`06d2d860e`](06d2d860e4)]:
    -   @vercel/build-utils@8.2.2

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-07 10:40:38 -05:00
Dima Voytenko
c925dc4a1b Upgrade to @vercel/nft 0.27.2 with browser remapping support (#11700)
See https://github.com/vercel/nft/pull/424 for more details.
2024-06-06 23:45:45 +00:00
Austin Merrick
21444a38e5 [build-utils] Improve no lockfile detection logic (#11706)
Two minor improvements missed from the review of https://github.com/vercel/vercel/pull/11697:

- [Include supported package manager names in error message](https://github.com/vercel/vercel/pull/11697#discussion_r1628382867)
- [Avoid `as` to improve type safety](https://github.com/vercel/vercel/pull/11697#discussion_r1628384789)
2024-06-06 23:20:23 +00:00
Zack Tanner
fa9789a93e [next]: fix issues with rewrite normalization of index routes (#11707)
The Next.js builder currently normalizes user rewrites to ensure the internal `.rsc` / `.action` rewrites are still handled even after following the rewrite.

However we have special rewrites: `/index.rsc` and `/index.action`. When those routes pass through the normalization logic, a request routed to a catch-all route (e.g. `[[...param]]`) will go from `/` -> `/index.rsc` -> `<someRewriteString>?param=index`. This is inconsistent `next start` or other spots where the param should be an empty string.

Similarly, if a user rewrites their entire app to a subdirectory (eg `/:path*` -> `/base/:path*`, a route will go from `/` -> `/index.rsc` -> `/base/index.rsc` which won't exist, causing a 404. 

The solution here is to return the `index.rsc` / `index.action` routes back to `/` so they can be handled by user rewrites, if necessary. 

This also disables the `hasActionOutputSupport` flag if `routesManifest.i18n` is detected as they are not compatible.
2024-06-06 23:15:47 +00:00
Trek Glowacki
5c12ed6950 Change node 16.x EOL for Vercel (#11704)
https://github.com/vercel/vercel/pull/11671 changed the EOL date for
node 16.x to be AWS's final date. We want ours to be ~ a month earlier.
2024-06-06 14:54:22 -05:00
Austin Merrick
06d2d860e4 [build-utils] Handle case of not having lockfile (#11697)
In the scenario where we don't have a lockfile, cliType was detected by build utils as npm regardless of what's set in corepack. This fixes that.
2024-06-05 20:23:39 +00:00
Zack Tanner
b735f37fd9 [next]: ensure unmatched rsc rewrites are routed to correct handler (#11688)
Same reasoning as:

- https://github.com/vercel/vercel/pull/11686

Split this into a separate PR so it can be tested/released separately.
2024-06-04 18:52:44 +00:00
Vercel Release Bot
d91f3afcbf Version Packages (#11689)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## vercel@34.2.5

### Patch Changes

- Adds a route for the `.rsc` pathname as well when app has ppr enabled
but not all routes.
([#11681](https://github.com/vercel/vercel/pull/11681))

- Updated dependencies
\[[`7457767a7`](7457767a77),
[`4337ea065`](4337ea0654)]:
    -   @vercel/next@4.2.15

## @vercel/fs-detectors@5.2.4

### Patch Changes

- Add support for detecting Turborepo 2
([#11680](https://github.com/vercel/vercel/pull/11680))

## @vercel/next@4.2.15

### Patch Changes

- ensure unmatched action rewrites are routed to correct handler
([#11686](https://github.com/vercel/vercel/pull/11686))

- Adds a route for the `.rsc` pathname as well when app has ppr enabled
but not all routes.
([#11681](https://github.com/vercel/vercel/pull/11681))

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-04 11:29:56 -07:00
Lee Robinson
58d9789e60 examples: Update Astro template. (#11687) 2024-06-04 18:28:11 +00:00
Zack Tanner
7457767a77 [next]: ensure unmatched action rewrites are routed to correct handler (#11686)
User defined rewrites are "normalized" so that our internal rewrites are still properly handled. Before normalizing these rewrites, the Next.js builder will attempt to match server action requests to a`.action` variant. Then the user-defined rewrites flow through the afterFiles normalization ([this part](https://github.com/vercel/vercel/blob/fix/unmatched-action-rewrites/packages/next/src/server-build.ts#L254-L279)) so that when we add `.action` in the builder, we don't drop the suffix. 

But this normalization can lead to a malformed `dest`. e.g., if I had rewrite like this:

```js
{
  source: '/greedy-rewrite/static/:path*',
  destination: '/static/:path*',
}
```

The builder would go through this flow on an action request to `/greedy-rewrite/static`:

1. It'll attempt to match it to a `.action` output, so `/greedy-rewrite/static` -> `/greedy-rewrite/static.action`
2. The afterFiles normalization will take place, so the original `dest` of `/static/$1` will become `/static/$1$rscsuff`
3. $1 will be an empty string, because it doesn't match the existing capture group. So now `/greedy-rewrite/static.action` -> `/greedy-rewrite/static/.action`
4. `static/.action` is not a valid output, so it'll 404 and the action will break. 

Existing handling exists for `.rsc` outputs for a similar reason, but only on the index route. I added a similar fix for this in #11688.
2024-06-04 18:05:11 +00:00
Chris Olszewski
5dedc7b2ce feat(turbo): add support for turbo 2 configuration (#11680)
With the release of Turborepo 2 we're renaming `pipeline` to `tasks`. 

This PR updates the default settings logic to look in `tasks` for a
`build` task definition in addition to looking at `pipeline`. It also
updates the message to no longer mention Turbo configuration in
`package.json` as this is fully ignored in Turborepo 2.

Added a quick unit test to verify `build` task definitions are found in
the `tasks` section of `turbo.json`.

Please let me know if there are other tests/places I should update.
2024-06-04 10:36:35 -07:00
Wyatt Johnson
4337ea0654 [ppr] Add missng .rsc route for non-ppr enabled pages (#11681)
When deploying partial prerendering (PPR), there may some pages that are
not enabled for PPR but still appear in the `prerender-manifest.json`.
Due to the branching of the client router, these routes also have to
have a `.rsc` as well as a `.prefetch.rsc` variants in order to prevent
404's. This change adds support for adding the extra route to the
prerender for pages that have PPR disabled.
2024-06-03 17:52:30 -07:00
Vercel Release Bot
a26cbd8199 Version Packages (#11674)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @vercel/python@4.3.0

### Minor Changes

- support newer python versions
([#11675](https://github.com/vercel/vercel/pull/11675))

## @vercel/build-utils@8.2.1

### Patch Changes

- [node] update node@16 deprecation day
([#11671](https://github.com/vercel/vercel/pull/11671))

## vercel@34.2.4

### Patch Changes

- Updated dependencies
\[[`3eb9d8c89`](3eb9d8c892),
[`83741a0eb`](83741a0eb9)]:
    -   @vercel/python@4.3.0
    -   @vercel/build-utils@8.2.1
    -   @vercel/node@3.1.6
    -   @vercel/static-build@2.5.10

## @vercel/client@13.2.8

### Patch Changes

- Updated dependencies
\[[`83741a0eb`](83741a0eb9)]:
    -   @vercel/build-utils@8.2.1

## @vercel/gatsby-plugin-vercel-builder@2.0.32

### Patch Changes

- Updated dependencies
\[[`83741a0eb`](83741a0eb9)]:
    -   @vercel/build-utils@8.2.1

## @vercel/node@3.1.6

### Patch Changes

- Updated dependencies
\[[`83741a0eb`](83741a0eb9)]:
    -   @vercel/build-utils@8.2.1

## @vercel/static-build@2.5.10

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/gatsby-plugin-vercel-builder@2.0.32

## @vercel-internals/types@1.0.37

### Patch Changes

- Updated dependencies
\[[`83741a0eb`](83741a0eb9)]:
    -   @vercel/build-utils@8.2.1

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-05-30 14:00:25 -05:00
Trek Glowacki
3eb9d8c892 support newer python versions (#11675)
When we added the option of getting `al2023` in addition to `al2`, this required a python version bump for those apps on `al2023`. Python 3.10 had a breaking minor change. https://github.com/vercel/vercel/pull/11541 mostly fixed it, with some comments.

OP hasn't replied to feedback on that PR, so I've take it over from them.
2024-05-30 18:46:28 +00:00
Trek Glowacki
83741a0eb9 [node] update node@16 deprecation day (#11671)
Double check my dates, but I believe this is the new correct date we want. https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html
2024-05-30 15:24:15 +00:00
Jeff See
9db0298981 Switch from jest to vitest for remix builder (#11652) 2024-05-28 17:02:45 +00:00
Vercel Release Bot
af29e9be49 Version Packages (#11648)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## vercel@34.2.3

### Patch Changes

- Don't create streaming lambdas for pages router routes
([#11660](https://github.com/vercel/vercel/pull/11660))

- Updated dependencies
\[[`c9d53d4e3`](c9d53d4e3e),
[`5f561f8cf`](5f561f8cfa)]:
    -   @vercel/next@4.2.14

## @vercel/next@4.2.14

### Patch Changes

- Don't create streaming lambdas for pages router routes
([#11660](https://github.com/vercel/vercel/pull/11660))

- Ensure user rewrites still match to action outputs
([#11628](https://github.com/vercel/vercel/pull/11628))

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-05-24 15:19:28 -07:00
Wyatt Johnson
c9d53d4e3e [next] Ensure only pages enable streaming (#11660)
This fixes a regression introduced by #11625 that enabled streaming for
routes on the pages router (these routes do not support streaming).
2024-05-24 15:15:32 -07:00
Trek Glowacki
a26ea7bf12 [tests] bump datadog installed version (#11651)
Unsure if this is related to `vitest` migration or something else but a dependency of the `datadog-ci` version we use is gone and [now errors](https://github.com/vercel/vercel/actions/runs/9213580743/job/25348743824?pr=11650). Bumping it to latest.
2024-05-23 20:44:34 +00:00
Trek Glowacki
866d0c173d [tests] remove unused opts.skipTeam (#11650)
I can't find this being used anywhere.
2024-05-23 15:25:04 -05:00
Zack Tanner
5f561f8cfa [next]: ensure user rewrites match to action outputs (#11628)
The builder normalizes user rewrites that target pages that have special outputs (`.rsc`, `.prefetch.rsc`). When we added support for `.action` outputs, we need to perform this same normalization to ensure that user rewrites still match. If the rewrite was a greedy match (eg `/:path*`) it'd be ok, but more specific rewrites would have the issue.
2024-05-23 19:06:25 +00:00
Nathan Rajlich
139e8cdb17 [node] Use vitest for unit tests (#11631)
Similar to #11302, but for the `@vercel/node` package.
2024-05-23 18:20:18 +00:00
Vercel Release Bot
6529a9ab9c Version Packages (#11637)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## vercel@34.2.2

### Patch Changes

- Fix related to erroring when a prefetch route is not provided but the
route is PPR enabled
([#11638](https://github.com/vercel/vercel/pull/11638))

- Updated dependencies
\[[`8e44ef5b9`](8e44ef5b9d),
[`61e6af374`](61e6af3740)]:
    -   @vercel/next@4.2.13

## @vercel/next@4.2.13

### Patch Changes

- Fix static case for detecting when a page supports PPR
([#11635](https://github.com/vercel/vercel/pull/11635))

- Fix related to erroring when a prefetch route is not provided but the
route is PPR enabled
([#11638](https://github.com/vercel/vercel/pull/11638))

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-05-23 10:33:01 +02:00
Wyatt Johnson
61e6af3740 [ppr] Fix for error case involving prefetch data routes (#11638)
Only error when the prefetch data route is present but the route also
has PPR enabled.
2024-05-23 10:28:05 +02:00
Wyatt Johnson
8e44ef5b9d [ppr] Fix static case (#11635)
When PPR is enabled in incremental mode, the previous code used the page information to determine if there was a failure for generating the flight data. This has been moved to the app PPR setting instead.
2024-05-23 05:23:26 +00:00
Wyatt Johnson
fe9e27c459 chore: bump react version (#11636) 2024-05-23 05:14:10 +00:00
Vercel Release Bot
8a6dc204fd Version Packages (#11634)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## vercel@34.2.1

### Patch Changes

- Support incremental PPR for large applications
([#11625](https://github.com/vercel/vercel/pull/11625))

- Updated dependencies
\[[`73e558913`](73e558913a)]:
    -   @vercel/next@4.2.12

## @vercel/next@4.2.12

### Patch Changes

- Support incremental PPR for large applications
([#11625](https://github.com/vercel/vercel/pull/11625))

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-05-22 21:14:01 -07:00
Wyatt Johnson
73e558913a [ppr] Fix PPR detection for groups (#11625)
Previously, PPR was either all on, or all off. As we've added support for incremental adoption of PPR, the logic for determining if there's a grouping issue had to be adjusted.

This now only considers a group as supporting PPR if a route in the group supports PPR. As we also use this as a grouping key, this still ensures we won't have conflicts.
2024-05-23 04:06:12 +00:00
Wyatt Johnson
464cb26255 chore: bump react versions (#11632) 2024-05-22 19:45:03 -07:00
Zack Tanner
80e0bab0ec [next] Fix Next.js tests (#11610)
Syncs the experimental React dependency to avoid build errors. 

This was updated in:
- https://github.com/vercel/next.js/pull/65864
2024-05-17 22:24:53 +00:00
Trek Glowacki
f900ca8daf [framework-fixtures] add missing dependency to dependabot (#11606)
Hydrogen has a peer-dep on remix.
2024-05-16 20:33:36 -05:00
Nathan Rajlich
9ee7d31957 [cli] Add test for CLI extensions passing through exit code (#11600)
/cc @codybrouwers
2024-05-15 20:02:40 +00:00
Vercel Release Bot
1eb76a3ae7 Version Packages (#11598)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @vercel/build-utils@8.2.0

### Minor Changes

- fix corepack detection for package manager version determination
([#11596](https://github.com/vercel/vercel/pull/11596))

### Patch Changes

- Fix triggering of ignored project settings node version warning
([#11550](https://github.com/vercel/vercel/pull/11550))

## vercel@34.2.0

### Minor Changes

- Stop sending system environment variables in dev
([#11526](https://github.com/vercel/vercel/pull/11526))

### Patch Changes

- Updated dependencies
\[[`d3c1267e2`](d3c1267e24),
[`ccd7eb1fb`](ccd7eb1fb7)]:
    -   @vercel/build-utils@8.2.0
    -   @vercel/node@3.1.5
    -   @vercel/static-build@2.5.9

## @vercel/client@13.2.7

### Patch Changes

- Updated dependencies
\[[`d3c1267e2`](d3c1267e24),
[`ccd7eb1fb`](ccd7eb1fb7)]:
    -   @vercel/build-utils@8.2.0

## @vercel/gatsby-plugin-vercel-builder@2.0.31

### Patch Changes

- Updated dependencies
\[[`d3c1267e2`](d3c1267e24),
[`ccd7eb1fb`](ccd7eb1fb7)]:
    -   @vercel/build-utils@8.2.0

## @vercel/node@3.1.5

### Patch Changes

- Updated dependencies
\[[`d3c1267e2`](d3c1267e24),
[`ccd7eb1fb`](ccd7eb1fb7)]:
    -   @vercel/build-utils@8.2.0

## @vercel/static-build@2.5.9

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/gatsby-plugin-vercel-builder@2.0.31

## @vercel-internals/types@1.0.36

### Patch Changes

- Updated dependencies
\[[`d3c1267e2`](d3c1267e24),
[`ccd7eb1fb`](ccd7eb1fb7)]:
    -   @vercel/build-utils@8.2.0

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-05-15 14:26:56 -05:00
Sean Massa
ccd7eb1fb7 fix corepack detection for package manager version determination (#11596)
The previous logic was checking for the env var `ENABLE_EXPERIMENTAL_COREPACK` to determine if corepack was being used by a project. However, this value only means that the build system should consider corepack, not that it's actively being used.

We need to check that flag AND the existence of a `packageManager` property in the project's `package.json`.
2024-05-15 19:25:01 +00:00
Austin Merrick
41c44d6594 [build-utils] Refactor getNodeVersion (#11599)
Makes variable names more clear and consistent.
2024-05-15 17:17:41 +00:00
Austin Merrick
446ac49e2b [cli] Don't pull system environment vars in dev (#11526)
System environment variables would get set with empty strings in development which breaks some builds. This fixes that by using the v2 of `/env/pull` introduced in https://github.com/vercel/api/pull/27777.
2024-05-15 12:17:47 +00:00
Austin Merrick
d3c1267e24 [build-utils] Fix warn for ignored project settings node version (#11550)
There were scenarios where the warning "Node.js Version defined in your Project Settings ("18.x") will not apply" would not be triggered. For example:

1. Project Setting is 18.x
2. package.json has "engines.node": ">=18.x"
3. semver.intersects('18.x', '>=18.x') // => true (In this [code path](8ea93839cc/packages/build-utils/src/fs/run-user-scripts.ts (L258))) -> No warning message that Node.js Version was changed
4. After the error message we evaluate the latest node Version to use (20.x) in getSupportedNodeVersion()(this [code path](8ea93839cc/packages/build-utils/src/fs/run-user-scripts.ts (L274)))
5. User doesn't get notified that we changed the node version to something different than their project setting

This fixes that scenario by getting the supported node version first.
2024-05-14 23:23:17 +00:00
Sean Massa
b09d7b6130 [tests] allow errors to define retry delay (#11597)
Errors can now define their own retry delay. This is necessary for some
kinds of errors where all retries will run within the same second.
2024-05-14 14:15:31 -05:00
Vercel Release Bot
f78b315a50 Version Packages (#11595)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @vercel/build-utils@8.1.3

### Patch Changes

- [build-utils] log more around package manager detection
([#11594](https://github.com/vercel/vercel/pull/11594))

## vercel@34.1.14

### Patch Changes

- Updated dependencies
\[[`ad6945435`](ad69454352)]:
    -   @vercel/build-utils@8.1.3
    -   @vercel/node@3.1.4
    -   @vercel/static-build@2.5.8

## @vercel/client@13.2.6

### Patch Changes

- Updated dependencies
\[[`ad6945435`](ad69454352)]:
    -   @vercel/build-utils@8.1.3

## @vercel/gatsby-plugin-vercel-builder@2.0.30

### Patch Changes

- Updated dependencies
\[[`ad6945435`](ad69454352)]:
    -   @vercel/build-utils@8.1.3

## @vercel/node@3.1.4

### Patch Changes

- Updated dependencies
\[[`ad6945435`](ad69454352)]:
    -   @vercel/build-utils@8.1.3

## @vercel/static-build@2.5.8

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/gatsby-plugin-vercel-builder@2.0.30

## @vercel-internals/types@1.0.35

### Patch Changes

- Updated dependencies
\[[`ad6945435`](ad69454352)]:
    -   @vercel/build-utils@8.1.3

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-05-13 17:07:24 -05:00
Sean Massa
ad69454352 [build-utils] log more around package manager detection (#11594)
Add more loggign around package manager detection to see why we're not
properly detecting `pnpm` given a pnpm lockfile.
2024-05-13 17:05:25 -05:00
Vercel Release Bot
14059906d3 Version Packages (#11593)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @vercel/build-utils@8.1.2

### Patch Changes

- add log to package manager version detection
([#11592](https://github.com/vercel/vercel/pull/11592))

## vercel@34.1.13

### Patch Changes

- Updated dependencies
\[[`1682ad43d`](1682ad43d0)]:
    -   @vercel/build-utils@8.1.2
    -   @vercel/node@3.1.3
    -   @vercel/static-build@2.5.7

## @vercel/client@13.2.5

### Patch Changes

- Updated dependencies
\[[`1682ad43d`](1682ad43d0)]:
    -   @vercel/build-utils@8.1.2

## @vercel/gatsby-plugin-vercel-builder@2.0.29

### Patch Changes

- Updated dependencies
\[[`1682ad43d`](1682ad43d0)]:
    -   @vercel/build-utils@8.1.2

## @vercel/node@3.1.3

### Patch Changes

- Updated dependencies
\[[`1682ad43d`](1682ad43d0)]:
    -   @vercel/build-utils@8.1.2

## @vercel/static-build@2.5.7

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/gatsby-plugin-vercel-builder@2.0.29

## @vercel-internals/types@1.0.34

### Patch Changes

- Updated dependencies
\[[`1682ad43d`](1682ad43d0)]:
    -   @vercel/build-utils@8.1.2

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-05-13 14:03:47 -05:00
Sean Massa
1682ad43d0 [build-utils] add log to package manager version detection (#11592) 2024-05-13 19:01:58 +00:00
Vercel Release Bot
423630a168 Version Packages (#11589)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @vercel/build-utils@8.1.1

### Patch Changes

- [build-utils] pnpm lockfile testing and fixing
([#11591](https://github.com/vercel/vercel/pull/11591))

## vercel@34.1.12

### Patch Changes

- Updated dependencies
\[[`67afc2608`](67afc26085),
[`2f7a6ed5f`](2f7a6ed5f9)]:
    -   @vercel/next@4.2.11
    -   @vercel/build-utils@8.1.1
    -   @vercel/node@3.1.2
    -   @vercel/static-build@2.5.6

## @vercel/client@13.2.4

### Patch Changes

- Updated dependencies
\[[`2f7a6ed5f`](2f7a6ed5f9)]:
    -   @vercel/build-utils@8.1.1

## @vercel/gatsby-plugin-vercel-builder@2.0.28

### Patch Changes

- Updated dependencies
\[[`2f7a6ed5f`](2f7a6ed5f9)]:
    -   @vercel/build-utils@8.1.1

## @vercel/next@4.2.11

### Patch Changes

- normalize source file locations for special metadata files
([#11579](https://github.com/vercel/vercel/pull/11579))

## @vercel/node@3.1.2

### Patch Changes

- Updated dependencies
\[[`2f7a6ed5f`](2f7a6ed5f9)]:
    -   @vercel/build-utils@8.1.1

## @vercel/static-build@2.5.6

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/gatsby-plugin-vercel-builder@2.0.28

## @vercel-internals/types@1.0.33

### Patch Changes

- Updated dependencies
\[[`2f7a6ed5f`](2f7a6ed5f9)]:
    -   @vercel/build-utils@8.1.1

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-05-13 13:18:24 -05:00
Sean Massa
2f7a6ed5f9 [build-utils] log pnpm lockfile selection (#11591)
Both `pnpm@6` and `pnpm@7` can parse lockfile versions `5.3` and `5.4`, but if there's a mismatch, `pnpm` will output a warning saying so. In order to prevent confusing warnings from being displayed to the user, this PR aligns the pnpm version with the exact lockfile verison.

It also adds a debug log to show which package manager version was determined based on the lockfile version.
2024-05-13 18:16:24 +00:00
Zack Tanner
67afc26085 [next]: normalize source path for special app-dir metadata files (#11579)
When specifying a functions configuration in `vercel.json`, we attempt to find source files for all entrypoints.  This attempts to normalize those source paths for some special cases so that we don't show a build warning for completely normal usage.

- `/_not-found` is an entrypoint automatically inserted by Next.js -- if we don't find a source file for it, don't warn, as the user might not have added one
- special metadata files like `favicon.ico` and `opengraph-image.<ext>` will be bundled as `favicon.ico/route.js` but the source file will be the raw extension.
2024-05-13 16:04:16 +00:00
Vercel Release Bot
c224fb1d2e Version Packages (#11584)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @vercel/build-utils@8.1.0

### Minor Changes

- Update pnpm version detection logic
([#11445](https://github.com/vercel/vercel/pull/11445))
    Add support for pnpm 9

## vercel@34.1.11

### Patch Changes

- Updated dependencies
\[[`5014b1e82`](5014b1e82a),
[`18d1703d5`](18d1703d5b),
[`e87d4c14d`](e87d4c14d0),
[`bc5fd4115`](bc5fd41158)]:
    -   @vercel/build-utils@8.1.0
    -   @vercel/next@4.2.10
    -   @vercel/redwood@2.0.9
    -   @vercel/remix-builder@2.1.6
    -   @vercel/node@3.1.1
    -   @vercel/static-build@2.5.5

## @vercel/client@13.2.3

### Patch Changes

- Updated dependencies
\[[`5014b1e82`](5014b1e82a)]:
    -   @vercel/build-utils@8.1.0

## @vercel/gatsby-plugin-vercel-builder@2.0.27

### Patch Changes

- Updated dependencies
\[[`5014b1e82`](5014b1e82a)]:
    -   @vercel/build-utils@8.1.0

## @vercel/next@4.2.10

### Patch Changes

- skip action rewrites for RSC requests
([#11576](https://github.com/vercel/vercel/pull/11576))

- Bump `@vercel/nft@0.27.0`
([#11580](https://github.com/vercel/vercel/pull/11580))

## @vercel/node@3.1.1

### Patch Changes

- Bump `@vercel/nft@0.27.0`
([#11580](https://github.com/vercel/vercel/pull/11580))

- Updated dependencies
\[[`5014b1e82`](5014b1e82a)]:
    -   @vercel/build-utils@8.1.0

## @vercel/redwood@2.0.9

### Patch Changes

- Bump `@vercel/nft@0.27.0`
([#11580](https://github.com/vercel/vercel/pull/11580))

## @vercel/remix-builder@2.1.6

### Patch Changes

- Bump `@vercel/nft@0.27.0`
([#11580](https://github.com/vercel/vercel/pull/11580))

- Update `@remix-run/dev` fork to v2.9.2-patch.2
([#11582](https://github.com/vercel/vercel/pull/11582))

## @vercel/static-build@2.5.5

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/gatsby-plugin-vercel-builder@2.0.27

## @vercel-internals/types@1.0.32

### Patch Changes

- Updated dependencies
\[[`5014b1e82`](5014b1e82a)]:
    -   @vercel/build-utils@8.1.0

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-05-11 14:36:18 -05:00
Erika Rowland
5014b1e82a Update pnpm version detection logic (#11445)
The code we use to detect the version of `pnpm` based on lockfiles is hard to follow. It doesn't pick and executable, it instead of *sometimes* overrides the `PATH` for these utilities with a prepended alternate path. 

This means that there is no one single place where we definitively specify which version of `pnpm` that is used, so much as *hope* that the `PATH` has the correct version on it. I don't know that we *can* specify an executable outside of the build container, and it's unclear, since this is a package, whether this utility is used outside of a build container setting.

In this pull request I cleaned up the code and updated the logic to include the `pnpm 7` and `pnpm 8` changes requested, with no changes yet to implement `pnpm 9`.

It's possible that we want to rewrite this detection logic from scratch to avoid this roundabout way of "finding" the executable, but I haven't done that here.
2024-05-11 07:09:53 +00:00
Steven
6a8a84907b [tests] remove styfle from codeowners (#11585)
Remove `styfle` from codeowners
2024-05-11 04:25:41 +00:00
Sean Massa
722adf0e10 some errors can specify retries (#11581)
Trying a different approach to retrying errors when logs must contain a value.

Alternative to: https://github.com/vercel/vercel/pull/11577
2024-05-10 22:19:10 +00:00
Vercel Release Bot
bc5fd41158 [remix] Update @remix-run/dev to v2.9.2-patch.2 (#11582)
This auto-generated PR updates `@remix-run/dev` to version 2.9.2-patch.2.
2024-05-10 21:35:49 +00:00
Austin Merrick
e87d4c14d0 [node][next][redwood][remix] bump @vercel/nft@0.27.0 (#11580)
[@vercel/nft@0.27.0](https://github.com/vercel/nft/releases/tag/0.27.0) is necessary for parsing import assertions. Import assertions are causing [this issue](https://github.com/vercel/vercel/issues/11533).
2024-05-10 21:25:40 +00:00
Kiko Beats
bc95d764b4 ci: add Node.js v18 tests (#11575)
Some tests are skipped because CI tests are running against v16.

I added a new GitHub CI job just inlcuding the tests that are skipped for now.
2024-05-10 21:15:37 +00:00
Nathan Rajlich
1b5ce5644f [examples] Fix "remix" template (#11583)
`@vercel/remix@2.9.2` is broken, but that's the version that tries to
get installed from the `^` caret. For now, explicitly use the
`2.9.2-patch.2` release which works correctly.
2024-05-10 14:11:16 -07:00
Zack Tanner
18d1703d5b [next]: skip action rewrite if RSC header is present (#11576)
When rewriting requests that contain a `next-action` header to a `.action` output, we should do so only in the case where the RSC header isn't present. When a Next.js server action triggers a `redirect`, an intra-app RSC request will be made to that requested URL, with the `next-action` header still present. This means the intra-app request will be incorrectly rewritten, when we only intended to handle the actual action request.

This was patched in Next.js in the following PR:
- https://github.com/vercel/next.js/pull/65615

But it seems like a good idea to be resilient to this here as well.
2024-05-10 21:09:56 +00:00
Zack Tanner
5c6f9c0b66 [tests] fix maxDuration integration test (#11578)
Since maxDuration was updated for this tier ([x-ref](https://vercel.com/changelog/vercel-functions-for-hobby-can-now-run-up-to-60-seconds))
2024-05-10 18:39:49 +00:00
Vercel Release Bot
809740b385 Version Packages (#11570)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @vercel/functions@1.0.2

### Patch Changes

- Convert package to CommonJS
([#11569](https://github.com/vercel/vercel/pull/11569))

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-05-09 18:12:02 -07:00
Nathan Rajlich
bf9acd023d [functions] Convert to CommonJS (#11569)
The package was not working because it is using ESM syntax, but the
`package.json` did not have `"type": "module"`.

Anyways, for broader compatibility, let's use CommonJS.
2024-05-09 18:10:39 -07:00
Vercel Release Bot
f4ba9cdcf8 Version Packages (#11564)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## vercel@34.1.10

### Patch Changes

- Updated dependencies
\[[`119f80e96`](119f80e961),
[`11584b0e9`](11584b0e9b),
[`3023122d4`](3023122d4e),
[`0e774b6be`](0e774b6be0)]:
    -   @vercel/next@4.2.9
    -   @vercel/static-build@2.5.4

## @vercel/next@4.2.9

### Patch Changes

- Support incremental partial prerendering
([#11560](https://github.com/vercel/vercel/pull/11560))

- ensure `.action` outputs are created for edge functions
([#11568](https://github.com/vercel/vercel/pull/11568))

-   ([#11566](https://github.com/vercel/vercel/pull/11566))

## @vercel/static-build@2.5.4

### Patch Changes

- Fix `Cannot read properties of null` error
([#11559](https://github.com/vercel/vercel/pull/11559))

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-05-09 10:03:52 -07:00
Zack Tanner
11584b0e9b [next] ensure action outputs are created for edge functions (#11568)
Since we're rewriting `next-action` requests to `.action` outputs, we need to ensure that we also duplicate the edge function handler for it. 

This runs all of the existing Node runtime tests in the Edge runtime as well. However, there's a discrepancy in how `x-vercel-cache` is returned, so for now we instead validate that its responding with `x-edge-runtime`.
2024-05-09 01:39:08 +00:00
JJ Kasper
3023122d4e [next] Update react version in next fixtures (#11566)
We are locking the peerDependency to react v19 beta on canary so we need to update these fixtures to tolerate that. 

x-ref: [slack thread](https://vercel.slack.com/archives/C048KLPEEH1/p1715191372631389)
x-ref: https://github.com/vercel/next.js/pull/65058
2024-05-08 23:33:24 +00:00
Nathan Rajlich
0e774b6be0 [static-build] Fix Cannot read properties of null error (#11559)
A bug was introduced in #11529 that causes the build to fail if `ruby`
is not installed. The fix here accounts for that scenario.

Closes #11547.
2024-05-08 11:44:49 -07:00
Wyatt Johnson
119f80e961 [next] Support Incremental Partial Prerendering (#11560)
This fixes the logic that detects if partial prerendering (PPR) has been
enabled for a project. The new incremental adoption pathway allows
setting the `experimental.ppr = 'incremental'` which the previous code
did not support.
2024-05-08 08:13:39 -06:00
Vercel Release Bot
9fe92d7de0 Version Packages (#11558)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @vercel/functions@1.0.1

### Patch Changes

- Don't throw error if context is missing
([`0817527f9`](0817527f9e))

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-05-07 17:13:10 +02:00
Kiko Beats
0817527f9e [@vercel/functions]: don't throw error if context is missing (#11557)
making `waituntil` a noop
2024-05-07 17:02:23 +02:00
257 changed files with 3450 additions and 849 deletions

4
.github/CODEOWNERS vendored
View File

@@ -5,13 +5,13 @@
* @TooTallNate @EndangeredMassa @trek @onsclom @jeffsee55 @erikareads
/.github/workflows @TooTallNate @EndangeredMassa @trek @onsclom @jeffsee55 @erikareads @ijjk
/packages/fs-detectors @TooTallNate @EndangeredMassa @trek @onsclom @jeffsee55 @erikareads @agadzik @chloetedder
/packages/next @TooTallNate @EndangeredMassa @trek @onsclom @jeffsee55 @erikareads @timneutkens @ijjk @ztanner @huozhi @Ethan-Arrowood @styfle
/packages/next @TooTallNate @EndangeredMassa @trek @onsclom @jeffsee55 @erikareads @timneutkens @ijjk @ztanner @huozhi @Ethan-Arrowood
/packages/routing-utils @TooTallNate @EndangeredMassa @trek @onsclom @jeffsee55 @erikareads @ijjk
/packages/static-build @TooTallNate @EndangeredMassa @trek @onsclom @jeffsee55 @erikareads
/packages/edge @TooTallNate @EndangeredMassa @trek @onsclom @jeffsee55 @erikareads @vercel/compute
/examples @TooTallNate @EndangeredMassa @trek @onsclom @jeffsee55 @erikareads @leerob
/examples/create-react-app @TooTallNate @EndangeredMassa @trek @onsclom @jeffsee55 @erikareads @Timer
/examples/nextjs @TooTallNate @EndangeredMassa @trek @onsclom @jeffsee55 @erikareads @timneutkens @ijjk @ztanner @huozhi @Ethan-Arrowood @styfle
/examples/nextjs @TooTallNate @EndangeredMassa @trek @onsclom @jeffsee55 @erikareads @timneutkens @ijjk @ztanner @huozhi @Ethan-Arrowood
/packages/node @TooTallNate @EndangeredMassa @trek @onsclom @jeffsee55 @erikareads @Kikobeats
# Unrestricted Paths

View File

@@ -63,16 +63,21 @@ updates:
allow:
- dependency-name: '@remix-run*'
- dependency-name: '@shopify*'
- dependency-name: 'remix*'
ignore:
- dependency-name: '@remix-run*'
update-types:
['version-update:semver-major', 'version-update:semver-patch']
- dependency-name: 'remix*'
update-types:
['version-update:semver-major', 'version-update:semver-patch']
- dependency-name: '@shopify*'
update-types:
['version-update:semver-major', 'version-update:semver-patch']
groups:
core:
patterns:
- 'remix*'
- '@remix-run*'
- '@shopify*'
update-types:

124
.github/workflows/test-18.yml vendored Normal file
View File

@@ -0,0 +1,124 @@
name: Tests Node.js v18
on:
push:
branches:
- main
tags:
- '!*'
pull_request:
env:
NODE_VERSION: '18'
TURBO_REMOTE_ONLY: 'true'
TURBO_TEAM: 'vercel'
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
setup:
name: Find Changes
runs-on: ubuntu-latest
outputs:
tests: ${{ steps['set-tests'].outputs['tests'] }}
dplUrl: ${{ steps.waitForTarball.outputs.url }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: install pnpm@8.3.1
run: npm i -g pnpm@8.3.1
- run: pnpm install
- id: set-tests
run: |
TESTS_ARRAY=$(node utils/chunk-tests-18.js $SCRIPT_NAME)
echo "Files to test:"
echo "$TESTS_ARRAY"
echo "tests=$TESTS_ARRAY" >> $GITHUB_OUTPUT
- uses: patrickedqvist/wait-for-vercel-preview@bfdff514ff78a669f2536e9f4dd4ef5813a704a2
id: waitForTarball
with:
token: ${{ secrets.GITHUB_TOKEN }}
max_timeout: 360
check_interval: 5
test:
timeout-minutes: 120
runs-on: ${{ matrix.runner }}
name: ${{matrix.scriptName}} (${{matrix.packageName}}, ${{matrix.chunkNumber}}, ${{ matrix.runner }})
if: ${{ needs.setup.outputs['tests'] != '[]' }}
needs:
- setup
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.setup.outputs['tests']) }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.nodeVersion || env.NODE_VERSION }}
# yarn 1.22.21 introduced a Corepack bug when running tests.
# this can be removed once https://github.com/yarnpkg/yarn/issues/9015 is resolved
- name: install yarn@1.22.19
run: npm i -g yarn@1.22.19
- name: install pnpm@8.3.1
run: npm i -g pnpm@8.3.1
- run: pnpm install
- name: Build ${{matrix.packageName}} and all its dependencies
run: node utils/gen.js && node_modules/.bin/turbo run build --cache-dir=".turbo" --log-order=stream --scope=${{matrix.packageName}} --include-dependencies --no-deps
env:
FORCE_COLOR: '1'
- name: Test ${{matrix.packageName}}
run: node utils/gen.js && node_modules/.bin/turbo run ${{matrix.testScript}} --summarize --cache-dir=".turbo" --log-order=stream --scope=${{matrix.packageName}} --no-deps -- ${{ join(matrix.testPaths, ' ') }}
shell: bash
env:
JEST_JUNIT_OUTPUT_FILE: ${{github.workspace}}/.junit-reports/${{matrix.scriptName}}-${{matrix.packageName}}-${{matrix.chunkNumber}}-${{ matrix.runner }}.xml
VERCEL_CLI_VERSION: ${{ needs.setup.outputs.dplUrl }}/tarballs/vercel.tgz
VERCEL_TEST_TOKEN: ${{ secrets.VERCEL_TEST_TOKEN }}
VERCEL_TEST_REGISTRATION_URL: ${{ secrets.VERCEL_TEST_REGISTRATION_URL }}
FORCE_COLOR: '1'
- name: 'Determine Turbo HIT or MISS'
if: ${{ !cancelled() }}
id: turbo-summary
shell: bash
run: |
TURBO_MISS_COUNT=`node utils/determine-turbo-hit-or-miss.js`
echo "MISS COUNT: $TURBO_MISS_COUNT"
echo "misses=$TURBO_MISS_COUNT" >> $GITHUB_OUTPUT
- name: 'Upload Test Report to Datadog'
if: ${{ steps['turbo-summary'].outputs.misses != '0' && !cancelled() }}
run: 'npx @datadog/datadog-ci@2.18.1 junit upload --service vercel-cli .junit-reports'
env:
DATADOG_API_KEY: ${{secrets.DATADOG_API_KEY_CLI}}
DD_ENV: ci
summary:
name: Summary
runs-on: ubuntu-latest
timeout-minutes: 5
if: always()
needs:
- test
steps:
- name: Check All
run: |-
for status in ${{ join(needs.*.result, ' ') }}
do
if [ "$status" != "success" ] && [ "$status" != "skipped" ]
then
echo "Some checks failed"
exit 1
fi
done

View File

@@ -1,4 +1,4 @@
name: Tests
name: Tests Node.js v16
on:
push:
@@ -99,7 +99,7 @@ jobs:
echo "misses=$TURBO_MISS_COUNT" >> $GITHUB_OUTPUT
- name: 'Upload Test Report to Datadog'
if: ${{ steps['turbo-summary'].outputs.misses != '0' && !cancelled() }}
run: 'npx @datadog/datadog-ci@2.18.1 junit upload --service vercel-cli .junit-reports'
run: 'npx @datadog/datadog-ci@2.36.0 junit upload --service vercel-cli .junit-reports'
env:
DATADOG_API_KEY: ${{secrets.DATADOG_API_KEY_CLI}}
DD_ENV: ci

View File

@@ -4,6 +4,12 @@
### Patch Changes
- examples: Update Astro template. ([#11687](https://github.com/vercel/vercel/pull/11687))
## null
### Patch Changes
- chore: update Nuxt example ([#10869](https://github.com/vercel/vercel/pull/10869))
## null

View File

@@ -1,3 +1,6 @@
# astro
.astro
# build output
dist/
.output/
@@ -11,7 +14,6 @@ yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# environment variables
.env
.env.production

View File

@@ -3,10 +3,9 @@
This directory is a brief example of an [Astro](https://astro.build/) site that can be deployed to Vercel with zero configuration. This demo showcases:
- `/` - A static page (pre-rendered)
- `/ssr` - A page that uses server-side rendering (through [Vercel Edge Functions](https://vercel.com/docs/functions/edge-functions))
- `/ssr` - A page that uses server-side rendering (through [Vercel Functions](https://vercel.com/docs/functions))
- `/ssr-with-swr-caching` - Similar to the previous page, but also caches the response on the [Vercel Edge Network](https://vercel.com/docs/edge-network/overview) using `cache-control` headers
- `/image` - Astro [Asset](https://docs.astro.build/en/guides/assets/) using Vercel [Image Optimization](https://vercel.com/docs/image-optimization)
- `/edge.json` - An Astro API Endpoint that returns JSON data using [Vercel Edge Functions](https://vercel.com/docs/functions/edge-functions)
- `/image` - Astro [Asset](https://docs.astro.build/en/guides/images/) using Vercel [Image Optimization](https://vercel.com/docs/image-optimization)
Learn more about [Astro on Vercel](https://vercel.com/docs/frameworks/astro).

View File

@@ -1,17 +0,0 @@
import { defineConfig } from 'astro/config';
// Use Vercel Edge Functions (Recommended)
import vercel from '@astrojs/vercel/edge';
// Can also use Serverless Functions
// import vercel from '@astrojs/vercel/serverless';
// Or a completely static build
// import vercel from '@astrojs/vercel/static';
export default defineConfig({
output: 'server',
experimental: {
assets: true
},
adapter: vercel({
imageService: true,
}),
});

View File

@@ -0,0 +1,9 @@
import { defineConfig } from 'astro/config';
import vercelServerless from '@astrojs/vercel/serverless';
export default defineConfig({
output: 'server',
adapter: vercelServerless({
imageService: true,
}),
});

View File

@@ -8,9 +8,9 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/vercel": "3.8.2",
"astro": "^2.10.14",
"react": "18.2.0",
"web-vitals": "^3.3.1"
"@astrojs/vercel": "7.6.0",
"astro": "^4.9.2",
"react": "18.3.1",
"web-vitals": "^4.0.1"
}
}

View File

@@ -1,9 +0,0 @@
export async function get() {
return new Response(JSON.stringify({ time: new Date() }), {
status: 200,
headers: {
'Content-Type': 'application/json',
'Cache-Control': 's-maxage=10, stale-while-revalidate',
},
});
}

View File

@@ -9,7 +9,7 @@
},
"devDependencies": {
"@types/jest": "27.4.1",
"@vercel/build-utils": "8.0.0",
"@vercel/build-utils": "8.2.2",
"@vercel/frameworks": "3.0.2"
},
"version": null

View File

@@ -9,18 +9,18 @@
"typecheck": "tsc"
},
"dependencies": {
"@remix-run/node": "^2.8.0",
"@remix-run/react": "^2.8.0",
"@remix-run/server-runtime": "^2.8.0",
"@remix-run/node": "^2.9.2",
"@remix-run/react": "^2.9.2",
"@remix-run/server-runtime": "^2.9.2",
"@vercel/analytics": "^1.2.2",
"@vercel/remix": "^2.8.0",
"@vercel/remix": "2.9.2-patch.2",
"isbot": "^4",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@remix-run/dev": "^2.8.0",
"@remix-run/eslint-config": "^2.8.0",
"@remix-run/dev": "^2.9.2",
"@remix-run/eslint-config": "^2.9.2",
"@types/react": "^18.2.20",
"@types/react-dom": "^18.2.7",
"eslint": "^8.38.0",

View File

@@ -1,5 +1,54 @@
# @vercel-internals/types
## 1.0.38
### Patch Changes
- Updated dependencies [[`5c12ed695`](https://github.com/vercel/vercel/commit/5c12ed69500ceff6a9dc544eab0acd7af64c044a), [`21444a38e`](https://github.com/vercel/vercel/commit/21444a38e50ed680c91b0e3955f15e378eeda64b), [`06d2d860e`](https://github.com/vercel/vercel/commit/06d2d860e47aed792247bf929805b180ed6e2dab)]:
- @vercel/build-utils@8.2.2
## 1.0.37
### Patch Changes
- Updated dependencies [[`83741a0eb`](https://github.com/vercel/vercel/commit/83741a0eb9e44457b083e8790a11eb89984e6357)]:
- @vercel/build-utils@8.2.1
## 1.0.36
### Patch Changes
- Updated dependencies [[`d3c1267e2`](https://github.com/vercel/vercel/commit/d3c1267e24082789ea6382cf6af81dd40df288ff), [`ccd7eb1fb`](https://github.com/vercel/vercel/commit/ccd7eb1fb78f7ac9effdbe1935de3bda82c97fe3)]:
- @vercel/build-utils@8.2.0
## 1.0.35
### Patch Changes
- Updated dependencies [[`ad6945435`](https://github.com/vercel/vercel/commit/ad69454352b519b2b0ed326f245c779530554bf2)]:
- @vercel/build-utils@8.1.3
## 1.0.34
### Patch Changes
- Updated dependencies [[`1682ad43d`](https://github.com/vercel/vercel/commit/1682ad43d0064b22b1248a7e946746b838f00076)]:
- @vercel/build-utils@8.1.2
## 1.0.33
### Patch Changes
- Updated dependencies [[`2f7a6ed5f`](https://github.com/vercel/vercel/commit/2f7a6ed5f92d454000f92247d3b6548e2064f4e6)]:
- @vercel/build-utils@8.1.1
## 1.0.32
### Patch Changes
- Updated dependencies [[`5014b1e82`](https://github.com/vercel/vercel/commit/5014b1e82a46181baeb727ffe6d14000b6a4b1d7)]:
- @vercel/build-utils@8.1.0
## 1.0.31
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"private": true,
"name": "@vercel-internals/types",
"version": "1.0.31",
"version": "1.0.38",
"types": "index.d.ts",
"main": "index.d.ts",
"files": [
@@ -10,7 +10,7 @@
"dependencies": {
"@types/node": "14.14.31",
"@vercel-internals/constants": "1.0.4",
"@vercel/build-utils": "8.0.0",
"@vercel/build-utils": "8.2.2",
"@vercel/routing-utils": "3.1.0"
},
"devDependencies": {

View File

@@ -1,5 +1,56 @@
# @vercel/build-utils
## 8.2.2
### Patch Changes
- Change node 16.x EOL for Vercel ([#11704](https://github.com/vercel/vercel/pull/11704))
- Improve error message and refactor ([#11706](https://github.com/vercel/vercel/pull/11706))
- [built-utils] Handle case of not having lockfile when corepack is enabled ([#11697](https://github.com/vercel/vercel/pull/11697))
## 8.2.1
### Patch Changes
- [node] update node@16 deprecation day ([#11671](https://github.com/vercel/vercel/pull/11671))
## 8.2.0
### Minor Changes
- fix corepack detection for package manager version determination ([#11596](https://github.com/vercel/vercel/pull/11596))
### Patch Changes
- Fix triggering of ignored project settings node version warning ([#11550](https://github.com/vercel/vercel/pull/11550))
## 8.1.3
### Patch Changes
- [build-utils] log more around package manager detection ([#11594](https://github.com/vercel/vercel/pull/11594))
## 8.1.2
### Patch Changes
- add log to package manager version detection ([#11592](https://github.com/vercel/vercel/pull/11592))
## 8.1.1
### Patch Changes
- [build-utils] pnpm lockfile testing and fixing ([#11591](https://github.com/vercel/vercel/pull/11591))
## 8.1.0
### Minor Changes
- Update pnpm version detection logic ([#11445](https://github.com/vercel/vercel/pull/11445))
Add support for pnpm 9
## 8.0.0
### Major Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/build-utils",
"version": "8.0.0",
"version": "8.2.2",
"license": "Apache-2.0",
"main": "./dist/index.js",
"types": "./dist/index.d.js",

View File

@@ -13,7 +13,7 @@ export const NODE_VERSIONS: NodeVersion[] = [
major: 16,
range: '16.x',
runtime: 'nodejs16.x',
discontinueDate: new Date('2024-06-15'),
discontinueDate: new Date('2025-01-31'),
},
{
major: 14,

View File

@@ -240,38 +240,51 @@ export function getSpawnOptions(
export async function getNodeVersion(
destPath: string,
nodeVersionFallback = process.env.VERCEL_PROJECT_SETTINGS_NODE_VERSION,
fallbackVersion = process.env.VERCEL_PROJECT_SETTINGS_NODE_VERSION,
config: Config = {},
meta: Meta = {},
availableVersions = getAvailableNodeVersions()
): Promise<NodeVersion> {
const latest = getLatestNodeVersion(availableVersions);
const latestVersion = getLatestNodeVersion(availableVersions);
if (meta.isDev) {
// Use the system-installed version of `node` in PATH for `vercel dev`
return { ...latest, runtime: 'nodejs' };
return { ...latestVersion, runtime: 'nodejs' };
}
const { packageJson } = await scanParentDirs(destPath, true);
let nodeVersion = config.nodeVersion || nodeVersionFallback;
let isAuto = true;
const configuredVersion = config.nodeVersion || fallbackVersion;
const packageJsonVersion = packageJson?.engines?.node;
const supportedNodeVersion = await getSupportedNodeVersion(
packageJsonVersion || configuredVersion,
!packageJsonVersion,
availableVersions
);
if (packageJson?.engines?.node) {
const { node } = packageJson.engines;
if (nodeVersion && validRange(node) && !intersects(nodeVersion, node)) {
if (
configuredVersion &&
!intersects(configuredVersion, supportedNodeVersion.range)
) {
console.warn(
`Warning: Due to "engines": { "node": "${node}" } in your \`package.json\` file, the Node.js Version defined in your Project Settings ("${nodeVersion}") will not apply. Learn More: http://vercel.link/node-version`
`Warning: Due to "engines": { "node": "${node}" } in your \`package.json\` file, the Node.js Version defined in your Project Settings ("${configuredVersion}") will not apply. Learn More: http://vercel.link/node-version`
);
} else if (coerce(node)?.raw === node) {
}
if (coerce(node)?.raw === node) {
console.warn(
`Warning: Detected "engines": { "node": "${node}" } in your \`package.json\` with major.minor.patch, but only major Node.js Version can be selected. Learn More: http://vercel.link/node-version`
);
} else if (validRange(node) && intersects(`${latest.major + 1}.x`, node)) {
} else if (
validRange(node) &&
intersects(`${latestVersion.major + 1}.x`, node)
) {
console.warn(
`Warning: Detected "engines": { "node": "${node}" } in your \`package.json\` that will automatically upgrade when a new major Node.js Version is released. Learn More: http://vercel.link/node-version`
);
}
nodeVersion = node;
isAuto = false;
}
return getSupportedNodeVersion(nodeVersion, isAuto, availableVersions);
return supportedNodeVersion;
}
export async function scanParentDirs(
@@ -340,7 +353,9 @@ export async function scanParentDirs(
// TODO: read "bun-lockfile-format-v0"
lockfileVersion = 0;
} else {
cliType = 'npm';
cliType = packageJson
? detectPackageManagerNameWithoutLockfile(packageJson)
: 'npm';
}
const packageJsonPath = pkgJsonPath || undefined;
@@ -353,6 +368,37 @@ export async function scanParentDirs(
};
}
function detectPackageManagerNameWithoutLockfile(packageJson: PackageJson) {
const packageJsonPackageManager = packageJson.packageManager;
if (usingCorepack(process.env, packageJsonPackageManager)) {
const corepackPackageManager = validateVersionSpecifier(
packageJsonPackageManager
);
switch (corepackPackageManager?.packageName) {
case 'npm':
case 'pnpm':
case 'yarn':
case 'bun':
return corepackPackageManager.packageName;
case undefined:
return 'npm';
default:
throw new Error(
`Unknown package manager "${corepackPackageManager?.packageName}". Change your package.json "packageManager" field to a known package manager: npm, pnpm, yarn, bun.`
);
}
}
return 'npm';
}
function usingCorepack(
env: { [x: string]: string | undefined },
packageJsonPackageManager: string | undefined
) {
const corepackFlagged = env.ENABLE_EXPERIMENTAL_COREPACK === '1';
return corepackFlagged && Boolean(packageJsonPackageManager);
}
export async function walkParentDirs({
base,
start,
@@ -413,9 +459,8 @@ export async function runNpmInstall(
try {
await runNpmInstallSema.acquire();
const { cliType, packageJsonPath, lockfileVersion } = await scanParentDirs(
destPath
);
const { cliType, packageJsonPath, packageJson, lockfileVersion } =
await scanParentDirs(destPath, true);
if (!packageJsonPath) {
debug(
@@ -450,6 +495,7 @@ export async function runNpmInstall(
opts.env = getEnvForPackageManager({
cliType,
lockfileVersion,
packageJsonPackageManager: packageJson?.packageManager,
nodeVersion,
env,
});
@@ -534,64 +580,249 @@ export async function runNpmInstall(
export function getEnvForPackageManager({
cliType,
lockfileVersion,
packageJsonPackageManager,
nodeVersion,
env,
}: {
cliType: CliType;
lockfileVersion: number | undefined;
packageJsonPackageManager?: string | undefined;
nodeVersion: NodeVersion | undefined;
env: { [x: string]: string | undefined };
}) {
const corepackEnabled = usingCorepack(env, packageJsonPackageManager);
const {
detectedLockfile,
detectedPackageManager,
path: newPath,
yarnNodeLinker,
} = getPathForPackageManager({
} = getPathOverrideForPackageManager({
cliType,
lockfileVersion,
corepackEnabled,
nodeVersion,
env,
});
if (corepackEnabled) {
debug(
`Detected corepack use for "${packageJsonPackageManager}". Not overriding package manager version.`
);
} else {
debug(
`Detected ${detectedPackageManager}. Added "${newPath}" to path. Based on assumed package manager "${cliType}", lockfile "${detectedLockfile}", and lockfileVersion "${lockfileVersion}"`
);
}
const newEnv: { [x: string]: string | undefined } = {
...env,
};
if (newPath) {
const alreadyInPath = (newPath: string) => {
const oldPath = env.PATH ?? '';
return oldPath.split(path.delimiter).includes(newPath);
};
if (newPath && !alreadyInPath(newPath)) {
// Ensure that the binaries of the detected package manager are at the
// beginning of the `$PATH`.
const oldPath = env.PATH + '';
newEnv.PATH = `${newPath}${path.delimiter}${oldPath}`;
}
if (yarnNodeLinker) {
newEnv.YARN_NODE_LINKER = yarnNodeLinker;
}
if (detectedLockfile && detectedPackageManager) {
// For pnpm we also show the version of the lockfile we found
const versionString =
cliType === 'pnpm' ? `version ${lockfileVersion} ` : '';
if (detectedLockfile && detectedPackageManager) {
// For pnpm we also show the version of the lockfile we found
const versionString =
cliType === 'pnpm' ? `version ${lockfileVersion} ` : '';
console.log(
`Detected \`${detectedLockfile}\` ${versionString}generated by ${detectedPackageManager}`
);
if (cliType === 'bun') {
console.warn(
'Warning: Bun is used as a package manager at build time only, not at runtime with Functions'
console.log(
`Detected \`${detectedLockfile}\` ${versionString}generated by ${detectedPackageManager}`
);
if (cliType === 'bun') {
console.warn(
'Warning: Bun is used as a package manager at build time only, not at runtime with Functions'
);
}
}
}
if (cliType === 'yarn' && !env.YARN_NODE_LINKER) {
newEnv.YARN_NODE_LINKER = 'node-modules';
}
return newEnv;
}
type DetectedPnpmVersion =
| 'not found'
| 'pnpm 6'
| 'pnpm 7'
| 'pnpm 8'
| 'pnpm 9'
| 'corepack_enabled';
function detectPnpmVersion(
lockfileVersion: number | undefined,
corepackEnabled: boolean
): DetectedPnpmVersion {
switch (true) {
case corepackEnabled:
return 'corepack_enabled';
case lockfileVersion === undefined:
return 'not found';
case lockfileVersion === 5.3:
return 'pnpm 6';
case lockfileVersion === 5.4:
return 'pnpm 7';
case lockfileVersion === 6.0 || lockfileVersion === 6.1:
return 'pnpm 8';
case lockfileVersion === 7.0 || lockfileVersion === 9.0:
return 'pnpm 9';
default:
return 'not found';
}
}
function shouldUseNpm7(
lockfileVersion: number | undefined,
nodeVersion: NodeVersion | undefined
): boolean {
if (lockfileVersion === undefined) return false;
return lockfileVersion >= 2 && (nodeVersion?.major || 0) < 16;
}
/**
* Helper to get the binary paths that link to the used package manager.
* Note: Make sure it doesn't contain any `console.log` calls.
*/
export function getPathOverrideForPackageManager({
cliType,
lockfileVersion,
corepackEnabled,
nodeVersion,
}: {
cliType: CliType;
lockfileVersion: number | undefined;
corepackEnabled: boolean;
nodeVersion: NodeVersion | undefined;
}): {
/**
* Which lockfile was detected.
*/
detectedLockfile: string | undefined;
/**
* Detected package manager that generated the found lockfile.
*/
detectedPackageManager: string | undefined;
/**
* Value of $PATH that includes the binaries for the detected package manager.
* Undefined if no $PATH are necessary.
*/
path: string | undefined;
} {
const no_override = {
detectedLockfile: undefined,
detectedPackageManager: undefined,
path: undefined,
};
switch (cliType) {
case 'npm':
switch (true) {
case corepackEnabled:
return no_override;
case shouldUseNpm7(lockfileVersion, nodeVersion):
return {
path: '/node16/bin-npm7',
detectedLockfile: 'package-lock.json',
detectedPackageManager: 'npm 7+',
};
default:
return no_override;
}
case 'pnpm':
switch (detectPnpmVersion(lockfileVersion, corepackEnabled)) {
case 'corepack_enabled':
return no_override;
case 'pnpm 7':
// pnpm 7
return {
path: '/pnpm7/node_modules/.bin',
detectedLockfile: 'pnpm-lock.yaml',
detectedPackageManager: 'pnpm 7',
};
case 'pnpm 8':
// pnpm 8
return {
path: '/pnpm8/node_modules/.bin',
detectedLockfile: 'pnpm-lock.yaml',
detectedPackageManager: 'pnpm 8',
};
case 'pnpm 9':
// pnpm 9
return {
path: '/pnpm9/node_modules/.bin',
detectedLockfile: 'pnpm-lock.yaml',
detectedPackageManager: 'pnpm 9',
};
case 'pnpm 6':
default:
return no_override;
}
case 'bun':
switch (true) {
case corepackEnabled:
return no_override;
default:
// Bun 1
return {
path: '/bun1',
detectedLockfile: 'bun.lockb',
detectedPackageManager: 'Bun',
};
}
case 'yarn':
return no_override;
}
}
function validateVersionSpecifier(version?: string) {
if (!version) {
return undefined;
}
const [before, after, ...extra] = version.split('@');
if (extra.length) {
// should not have more than one `@`
return undefined;
}
if (!before) {
// should have a package before the `@`
return undefined;
}
if (!after) {
// should have a version after the `@`
return undefined;
}
if (!validRange(after)) {
// the version after the `@` should be a valid semver value
return undefined;
}
return {
packageName: before,
packageVersionRange: after,
};
}
/**
* Helper to get the binary paths that link to the used package manager.
* Note: Make sure it doesn't contain any `console.log` calls.
* @deprecated use `getEnvForPackageManager` instead
*/
export function getPathForPackageManager({
cliType,
lockfileVersion,
@@ -622,70 +853,36 @@ export function getPathForPackageManager({
*/
yarnNodeLinker: string | undefined;
} {
let detectedLockfile: string | undefined;
let detectedPackageManager: string | undefined;
let pathValue: string | undefined;
let yarnNodeLinker: string | undefined;
const oldPath = env.PATH + '';
const npm7 = '/node16/bin-npm7';
const pnpm7 = '/pnpm7/node_modules/.bin';
const pnpm8 = '/pnpm8/node_modules/.bin';
const bun1 = '/bun1';
// This is not the correct check for whether or not corepack is being used. For that, you'd have to check
// the package.json's `packageManager` property. However, this deprecated function is keeping it's old,
// broken behavior.
const corepackEnabled = env.ENABLE_EXPERIMENTAL_COREPACK === '1';
if (cliType === 'npm') {
if (
typeof lockfileVersion === 'number' &&
lockfileVersion >= 2 &&
(nodeVersion?.major || 0) < 16 &&
!oldPath.includes(npm7) &&
!corepackEnabled
) {
// npm 7
pathValue = npm7;
detectedLockfile = 'package-lock.json';
detectedPackageManager = 'npm 7+';
}
} else if (cliType === 'pnpm') {
if (
typeof lockfileVersion === 'number' &&
lockfileVersion === 5.4 &&
!oldPath.includes(pnpm7) &&
!corepackEnabled
) {
// pnpm 7
pathValue = pnpm7;
detectedLockfile = 'pnpm-lock.yaml';
detectedPackageManager = 'pnpm 7';
} else if (
typeof lockfileVersion === 'number' &&
lockfileVersion >= 6 &&
!oldPath.includes(pnpm8) &&
!corepackEnabled
) {
// pnpm 8
pathValue = pnpm8;
detectedLockfile = 'pnpm-lock.yaml';
detectedPackageManager = 'pnpm 8';
}
} else if (cliType === 'bun') {
if (!oldPath.includes(bun1) && !corepackEnabled) {
// Bun 1
pathValue = bun1;
detectedLockfile = 'bun.lockb';
detectedPackageManager = 'Bun';
}
} else {
// Yarn v2 PnP mode may be activated, so force "node-modules" linker style
if (!env.YARN_NODE_LINKER) {
yarnNodeLinker = 'node-modules';
}
}
return {
detectedLockfile,
detectedPackageManager,
path: pathValue,
yarnNodeLinker,
const overrides = getPathOverrideForPackageManager({
cliType,
lockfileVersion,
corepackEnabled,
nodeVersion,
});
const alreadyInPath = (newPath: string) => {
const oldPath = env.PATH ?? '';
return oldPath.split(path.delimiter).includes(newPath);
};
switch (true) {
case cliType === 'yarn' && !env.YARN_NODE_LINKER:
return { ...overrides, yarnNodeLinker: 'node-modules' };
case alreadyInPath(overrides.path ?? ''):
return {
detectedLockfile: undefined,
detectedPackageManager: undefined,
path: undefined,
yarnNodeLinker: undefined,
};
default:
return { ...overrides, yarnNodeLinker: undefined };
}
}
export async function runCustomInstallCommand({
@@ -700,10 +897,14 @@ export async function runCustomInstallCommand({
spawnOpts?: SpawnOptions;
}) {
console.log(`Running "install" command: \`${installCommand}\`...`);
const { cliType, lockfileVersion } = await scanParentDirs(destPath);
const { cliType, lockfileVersion, packageJson } = await scanParentDirs(
destPath,
true
);
const env = getEnvForPackageManager({
cliType,
lockfileVersion,
packageJsonPackageManager: packageJson?.packageManager,
nodeVersion,
env: spawnOpts?.env || {},
});
@@ -741,6 +942,7 @@ export async function runPackageJsonScript(
env: getEnvForPackageManager({
cliType,
lockfileVersion,
packageJsonPackageManager: packageJson?.packageManager,
nodeVersion: undefined,
env: cloneEnv(process.env, spawnOpts?.env),
}),

View File

@@ -4,7 +4,7 @@
"probes": [
{
"path": "/",
"mustContain": "pnpm version: 6",
"mustContain": "pnpm version: 7",
"logMustContain": "pnpm run build"
}
]

View File

@@ -1,5 +1,6 @@
import { delimiter } from 'path';
import { getEnvForPackageManager, getPathForPackageManager } from '../src';
import { getPathOverrideForPackageManager } from '../src/fs/run-user-scripts';
describe('Test `getEnvForPackageManager()`', () => {
let consoleLogSpy: jest.SpyInstance;
@@ -34,6 +35,7 @@ describe('Test `getEnvForPackageManager()`', () => {
args: {
cliType: 'npm',
nodeVersion: { major: 14, range: '14.x', runtime: 'nodejs14.x' },
packageJsonPackageManager: undefined,
lockfileVersion: 1,
env: {
FOO: 'bar',
@@ -50,6 +52,7 @@ describe('Test `getEnvForPackageManager()`', () => {
args: {
cliType: 'npm',
nodeVersion: { major: 14, range: '14.x', runtime: 'nodejs14.x' },
packageJsonPackageManager: undefined,
lockfileVersion: 2,
env: {
FOO: 'bar',
@@ -68,6 +71,7 @@ describe('Test `getEnvForPackageManager()`', () => {
args: {
cliType: 'npm',
nodeVersion: { major: 14, range: '14.x', runtime: 'nodejs14.x' },
packageJsonPackageManager: 'pnpm@latest',
lockfileVersion: 2,
env: {
FOO: 'bar',
@@ -86,6 +90,7 @@ describe('Test `getEnvForPackageManager()`', () => {
args: {
cliType: 'npm',
nodeVersion: { major: 14, range: '14.x', runtime: 'nodejs14.x' },
packageJsonPackageManager: undefined,
lockfileVersion: 2,
env: {
FOO: 'bar',
@@ -104,6 +109,7 @@ describe('Test `getEnvForPackageManager()`', () => {
args: {
cliType: 'npm',
nodeVersion: { major: 16, range: '16.x', runtime: 'nodejs16.x' },
packageJsonPackageManager: undefined,
lockfileVersion: 2,
env: {
FOO: 'bar',
@@ -122,6 +128,7 @@ describe('Test `getEnvForPackageManager()`', () => {
args: {
cliType: 'yarn',
nodeVersion: { major: 16, range: '16.x', runtime: 'nodejs16.x' },
packageJsonPackageManager: undefined,
lockfileVersion: 2,
env: {
FOO: 'bar',
@@ -139,6 +146,7 @@ describe('Test `getEnvForPackageManager()`', () => {
args: {
cliType: 'yarn',
nodeVersion: { major: 16, range: '16.x', runtime: 'nodejs16.x' },
packageJsonPackageManager: undefined,
lockfileVersion: 2,
env: {
FOO: 'bar',
@@ -157,6 +165,7 @@ describe('Test `getEnvForPackageManager()`', () => {
args: {
cliType: 'pnpm',
nodeVersion: { major: 16, range: '16.x', runtime: 'nodejs16.x' },
packageJsonPackageManager: undefined,
lockfileVersion: 5.4,
env: {
FOO: 'bar',
@@ -171,11 +180,52 @@ describe('Test `getEnvForPackageManager()`', () => {
'Detected `pnpm-lock.yaml` version 5.4 generated by pnpm 7',
consoleWarnOutput: null,
},
{
name: 'should set path if pnpm 8 is detected',
args: {
cliType: 'pnpm',
nodeVersion: { major: 18, range: '18.x', runtime: 'nodejs18.x' },
packageJsonPackageManager: undefined,
lockfileVersion: 6.0,
env: {
FOO: 'bar',
PATH: 'foo',
},
},
want: {
FOO: 'bar',
PATH: `/pnpm8/node_modules/.bin${delimiter}foo`,
},
consoleLogOutput:
'Detected `pnpm-lock.yaml` version 6 generated by pnpm 8',
consoleWarnOutput: null,
},
{
name: 'should set path if pnpm 8 is detected',
args: {
cliType: 'pnpm',
nodeVersion: { major: 18, range: '18.x', runtime: 'nodejs18.x' },
packageJsonPackageManager: undefined,
lockfileVersion: 9.0,
env: {
FOO: 'bar',
PATH: 'foo',
},
},
want: {
FOO: 'bar',
PATH: `/pnpm9/node_modules/.bin${delimiter}foo`,
},
consoleLogOutput:
'Detected `pnpm-lock.yaml` version 9 generated by pnpm 9',
consoleWarnOutput: null,
},
{
name: 'should set path if bun v1 is detected',
args: {
cliType: 'bun',
nodeVersion: { major: 18, range: '18.x', runtime: 'nodejs18.x' },
packageJsonPackageManager: undefined,
lockfileVersion: 0,
env: {
FOO: 'bar',
@@ -195,6 +245,7 @@ describe('Test `getEnvForPackageManager()`', () => {
args: {
cliType: 'pnpm',
nodeVersion: { major: 16, range: '16.x', runtime: 'nodejs16.x' },
packageJsonPackageManager: 'npm@latest',
lockfileVersion: 5.4,
env: {
FOO: 'bar',
@@ -213,6 +264,7 @@ describe('Test `getEnvForPackageManager()`', () => {
args: {
cliType: 'pnpm',
nodeVersion: { major: 16, range: '16.x', runtime: 'nodejs16.x' },
packageJsonPackageManager: undefined,
lockfileVersion: 5.4,
env: {
FOO: 'bar',
@@ -226,27 +278,12 @@ describe('Test `getEnvForPackageManager()`', () => {
consoleLogOutput: null,
consoleWarnOutput: null,
},
{
name: 'should not set path if pnpm 6 is detected',
args: {
cliType: 'pnpm',
nodeVersion: { major: 14, range: '14.x', runtime: 'nodejs14.x' },
lockfileVersion: 5.3,
env: {
FOO: 'bar',
},
},
want: {
FOO: 'bar',
},
consoleLogOutput: null,
consoleWarnOutput: null,
},
])('$name', ({ args, want, consoleLogOutput, consoleWarnOutput }) => {
expect(
getEnvForPackageManager({
cliType: args.cliType,
lockfileVersion: args.lockfileVersion,
packageJsonPackageManager: args.packageJsonPackageManager,
nodeVersion: args.nodeVersion,
env: args.env,
})
@@ -268,11 +305,210 @@ describe('Test `getEnvForPackageManager()`', () => {
});
});
describe('Test `getPathForPackageManager()`', () => {
describe('Test `getPathOverrideForPackageManager()`', () => {
test.each<{
name: string;
args: Parameters<typeof getEnvForPackageManager>[0];
want: unknown;
}>([
{
name: 'should do nothing to env for npm < 6 and node < 16',
args: {
cliType: 'npm',
nodeVersion: { major: 14, range: '14.x', runtime: 'nodejs14.x' },
packageJsonPackageManager: undefined,
lockfileVersion: 1,
env: {
FOO: 'bar',
},
},
want: {
detectedLockfile: undefined,
detectedPackageManager: undefined,
path: undefined,
},
},
{
name: 'should set path if npm 7+ is detected and node < 16',
args: {
cliType: 'npm',
nodeVersion: { major: 14, range: '14.x', runtime: 'nodejs14.x' },
packageJsonPackageManager: undefined,
lockfileVersion: 2,
env: {
FOO: 'bar',
PATH: 'foo',
},
},
want: {
detectedLockfile: 'package-lock.json',
detectedPackageManager: 'npm 7+',
path: '/node16/bin-npm7',
},
},
{
name: 'should not set npm path if corepack enabled',
args: {
cliType: 'npm',
nodeVersion: { major: 14, range: '14.x', runtime: 'nodejs14.x' },
packageJsonPackageManager: 'pnpm@latest',
lockfileVersion: 2,
env: {
FOO: 'bar',
ENABLE_EXPERIMENTAL_COREPACK: '1',
},
},
want: {
detectedLockfile: undefined,
detectedPackageManager: undefined,
path: undefined,
},
},
{
name: 'should not set path if node is 16 and npm 7+ is detected',
args: {
cliType: 'npm',
nodeVersion: { major: 16, range: '16.x', runtime: 'nodejs16.x' },
packageJsonPackageManager: undefined,
lockfileVersion: 2,
env: {
FOO: 'bar',
PATH: 'foo',
},
},
want: {
detectedLockfile: undefined,
detectedPackageManager: undefined,
path: undefined,
},
},
{
name: 'should not set path if pnpm 6 is detected',
args: {
cliType: 'pnpm',
nodeVersion: { major: 16, range: '16.x', runtime: 'nodejs16.x' },
packageJsonPackageManager: undefined,
lockfileVersion: 5.3, // detects as pnpm@6, which is the default
env: {
FOO: 'bar',
PATH: 'foo',
},
},
want: {
detectedLockfile: undefined,
detectedPackageManager: undefined,
path: undefined,
},
},
{
name: 'should set path if pnpm 7+ is detected',
args: {
cliType: 'pnpm',
nodeVersion: { major: 16, range: '16.x', runtime: 'nodejs16.x' },
packageJsonPackageManager: undefined,
lockfileVersion: 5.4,
env: {
FOO: 'bar',
PATH: 'foo',
},
},
want: {
detectedLockfile: 'pnpm-lock.yaml',
detectedPackageManager: 'pnpm 7',
path: '/pnpm7/node_modules/.bin',
},
},
{
name: 'should set path if pnpm 8 is detected',
args: {
cliType: 'pnpm',
nodeVersion: { major: 18, range: '18.x', runtime: 'nodejs18.x' },
packageJsonPackageManager: undefined,
lockfileVersion: 6.1,
env: {
FOO: 'bar',
PATH: 'foo',
},
},
want: {
detectedLockfile: 'pnpm-lock.yaml',
detectedPackageManager: 'pnpm 8',
path: '/pnpm8/node_modules/.bin',
},
},
{
name: 'should set path if pnpm 9 is detected',
args: {
cliType: 'pnpm',
nodeVersion: { major: 18, range: '18.x', runtime: 'nodejs18.x' },
packageJsonPackageManager: undefined,
lockfileVersion: 7.0,
env: {
FOO: 'bar',
PATH: 'foo',
},
},
want: {
detectedLockfile: 'pnpm-lock.yaml',
detectedPackageManager: 'pnpm 9',
path: '/pnpm9/node_modules/.bin',
},
},
{
name: 'should set path if bun v1 is detected',
args: {
cliType: 'bun',
nodeVersion: { major: 18, range: '18.x', runtime: 'nodejs18.x' },
packageJsonPackageManager: undefined,
lockfileVersion: 0,
env: {
FOO: 'bar',
PATH: '/usr/local/bin',
},
},
want: {
detectedLockfile: 'bun.lockb',
detectedPackageManager: 'Bun',
path: '/bun1',
},
},
{
name: 'should not set pnpm path if corepack is enabled',
args: {
cliType: 'pnpm',
nodeVersion: { major: 16, range: '16.x', runtime: 'nodejs16.x' },
packageJsonPackageManager: 'npm@latest',
lockfileVersion: 5.4,
env: {
FOO: 'bar',
ENABLE_EXPERIMENTAL_COREPACK: '1',
},
},
want: {
detectedLockfile: undefined,
detectedPackageManager: undefined,
path: undefined,
},
},
])('$name', ({ args, want }) => {
expect(
getPathOverrideForPackageManager({
cliType: args.cliType,
lockfileVersion: args.lockfileVersion,
// naive assumption that enabling corepack as a feature means it's used, but this is fine for tests
corepackEnabled: Boolean(args.env.ENABLE_EXPERIMENTAL_COREPACK),
nodeVersion: args.nodeVersion,
})
).toStrictEqual(want);
});
});
describe('Test `getPathForPackageManager()`', () => {
test.each<{
name: string;
args: Parameters<typeof getPathForPackageManager>[0];
want: unknown;
}>([
{
name: 'should do nothing to env for npm < 6 and node < 16',
@@ -470,23 +706,6 @@ describe('Test `getPathForPackageManager()`', () => {
yarnNodeLinker: undefined,
},
},
{
name: 'should not set path if pnpm 6 is detected',
args: {
cliType: 'pnpm',
nodeVersion: { major: 14, range: '14.x', runtime: 'nodejs14.x' },
lockfileVersion: 5.3,
env: {
FOO: 'bar',
},
},
want: {
detectedLockfile: undefined,
detectedPackageManager: undefined,
path: undefined,
yarnNodeLinker: undefined,
},
},
])('$name', ({ args, want }) => {
expect(
getPathForPackageManager({

View File

@@ -221,6 +221,21 @@ it('should warn when package.json engines is greater than', async () => {
]);
});
it('should warn when project settings gets overrided', async () => {
expect(
await getNodeVersion(
path.join(__dirname, 'pkg-engine-node-greaterthan'),
undefined,
{ nodeVersion: '16.x' },
{}
)
).toHaveProperty('range', '20.x');
expect(warningMessages).toStrictEqual([
'Warning: Due to "engines": { "node": ">=16" } in your `package.json` file, the Node.js Version defined in your Project Settings ("16.x") will not apply. Learn More: http://vercel.link/node-version',
'Warning: Detected "engines": { "node": ">=16" } in your `package.json` that will automatically upgrade when a new major Node.js Version is released. Learn More: http://vercel.link/node-version',
]);
});
it('should not warn when package.json engines matches project setting from config', async () => {
expect(
await getNodeVersion(
@@ -271,7 +286,7 @@ it('should throw for discontinued versions', async () => {
// Mock a future date so that Node 16 becomes discontinued
const realDateNow = Date.now;
try {
global.Date.now = () => new Date('2024-07-16').getTime();
global.Date.now = () => new Date('2025-03-01').getTime();
expect(getSupportedNodeVersion('8.10.x', false)).rejects.toThrow();
expect(getSupportedNodeVersion('8.10.x', true)).rejects.toThrow();
@@ -341,8 +356,8 @@ it('should warn for deprecated versions, soon to be discontinued', async () => {
'Error: Node.js version 12.x has reached End-of-Life. Deployments created on or after 2022-10-03 will fail to build. Please set Node.js Version to 20.x in your Project Settings to use Node.js 20.',
'Error: Node.js version 14.x has reached End-of-Life. Deployments created on or after 2023-08-15 will fail to build. Please set "engines": { "node": "20.x" } in your `package.json` file to use Node.js 20.',
'Error: Node.js version 14.x has reached End-of-Life. Deployments created on or after 2023-08-15 will fail to build. Please set Node.js Version to 20.x in your Project Settings to use Node.js 20.',
'Error: Node.js version 16.x has reached End-of-Life. Deployments created on or after 2024-06-15 will fail to build. Please set "engines": { "node": "20.x" } in your `package.json` file to use Node.js 20.',
'Error: Node.js version 16.x has reached End-of-Life. Deployments created on or after 2024-06-15 will fail to build. Please set Node.js Version to 20.x in your Project Settings to use Node.js 20.',
'Error: Node.js version 16.x has reached End-of-Life. Deployments created on or after 2025-01-31 will fail to build. Please set "engines": { "node": "20.x" } in your `package.json` file to use Node.js 20.',
'Error: Node.js version 16.x has reached End-of-Life. Deployments created on or after 2025-01-31 will fail to build. Please set Node.js Version to 20.x in your Project Settings to use Node.js 20.',
]);
} finally {
global.Date.now = realDateNow;

View File

@@ -1,5 +1,126 @@
# vercel
## 34.2.6
### Patch Changes
- [built-utils] Handle case of not having lockfile when corepack is enabled ([#11697](https://github.com/vercel/vercel/pull/11697))
- Updated dependencies [[`5c12ed695`](https://github.com/vercel/vercel/commit/5c12ed69500ceff6a9dc544eab0acd7af64c044a), [`21444a38e`](https://github.com/vercel/vercel/commit/21444a38e50ed680c91b0e3955f15e378eeda64b), [`fa9789a93`](https://github.com/vercel/vercel/commit/fa9789a93ebe64c4246f441590cb695d296af336), [`c925dc4a1`](https://github.com/vercel/vercel/commit/c925dc4a1bf3a47b684b5f7fd788ddd24ba1ed1e), [`06d2d860e`](https://github.com/vercel/vercel/commit/06d2d860e47aed792247bf929805b180ed6e2dab), [`b735f37fd`](https://github.com/vercel/vercel/commit/b735f37fd92c707040e72084b0fdb4f8fd01dd51)]:
- @vercel/build-utils@8.2.2
- @vercel/next@4.2.16
- @vercel/redwood@2.0.10
- @vercel/remix-builder@2.1.7
- @vercel/node@3.1.7
- @vercel/static-build@2.5.11
## 34.2.5
### Patch Changes
- Adds a route for the `.rsc` pathname as well when app has ppr enabled but not all routes. ([#11681](https://github.com/vercel/vercel/pull/11681))
- Updated dependencies [[`7457767a7`](https://github.com/vercel/vercel/commit/7457767a77b03662c103a658273a46cf78359068), [`4337ea065`](https://github.com/vercel/vercel/commit/4337ea0654c4ee2c91c4464540f879d43da6696f)]:
- @vercel/next@4.2.15
## 34.2.4
### Patch Changes
- Updated dependencies [[`3eb9d8c89`](https://github.com/vercel/vercel/commit/3eb9d8c8929592960d88e0395e2a2443f7304d6b), [`83741a0eb`](https://github.com/vercel/vercel/commit/83741a0eb9e44457b083e8790a11eb89984e6357)]:
- @vercel/python@4.3.0
- @vercel/build-utils@8.2.1
- @vercel/node@3.1.6
- @vercel/static-build@2.5.10
## 34.2.3
### Patch Changes
- Don't create streaming lambdas for pages router routes ([#11660](https://github.com/vercel/vercel/pull/11660))
- Updated dependencies [[`c9d53d4e3`](https://github.com/vercel/vercel/commit/c9d53d4e3e4591b9b6bde86100564c9ee4c6d1d4), [`5f561f8cf`](https://github.com/vercel/vercel/commit/5f561f8cfa4720801a5cf4598f193ab34539abb9)]:
- @vercel/next@4.2.14
## 34.2.2
### Patch Changes
- Fix related to erroring when a prefetch route is not provided but the route is PPR enabled ([#11638](https://github.com/vercel/vercel/pull/11638))
- Updated dependencies [[`8e44ef5b9`](https://github.com/vercel/vercel/commit/8e44ef5b9d2cdbe743c7f1e3534f182465fed9bf), [`61e6af374`](https://github.com/vercel/vercel/commit/61e6af3740296c11015d0c3da84ee205020b0ea6)]:
- @vercel/next@4.2.13
## 34.2.1
### Patch Changes
- Support incremental PPR for large applications ([#11625](https://github.com/vercel/vercel/pull/11625))
- Updated dependencies [[`73e558913`](https://github.com/vercel/vercel/commit/73e558913ab30ba097d7536a12fa8a7c967479f0)]:
- @vercel/next@4.2.12
## 34.2.0
### Minor Changes
- Stop sending system environment variables in dev ([#11526](https://github.com/vercel/vercel/pull/11526))
### Patch Changes
- Updated dependencies [[`d3c1267e2`](https://github.com/vercel/vercel/commit/d3c1267e24082789ea6382cf6af81dd40df288ff), [`ccd7eb1fb`](https://github.com/vercel/vercel/commit/ccd7eb1fb78f7ac9effdbe1935de3bda82c97fe3)]:
- @vercel/build-utils@8.2.0
- @vercel/node@3.1.5
- @vercel/static-build@2.5.9
## 34.1.14
### Patch Changes
- Updated dependencies [[`ad6945435`](https://github.com/vercel/vercel/commit/ad69454352b519b2b0ed326f245c779530554bf2)]:
- @vercel/build-utils@8.1.3
- @vercel/node@3.1.4
- @vercel/static-build@2.5.8
## 34.1.13
### Patch Changes
- Updated dependencies [[`1682ad43d`](https://github.com/vercel/vercel/commit/1682ad43d0064b22b1248a7e946746b838f00076)]:
- @vercel/build-utils@8.1.2
- @vercel/node@3.1.3
- @vercel/static-build@2.5.7
## 34.1.12
### Patch Changes
- Updated dependencies [[`67afc2608`](https://github.com/vercel/vercel/commit/67afc26085e2ebdaa33a8cbce112afec4cb1c4f5), [`2f7a6ed5f`](https://github.com/vercel/vercel/commit/2f7a6ed5f92d454000f92247d3b6548e2064f4e6)]:
- @vercel/next@4.2.11
- @vercel/build-utils@8.1.1
- @vercel/node@3.1.2
- @vercel/static-build@2.5.6
## 34.1.11
### Patch Changes
- Updated dependencies [[`5014b1e82`](https://github.com/vercel/vercel/commit/5014b1e82a46181baeb727ffe6d14000b6a4b1d7), [`18d1703d5`](https://github.com/vercel/vercel/commit/18d1703d5b4f2adc61fd56011f874c393fa57d0d), [`e87d4c14d`](https://github.com/vercel/vercel/commit/e87d4c14d0e718281f9ba91c9ec1cc6e142d383d), [`bc5fd4115`](https://github.com/vercel/vercel/commit/bc5fd41158ec9f36e5db1fe749589adcbaec6950)]:
- @vercel/build-utils@8.1.0
- @vercel/next@4.2.10
- @vercel/redwood@2.0.9
- @vercel/remix-builder@2.1.6
- @vercel/node@3.1.1
- @vercel/static-build@2.5.5
## 34.1.10
### Patch Changes
- Updated dependencies [[`119f80e96`](https://github.com/vercel/vercel/commit/119f80e9611a7a5a755aa689502dcdab323194aa), [`11584b0e9`](https://github.com/vercel/vercel/commit/11584b0e9b55f312f34d0d6467ab498e472ac9df), [`3023122d4`](https://github.com/vercel/vercel/commit/3023122d4e0dd292340d9e9e61ef232baf6e610d), [`0e774b6be`](https://github.com/vercel/vercel/commit/0e774b6be0c832213a64124e1f4fc6d150e87d9f)]:
- @vercel/next@4.2.9
- @vercel/static-build@2.5.4
## 34.1.9
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "vercel",
"version": "34.1.9",
"version": "34.2.6",
"preferGlobal": true,
"license": "Apache-2.0",
"description": "The command-line interface for Vercel",
@@ -12,8 +12,8 @@
},
"scripts": {
"test": "jest --reporters=default --reporters=jest-junit --env node --verbose --bail",
"vitest-unit-run": "pnpm vitest",
"vitest-unit": "pnpm jest test/unit/ --listTests",
"vitest-run": "vitest",
"vitest-unit": "jest test/unit/ --listTests",
"test-e2e": "rimraf test/fixtures/integration && pnpm test test/integration-1.test.ts test/integration-2.test.ts test/integration-3.test.ts",
"test-dev": "pnpm test test/dev/",
"coverage": "codecov",
@@ -32,17 +32,17 @@
"node": ">= 16"
},
"dependencies": {
"@vercel/build-utils": "8.0.0",
"@vercel/build-utils": "8.2.2",
"@vercel/fun": "1.1.0",
"@vercel/go": "3.1.1",
"@vercel/hydrogen": "1.0.2",
"@vercel/next": "4.2.8",
"@vercel/node": "3.1.0",
"@vercel/python": "4.2.0",
"@vercel/redwood": "2.0.8",
"@vercel/remix-builder": "2.1.5",
"@vercel/next": "4.2.16",
"@vercel/node": "3.1.7",
"@vercel/python": "4.3.0",
"@vercel/redwood": "2.0.10",
"@vercel/remix-builder": "2.1.7",
"@vercel/ruby": "2.1.0",
"@vercel/static-build": "2.5.3",
"@vercel/static-build": "2.5.11",
"chokidar": "3.3.1"
},
"devDependencies": {
@@ -92,11 +92,11 @@
"@types/yauzl-promise": "2.1.0",
"@vercel-internals/constants": "1.0.4",
"@vercel-internals/get-package-json": "1.0.0",
"@vercel-internals/types": "1.0.31",
"@vercel/client": "13.2.2",
"@vercel-internals/types": "1.0.38",
"@vercel/client": "13.2.9",
"@vercel/error-utils": "2.0.2",
"@vercel/frameworks": "3.0.2",
"@vercel/fs-detectors": "5.2.3",
"@vercel/fs-detectors": "5.2.4",
"@vercel/routing-utils": "3.1.0",
"@vitest/expect": "1.4.0",
"ajv": "6.12.2",

View File

@@ -70,7 +70,7 @@ export async function pullEnvRecords(
);
const query = new URLSearchParams();
let url = `/v1/env/pull/${projectId}`;
let url = `/v2/env/pull/${projectId}`;
if (target) {
url += `/${encodeURIComponent(target)}`;

View File

@@ -0,0 +1,32 @@
{
"name": "cli-extension-exit-code",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"dependencies": {
"cli-extension-fail": "file:../cli-extension-fail"
}
},
"../cli-extension-fail": {
"bin": {
"vercel-fail": "bin.js"
}
},
"../cli-extension-whoami": {
"extraneous": true,
"bin": {
"vercel-mywhoami": "bin.js"
}
},
"node_modules/cli-extension-fail": {
"resolved": "../cli-extension-fail",
"link": true
}
},
"dependencies": {
"cli-extension-fail": {
"version": "file:../cli-extension-fail"
}
}
}

View File

@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"cli-extension-fail": "file:../cli-extension-fail"
}
}

View File

@@ -0,0 +1,2 @@
#!/usr/bin/env node
process.exit(6);

View File

@@ -0,0 +1,6 @@
{
"name": "cli-extension-fail",
"bin": {
"vercel-fail": "bin.js"
}
}

View File

@@ -263,6 +263,7 @@ test('[vc build] should build project with corepack and select pnpm@7.1.0', asyn
path.join(directory, '.vercel/cache/corepack')
);
expect(contents).toEqual(['home', 'shim']);
expect(output.stdout).toMatch(/Running "pnpm run build"/gm);
} finally {
delete process.env.ENABLE_EXPERIMENTAL_COREPACK;
}
@@ -291,6 +292,7 @@ test('[vc build] should build project with corepack and select yarn@2.4.3', asyn
path.join(directory, '.vercel/cache/corepack')
);
expect(contents).toEqual(['home', 'shim']);
expect(output.stdout).toMatch(/Running "yarn run build"/gm);
} finally {
delete process.env.ENABLE_EXPERIMENTAL_COREPACK;
}
@@ -917,9 +919,9 @@ test('Deploy `api-env` fixture and test `vercel env` command', async () => {
expect(homeJson['MY_STDIN_VAR']).toBe('{"expect":"quotes"}');
expect(homeJson['MY_DECRYPTABLE_SECRET_ENV']).toBe('decryptable value');
// system env vars are automatically exposed
expect(apiJson['VERCEL']).toBe('1');
expect(homeJson['VERCEL']).toBe('1');
// system env vars are hidden in dev
expect(apiJson['VERCEL']).toBeUndefined();
expect(homeJson['VERCEL']).toBeUndefined();
// sleep before kill, otherwise the dev process doesn't clean up and exit properly
await sleep(100);
@@ -949,7 +951,7 @@ test('Deploy `api-env` fixture and test `vercel env` command', async () => {
async function vcEnvPullFetchSystemVars() {
const { exitCode, stdout, stderr } = await execCli(
binaryPath,
['env', 'pull', '-y'],
['env', 'pull', '-y', '--environment', 'production'],
{
cwd: target,
}
@@ -963,7 +965,7 @@ test('Deploy `api-env` fixture and test `vercel env` command', async () => {
expect(lines).toContain('VERCEL="1"');
expect(lines).toContain('VERCEL_URL=""');
expect(lines).toContain('VERCEL_ENV="development"');
expect(lines).toContain('VERCEL_ENV="production"');
expect(lines).toContain('VERCEL_GIT_PROVIDER=""');
expect(lines).toContain('VERCEL_GIT_REPO_SLUG=""');
}
@@ -980,22 +982,24 @@ test('Deploy `api-env` fixture and test `vercel env` command', async () => {
const localhostNoProtocol = localhost[0].slice('http://'.length);
const apiJson = await apiRes.json();
expect(apiJson['VERCEL']).toBe('1');
// environment variables are not set in dev
expect(apiJson['VERCEL']).toBeUndefined();
expect(apiJson['VERCEL_ENV']).toBeUndefined();
expect(apiJson['VERCEL_GIT_PROVIDER']).toBeUndefined();
expect(apiJson['VERCEL_GIT_REPO_SLUG']).toBeUndefined();
// except for these because vc dev
expect(apiJson['VERCEL_URL']).toBe(localhostNoProtocol);
expect(apiJson['VERCEL_ENV']).toBe('development');
expect(apiJson['VERCEL_REGION']).toBe('dev1');
expect(apiJson['VERCEL_GIT_PROVIDER']).toBe('');
expect(apiJson['VERCEL_GIT_REPO_SLUG']).toBe('');
const homeUrl = localhost[0];
const homeRes = await fetch(homeUrl);
const homeJson = await homeRes.json();
expect(homeJson['VERCEL']).toBe('1');
expect(homeJson['VERCEL']).toBeUndefined();
expect(homeJson['VERCEL_URL']).toBe(localhostNoProtocol);
expect(homeJson['VERCEL_ENV']).toBe('development');
expect(homeJson['VERCEL_REGION']).toBe(undefined);
expect(homeJson['VERCEL_GIT_PROVIDER']).toBe('');
expect(homeJson['VERCEL_GIT_REPO_SLUG']).toBe('');
expect(homeJson['VERCEL_ENV']).toBeUndefined();
expect(homeJson['VERCEL_REGION']).toBeUndefined();
expect(homeJson['VERCEL_GIT_PROVIDER']).toBeUndefined();
expect(homeJson['VERCEL_GIT_REPO_SLUG']).toBeUndefined();
// sleep before kill, otherwise the dev process doesn't clean up and exit properly
await sleep(100);

View File

@@ -1255,7 +1255,7 @@ test('fail to deploy a Lambda with an incorrect value for maxDuration', async ()
expect(output.exitCode, formatOutput(output)).toBe(1);
expect(output.stderr).toMatch(
/maxDuration must be between 1 second and 10 seconds/gm
/maxDuration must be between \d+ second and \d+ seconds/gm
);
});
@@ -1327,6 +1327,19 @@ test('should invoke CLI extension', async () => {
expect(output.stdout, formatted).toContain(`Username: ${contextName}`);
});
test('should pass through exit code for CLI extension', async () => {
const fixture = path.join(__dirname, 'fixtures/e2e/cli-extension-exit-code');
// Ensure the `.bin` is populated in the fixture
await runNpmInstall(fixture);
const output = await execCli(binaryPath, ['fail'], {
cwd: fixture,
reject: false,
});
expect(output.exitCode).toEqual(6);
});
// NOTE: Order matters here. This must be the last test in the file.
test('default command should prompt login with empty auth.json', async () => {
await clearAuthConfig();

View File

@@ -216,7 +216,7 @@ export function useProject(
res.json(project);
});
client.scenario.get(
`/v1/env/pull/${project.id}/:target?/:gitBranch?`,
`/v2/env/pull/${project.id}/:target?/:gitBranch?`,
(req, res) => {
const target =
typeof req.params.target === 'string'
@@ -390,7 +390,7 @@ function exposeSystemEnvs(
) {
const envs: Env = {};
if (autoExposeSystemEnvs) {
if (autoExposeSystemEnvs && target !== 'development') {
envs['VERCEL'] = '1';
envs['VERCEL_ENV'] = target || 'development';

View File

@@ -205,10 +205,17 @@ describe('env', () => {
});
const cwd = setupUnitFixture('vercel-env-pull');
client.cwd = cwd;
client.setArgv('env', 'pull', 'other.env', '--yes');
client.setArgv(
'env',
'pull',
'other.env',
'--yes',
'--environment',
'production'
);
const exitCodePromise = env(client);
await expect(client.stderr).toOutput(
'Downloading `development` Environment Variables for Project vercel-env-pull'
'Downloading `production` Environment Variables for Project vercel-env-pull'
);
await expect(client.stderr).toOutput('Created other.env file');
await expect(client.stderr).not.toOutput('and added it to .gitignore');
@@ -218,10 +225,44 @@ describe('env', () => {
const productionFileHasVercelEnv = rawDevEnv
.toString()
.includes('VERCEL_ENV="development"');
.includes('VERCEL_ENV="production"');
expect(productionFileHasVercelEnv).toBeTruthy();
});
it('should not expose system env variables in dev', async () => {
useUser();
useTeams('team_dummy');
useProject({
...defaultProject,
id: 'vercel-env-pull',
name: 'vercel-env-pull',
autoExposeSystemEnvs: true,
});
const cwd = setupUnitFixture('vercel-env-pull');
client.cwd = cwd;
client.setArgv('env', 'pull', 'other.env', '--yes');
const exitCodePromise = env(client);
await expect(client.stderr).toOutput(
'Downloading `development` Environment Variables for Project vercel-env-pull'
);
await expect(client.stderr).toOutput('Created other.env file');
await expect(client.stderr).not.toOutput('and added it to .gitignore');
await expect(exitCodePromise).resolves.toEqual(0);
const devEnv = (
await fs.readFile(path.join(cwd, 'other.env'))
).toString();
const devFileHasVercelEnv = [
'VERCEL',
'VERCEL_ENV',
'VERCEL_URL',
'VERCEL_REGION',
'VERCEL_DEPLOYMENT_ID',
].some(envVar => devEnv.includes(envVar));
expect(devFileHasVercelEnv).toBeFalsy();
});
it('should show a delta string', async () => {
const cwd = setupUnitFixture('vercel-env-pull-delta');
client.cwd = cwd;

View File

@@ -1,5 +1,54 @@
# @vercel/client
## 13.2.9
### Patch Changes
- Updated dependencies [[`5c12ed695`](https://github.com/vercel/vercel/commit/5c12ed69500ceff6a9dc544eab0acd7af64c044a), [`21444a38e`](https://github.com/vercel/vercel/commit/21444a38e50ed680c91b0e3955f15e378eeda64b), [`06d2d860e`](https://github.com/vercel/vercel/commit/06d2d860e47aed792247bf929805b180ed6e2dab)]:
- @vercel/build-utils@8.2.2
## 13.2.8
### Patch Changes
- Updated dependencies [[`83741a0eb`](https://github.com/vercel/vercel/commit/83741a0eb9e44457b083e8790a11eb89984e6357)]:
- @vercel/build-utils@8.2.1
## 13.2.7
### Patch Changes
- Updated dependencies [[`d3c1267e2`](https://github.com/vercel/vercel/commit/d3c1267e24082789ea6382cf6af81dd40df288ff), [`ccd7eb1fb`](https://github.com/vercel/vercel/commit/ccd7eb1fb78f7ac9effdbe1935de3bda82c97fe3)]:
- @vercel/build-utils@8.2.0
## 13.2.6
### Patch Changes
- Updated dependencies [[`ad6945435`](https://github.com/vercel/vercel/commit/ad69454352b519b2b0ed326f245c779530554bf2)]:
- @vercel/build-utils@8.1.3
## 13.2.5
### Patch Changes
- Updated dependencies [[`1682ad43d`](https://github.com/vercel/vercel/commit/1682ad43d0064b22b1248a7e946746b838f00076)]:
- @vercel/build-utils@8.1.2
## 13.2.4
### Patch Changes
- Updated dependencies [[`2f7a6ed5f`](https://github.com/vercel/vercel/commit/2f7a6ed5f92d454000f92247d3b6548e2064f4e6)]:
- @vercel/build-utils@8.1.1
## 13.2.3
### Patch Changes
- Updated dependencies [[`5014b1e82`](https://github.com/vercel/vercel/commit/5014b1e82a46181baeb727ffe6d14000b6a4b1d7)]:
- @vercel/build-utils@8.1.0
## 13.2.2
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/client",
"version": "13.2.2",
"version": "13.2.9",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"homepage": "https://vercel.com",
@@ -37,7 +37,7 @@
"typescript": "4.9.5"
},
"dependencies": {
"@vercel/build-utils": "8.0.0",
"@vercel/build-utils": "8.2.2",
"@vercel/error-utils": "2.0.2",
"@vercel/routing-utils": "3.1.0",
"@zeit/fetch": "5.2.0",

View File

@@ -1,5 +1,11 @@
# @vercel/fs-detectors
## 5.2.4
### Patch Changes
- Add support for detecting Turborepo 2 ([#11680](https://github.com/vercel/vercel/pull/11680))
## 5.2.3
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/fs-detectors",
"version": "5.2.3",
"version": "5.2.4",
"description": "Vercel filesystem detectors",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
@@ -37,7 +37,7 @@
"@types/minimatch": "3.0.5",
"@types/node": "14.18.33",
"@types/semver": "7.3.10",
"@vercel/build-utils": "8.0.0",
"@vercel/build-utils": "8.2.2",
"jest-junit": "16.0.0",
"typescript": "4.9.5"
}

View File

@@ -7,10 +7,11 @@ import JSON5 from 'json5';
import semver from 'semver';
export class MissingBuildPipeline extends Error {
constructor() {
super(
'Missing required `build` pipeline in turbo.json or package.json Turbo configuration.'
);
constructor(usesTasks: boolean) {
const message = usesTasks
? 'Missing required `build` task in turbo.json.'
: 'Missing required `build` pipeline in turbo.json or package.json Turbo configuration.';
super(message);
}
}
@@ -65,12 +66,15 @@ export async function getMonorepoDefaultSettings(
]);
let hasBuildPipeline = false;
let hasTurboTasks = false;
let turboSemVer = null;
if (turboJSONBuf !== null) {
const turboJSON = JSON5.parse(turboJSONBuf.toString('utf-8'));
if (turboJSON?.pipeline?.build) {
hasTurboTasks = 'tasks' in (turboJSON || {});
if (turboJSON?.pipeline?.build || turboJSON?.tasks?.build) {
hasBuildPipeline = true;
}
}
@@ -89,7 +93,7 @@ export async function getMonorepoDefaultSettings(
}
if (!hasBuildPipeline) {
throw new MissingBuildPipeline();
throw new MissingBuildPipeline(hasTurboTasks);
}
if (projectPath === '/') {

View File

@@ -0,0 +1,9 @@
{
"private": true,
"workspaces": [
"packages/*"
],
"devDependencies": {
"turbo": "latest"
}
}

View File

@@ -0,0 +1,5 @@
{
"name": "app-14",
"version": "0.0.1",
"main": "index.js"
}

View File

@@ -0,0 +1,2 @@
// TEST COMMENT TO VERIFY JSON5 SUPPORT
{ "tasks": { "build": { "dependsOn": ["^build"], "outputs": ["dist/**"] } } }

View File

@@ -17,11 +17,17 @@ describe('getMonorepoDefaultSettings', () => {
);
});
test('MissingBuildPipeline is an error', () => {
const missingBuildPipeline = new MissingBuildPipeline();
const missingBuildPipeline = new MissingBuildPipeline(false);
expect(missingBuildPipeline).toBeInstanceOf(Error);
expect(missingBuildPipeline.message).toBe(
'Missing required `build` pipeline in turbo.json or package.json Turbo configuration.'
);
const missingBuildTask = new MissingBuildPipeline(true);
expect(missingBuildTask).toBeInstanceOf(Error);
expect(missingBuildTask.message).toBe(
'Missing required `build` task in turbo.json.'
);
});
test.each([
@@ -31,6 +37,7 @@ describe('getMonorepoDefaultSettings', () => {
['turbo-npm', 'turbo', true, 'app-15', false, false],
['turbo-npm-root-proj', 'turbo', true, 'app-root-proj', true, false],
['turbo-latest', 'turbo', false, 'app-14', false, false],
['turbo-2', 'turbo', false, 'app-14', false, false],
['nx', 'nx', false, 'app-12', false, false],
['nx-package-config', 'nx', false, 'app-11', false, false],
['nx-project-and-package-config-1', 'nx', false, 'app-10', false, false],

View File

@@ -1,5 +1,17 @@
# @vercel/functions
## 1.0.2
### Patch Changes
- Convert package to CommonJS ([#11569](https://github.com/vercel/vercel/pull/11569))
## 1.0.1
### Patch Changes
- Don't throw error if context is missing ([`0817527f9`](https://github.com/vercel/vercel/commit/0817527f9e9d0d5fceb73f21e695089349a96d3e))
## 1.0.0
### Major Changes

View File

@@ -14,4 +14,4 @@
* }
* ```
*/
export const waitUntil: (promise: Promise<unknown>) => void;
export function waitUntil(promise: Promise<unknown>): void;

View File

@@ -1,8 +1,7 @@
/* global globalThis */
export const waitUntil = promise => {
exports.waitUntil = promise => {
if (
promise instanceof Promise === false ||
promise === null ||
typeof promise !== 'object' ||
typeof promise.then !== 'function'
@@ -13,12 +12,5 @@ export const waitUntil = promise => {
}
const ctx = globalThis[Symbol.for('@vercel/request-context')]?.get?.() ?? {};
if (!ctx.waitUntil) {
throw new Error(
'failed to get waitUntil function for this request context'
);
}
ctx.waitUntil(promise);
ctx.waitUntil?.(promise);
};

View File

@@ -23,14 +23,11 @@ test.each([
});
test.each([null, undefined, {}])(
'waitUntil throws when context is %s',
'waitUntil does not throw an error when context is %s',
input => {
const promise = Promise.resolve();
globalThis[Symbol.for('@vercel/request-context')] = input;
expect(() => waitUntil(promise)).toThrow(Error);
expect(() => waitUntil(promise)).toThrow(
'failed to get waitUntil function for this request context'
);
expect(() => waitUntil(promise)).not.toThrow();
}
);

View File

@@ -2,7 +2,7 @@
"name": "@vercel/functions",
"description": "Runtime functions to be used with your Vercel Functions",
"homepage": "https://vercel.com",
"version": "1.0.0",
"version": "1.0.2",
"types": "index.d.ts",
"main": "index.js",
"repository": {

View File

@@ -1,5 +1,54 @@
# @vercel/gatsby-plugin-vercel-builder
## 2.0.33
### Patch Changes
- Updated dependencies [[`5c12ed695`](https://github.com/vercel/vercel/commit/5c12ed69500ceff6a9dc544eab0acd7af64c044a), [`21444a38e`](https://github.com/vercel/vercel/commit/21444a38e50ed680c91b0e3955f15e378eeda64b), [`06d2d860e`](https://github.com/vercel/vercel/commit/06d2d860e47aed792247bf929805b180ed6e2dab)]:
- @vercel/build-utils@8.2.2
## 2.0.32
### Patch Changes
- Updated dependencies [[`83741a0eb`](https://github.com/vercel/vercel/commit/83741a0eb9e44457b083e8790a11eb89984e6357)]:
- @vercel/build-utils@8.2.1
## 2.0.31
### Patch Changes
- Updated dependencies [[`d3c1267e2`](https://github.com/vercel/vercel/commit/d3c1267e24082789ea6382cf6af81dd40df288ff), [`ccd7eb1fb`](https://github.com/vercel/vercel/commit/ccd7eb1fb78f7ac9effdbe1935de3bda82c97fe3)]:
- @vercel/build-utils@8.2.0
## 2.0.30
### Patch Changes
- Updated dependencies [[`ad6945435`](https://github.com/vercel/vercel/commit/ad69454352b519b2b0ed326f245c779530554bf2)]:
- @vercel/build-utils@8.1.3
## 2.0.29
### Patch Changes
- Updated dependencies [[`1682ad43d`](https://github.com/vercel/vercel/commit/1682ad43d0064b22b1248a7e946746b838f00076)]:
- @vercel/build-utils@8.1.2
## 2.0.28
### Patch Changes
- Updated dependencies [[`2f7a6ed5f`](https://github.com/vercel/vercel/commit/2f7a6ed5f92d454000f92247d3b6548e2064f4e6)]:
- @vercel/build-utils@8.1.1
## 2.0.27
### Patch Changes
- Updated dependencies [[`5014b1e82`](https://github.com/vercel/vercel/commit/5014b1e82a46181baeb727ffe6d14000b6a4b1d7)]:
- @vercel/build-utils@8.1.0
## 2.0.26
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/gatsby-plugin-vercel-builder",
"version": "2.0.26",
"version": "2.0.33",
"main": "dist/index.js",
"files": [
"dist",
@@ -20,7 +20,7 @@
},
"dependencies": {
"@sinclair/typebox": "0.25.24",
"@vercel/build-utils": "8.0.0",
"@vercel/build-utils": "8.2.2",
"@vercel/routing-utils": "3.1.0",
"esbuild": "0.14.47",
"etag": "1.8.1",

View File

@@ -29,7 +29,7 @@
"@types/node-fetch": "^2.3.0",
"@types/tar": "6.1.5",
"@types/yauzl-promise": "2.1.0",
"@vercel/build-utils": "8.0.0",
"@vercel/build-utils": "8.2.2",
"async-retry": "1.3.3",
"execa": "^1.0.0",
"fs-extra": "^7.0.0",

View File

@@ -26,7 +26,7 @@
"devDependencies": {
"@types/jest": "27.5.1",
"@types/node": "14.18.33",
"@vercel/build-utils": "8.0.0",
"@vercel/build-utils": "8.2.2",
"execa": "3.2.0",
"fs-extra": "11.1.0",
"jest-junit": "16.0.0"

View File

@@ -51,11 +51,15 @@ export const build: BuildV2 = async ({
);
const spawnOpts = getSpawnOptions(meta, nodeVersion);
const { cliType, lockfileVersion } = await scanParentDirs(entrypointDir);
const { cliType, lockfileVersion, packageJson } = await scanParentDirs(
entrypointDir,
true
);
spawnOpts.env = getEnvForPackageManager({
cliType,
lockfileVersion,
packageJsonPackageManager: packageJson?.packageManager,
nodeVersion,
env: spawnOpts.env || {},
});

View File

@@ -1,5 +1,69 @@
# @vercel/next
## 4.2.16
### Patch Changes
- prevent /index from being incorrectly normalized in rewrites ([#11707](https://github.com/vercel/vercel/pull/11707))
- Upgrade to @vercel/nft 0.27.2 with browser remapping support ([#11700](https://github.com/vercel/vercel/pull/11700))
- ensure unmatched rsc rewrites are routed to correct handler ([#11688](https://github.com/vercel/vercel/pull/11688))
## 4.2.15
### Patch Changes
- ensure unmatched action rewrites are routed to correct handler ([#11686](https://github.com/vercel/vercel/pull/11686))
- Adds a route for the `.rsc` pathname as well when app has ppr enabled but not all routes. ([#11681](https://github.com/vercel/vercel/pull/11681))
## 4.2.14
### Patch Changes
- Don't create streaming lambdas for pages router routes ([#11660](https://github.com/vercel/vercel/pull/11660))
- Ensure user rewrites still match to action outputs ([#11628](https://github.com/vercel/vercel/pull/11628))
## 4.2.13
### Patch Changes
- Fix static case for detecting when a page supports PPR ([#11635](https://github.com/vercel/vercel/pull/11635))
- Fix related to erroring when a prefetch route is not provided but the route is PPR enabled ([#11638](https://github.com/vercel/vercel/pull/11638))
## 4.2.12
### Patch Changes
- Support incremental PPR for large applications ([#11625](https://github.com/vercel/vercel/pull/11625))
## 4.2.11
### Patch Changes
- normalize source file locations for special metadata files ([#11579](https://github.com/vercel/vercel/pull/11579))
## 4.2.10
### Patch Changes
- skip action rewrites for RSC requests ([#11576](https://github.com/vercel/vercel/pull/11576))
- Bump `@vercel/nft@0.27.0` ([#11580](https://github.com/vercel/vercel/pull/11580))
## 4.2.9
### Patch Changes
- Support incremental partial prerendering ([#11560](https://github.com/vercel/vercel/pull/11560))
- ensure `.action` outputs are created for edge functions ([#11568](https://github.com/vercel/vercel/pull/11568))
- ([#11566](https://github.com/vercel/vercel/pull/11566))
## 4.2.8
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/next",
"version": "4.2.8",
"version": "4.2.16",
"license": "Apache-2.0",
"main": "./dist/index",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",
@@ -23,7 +23,7 @@
"dist"
],
"dependencies": {
"@vercel/nft": "0.26.4"
"@vercel/nft": "0.27.2"
},
"devDependencies": {
"@types/aws-lambda": "8.10.19",
@@ -40,7 +40,7 @@
"@types/semver": "6.0.0",
"@types/text-table": "0.2.1",
"@types/webpack-sources": "3.2.0",
"@vercel/build-utils": "8.0.0",
"@vercel/build-utils": "8.2.2",
"@vercel/routing-utils": "3.1.0",
"async-sema": "3.0.1",
"buffer-crc32": "0.2.13",

View File

@@ -257,10 +257,15 @@ export const build: BuildV2 = async ({
const nextVersionRange = await getNextVersionRange(entryPath);
const nodeVersion = await getNodeVersion(entryPath, undefined, config, meta);
const spawnOpts = getSpawnOptions(meta, nodeVersion);
const { cliType, lockfileVersion } = await scanParentDirs(entryPath);
const { cliType, lockfileVersion, packageJson } = await scanParentDirs(
entryPath,
true
);
spawnOpts.env = getEnvForPackageManager({
cliType,
lockfileVersion,
packageJsonPackageManager: packageJson?.packageManager,
nodeVersion,
env: spawnOpts.env || {},
});
@@ -1353,6 +1358,11 @@ export const build: BuildV2 = async ({
experimentalPPRRoutes.add(route);
}
const isAppPPREnabled = requiredServerFilesManifest
? requiredServerFilesManifest.config.experimental?.ppr === true ||
requiredServerFilesManifest.config.experimental?.ppr === 'incremental'
: false;
if (requiredServerFilesManifest) {
if (!routesManifest) {
throw new Error(
@@ -1408,6 +1418,7 @@ export const build: BuildV2 = async ({
hasIsr500Page,
variantsManifest,
experimentalPPRRoutes,
isAppPPREnabled,
});
}
@@ -1927,7 +1938,7 @@ export const build: BuildV2 = async ({
canUsePreviewMode,
bypassToken: prerenderManifest.bypassToken || '',
isServerMode,
experimentalPPRRoutes,
isAppPPREnabled: false,
hasActionOutputSupport: false,
}).then(arr =>
localizeDynamicRoutes(
@@ -1958,7 +1969,7 @@ export const build: BuildV2 = async ({
canUsePreviewMode,
bypassToken: prerenderManifest.bypassToken || '',
isServerMode,
experimentalPPRRoutes,
isAppPPREnabled: false,
hasActionOutputSupport: false,
}).then(arr =>
arr.map(route => {
@@ -2157,6 +2168,7 @@ export const build: BuildV2 = async ({
appPathRoutesManifest,
isSharedLambdas,
canUsePreviewMode,
isAppPPREnabled: false,
});
await Promise.all(

View File

@@ -144,6 +144,7 @@ export async function serverBuild({
requiredServerFilesManifest,
variantsManifest,
experimentalPPRRoutes,
isAppPPREnabled,
}: {
appPathRoutesManifest?: Record<string, string>;
dynamicPages: string[];
@@ -185,7 +186,15 @@ export async function serverBuild({
requiredServerFilesManifest: NextRequiredServerFilesManifest;
variantsManifest: VariantsManifest | null;
experimentalPPRRoutes: ReadonlySet<string>;
isAppPPREnabled: boolean;
}): Promise<BuildResult> {
if (isAppPPREnabled) {
debug(
'experimentalPPRRoutes',
JSON.stringify(Array.from(experimentalPPRRoutes))
);
}
lambdaPages = Object.assign({}, lambdaPages, lambdaAppPaths);
const experimentalAllowBundling = Boolean(
@@ -203,7 +212,8 @@ export async function serverBuild({
);
const hasActionOutputSupport =
semver.gte(nextVersion, ACTION_OUTPUT_SUPPORT_VERSION) &&
Boolean(process.env.NEXT_EXPERIMENTAL_STREAMING_ACTIONS);
Boolean(process.env.NEXT_EXPERIMENTAL_STREAMING_ACTIONS) &&
!routesManifest.i18n;
const projectDir = requiredServerFilesManifest.relativeAppDir
? path.join(baseDir, requiredServerFilesManifest.relativeAppDir)
: requiredServerFilesManifest.appDir || entryPath;
@@ -217,10 +227,6 @@ export async function serverBuild({
}
}
const experimental = {
ppr: requiredServerFilesManifest.config.experimental?.ppr === true,
};
let appRscPrefetches: UnwrapPromise<ReturnType<typeof glob>> = {};
let appBuildTraces: UnwrapPromise<ReturnType<typeof glob>> = {};
let appDir: string | null = null;
@@ -228,9 +234,7 @@ export async function serverBuild({
if (appPathRoutesManifest) {
appDir = path.join(pagesDir, '../app');
appBuildTraces = await glob('**/*.js.nft.json', appDir);
// TODO: maybe?
appRscPrefetches = experimental.ppr
appRscPrefetches = isAppPPREnabled
? {}
: await glob(`**/*${RSC_PREFETCH_SUFFIX}`, appDir);
@@ -249,9 +253,19 @@ export async function serverBuild({
for (const rewrite of afterFilesRewrites) {
if (rewrite.src && rewrite.dest) {
// ensures that userland rewrites are still correctly matched to their special outputs
// PPR should match .prefetch.rsc, .rsc, and .action
// non-PPR should match .rsc and .action
// we only add `.action` handling to the regex if flagged on in the build
const rscSuffix = isAppPPREnabled
? `(\\.prefetch)?\\.rsc${hasActionOutputSupport ? '|\\.action' : ''}`
: hasActionOutputSupport
? '(\\.action|\\.rsc)'
: '\\.rsc';
rewrite.src = rewrite.src.replace(
/\/?\(\?:\/\)\?/,
`(?<rscsuff>${experimental.ppr ? '(\\.prefetch)?' : ''}\\.rsc)?(?:/)?`
`(?<rscsuff>${rscSuffix})?(?:/)?`
);
let destQueryIndex = rewrite.dest.indexOf('?');
@@ -937,6 +951,7 @@ export async function serverBuild({
if (!group.isPrerenders || group.isExperimentalPPR) {
group.isStreaming = true;
}
group.isAppRouter = true;
// We create a streaming variant of the Prerender lambda group
@@ -984,18 +999,24 @@ export async function serverBuild({
apiLambdaGroups: apiLambdaGroups.map(group => ({
pages: group.pages,
isPrerender: group.isPrerenders,
isStreaming: group.isStreaming,
isExperimentalPPR: group.isExperimentalPPR,
pseudoLayerBytes: group.pseudoLayerBytes,
uncompressedLayerBytes: group.pseudoLayerUncompressedBytes,
})),
pageLambdaGroups: pageLambdaGroups.map(group => ({
pages: group.pages,
isPrerender: group.isPrerenders,
isStreaming: group.isStreaming,
isExperimentalPPR: group.isExperimentalPPR,
pseudoLayerBytes: group.pseudoLayerBytes,
uncompressedLayerBytes: group.pseudoLayerUncompressedBytes,
})),
appRouterLambdaGroups: appRouterLambdaGroups.map(group => ({
pages: group.pages,
isPrerender: group.isPrerenders,
isStreaming: group.isStreaming,
isExperimentalPPR: group.isExperimentalPPR,
pseudoLayerBytes: group.pseudoLayerBytes,
uncompressedLayerBytes: group.pseudoLayerUncompressedBytes,
})),
@@ -1003,6 +1024,8 @@ export async function serverBuild({
appRouterStreamingActionLambdaGroups.map(group => ({
pages: group.pages,
isPrerender: group.isPrerenders,
isStreaming: group.isStreaming,
isExperimentalPPR: group.isExperimentalPPR,
pseudoLayerBytes: group.pseudoLayerBytes,
uncompressedLayerBytes: group.pseudoLayerUncompressedBytes,
})),
@@ -1010,6 +1033,8 @@ export async function serverBuild({
group => ({
pages: group.pages,
isPrerender: group.isPrerenders,
isStreaming: group.isStreaming,
isExperimentalPPR: group.isExperimentalPPR,
pseudoLayerBytes: group.pseudoLayerBytes,
uncompressedLayerBytes: group.pseudoLayerUncompressedBytes,
})
@@ -1189,15 +1214,10 @@ export async function serverBuild({
const lambda = await createLambdaFromPseudoLayers(options);
// This is a PPR lambda if it's an App Page with the PPR experimental flag
// enabled.
const isPPR =
experimental.ppr && group.isAppRouter && !group.isAppRouteHandler;
// If PPR is enabled and this is an App Page, create the non-streaming
// lambda for the page for revalidation.
let revalidate: NodejsLambda | undefined;
if (isPPR) {
if (group.isExperimentalPPR) {
if (!options.isStreaming) {
throw new Error("Invariant: PPR lambda isn't streaming");
}
@@ -1214,14 +1234,11 @@ export async function serverBuild({
// This is the name of the page, where the root is `index`.
const pageName = pageFilename.replace(/\.js$/, '');
// This is the name of the page prefixed with a `/`, where the root is
// `/index`.
const pagePath = path.posix.join('/', pageName);
// This is the routable pathname for the page, where the root is `/`.
const pagePathname = pagePath === '/index' ? '/' : pagePath;
const pagePathname = normalizePage(pageName);
let isPrerender = prerenderRoutes.has(pagePathname);
const isRoutePPREnabled = experimentalPPRRoutes.has(pagePathname);
if (!isPrerender && routesManifest?.i18n) {
isPrerender = routesManifest.i18n.locales.some(locale => {
@@ -1239,7 +1256,7 @@ export async function serverBuild({
}
// If this is a PPR page, then we should prefix the output name.
if (isPPR) {
if (isRoutePPREnabled) {
if (!revalidate) {
throw new Error("Invariant: PPR lambda isn't set");
}
@@ -1320,6 +1337,13 @@ export async function serverBuild({
console.timeEnd(lambdaCreationLabel);
}
if (isAppPPREnabled) {
debug(
'experimentalStreamingLambdaPaths',
JSON.stringify(Array.from(experimentalStreamingLambdaPaths))
);
}
const prerenderRoute = onPrerenderRoute({
appDir,
pagesDir,
@@ -1339,6 +1363,7 @@ export async function serverBuild({
hasPages404: routesManifest.pages404,
isCorrectNotFoundRoutes,
isEmptyAllowQueryForPrendered,
isAppPPREnabled,
});
await Promise.all(
@@ -1407,7 +1432,7 @@ export async function serverBuild({
bypassToken: prerenderManifest.bypassToken || '',
isServerMode: true,
dynamicMiddlewareRouteMap: middleware.dynamicRouteMap,
experimentalPPRRoutes,
isAppPPREnabled,
hasActionOutputSupport,
}).then(arr =>
localizeDynamicRoutes(
@@ -1589,7 +1614,7 @@ export async function serverBuild({
if (lambdas[pathname]) {
lambdas[`${pathname}.rsc`] = lambdas[pathname];
if (experimental.ppr) {
if (isAppPPREnabled) {
lambdas[`${pathname}${RSC_PREFETCH_SUFFIX}`] = lambdas[pathname];
}
}
@@ -1597,10 +1622,14 @@ export async function serverBuild({
if (edgeFunctions[pathname]) {
edgeFunctions[`${pathname}.rsc`] = edgeFunctions[pathname];
if (experimental.ppr) {
if (isAppPPREnabled) {
edgeFunctions[`${pathname}${RSC_PREFETCH_SUFFIX}`] =
edgeFunctions[pathname];
}
if (hasActionOutputSupport) {
edgeFunctions[`${pathname}.action`] = edgeFunctions[pathname];
}
}
}
}
@@ -1612,7 +1641,7 @@ export async function serverBuild({
'RSC, Next-Router-State-Tree, Next-Router-Prefetch';
const appNotFoundPath = path.posix.join('.', entryDirectory, '_not-found');
if (experimental.ppr && !rscPrefetchHeader) {
if (isAppPPREnabled && !rscPrefetchHeader) {
throw new Error("Invariant: cannot use PPR without 'rsc.prefetchHeader'");
}
@@ -1620,7 +1649,7 @@ export async function serverBuild({
// all the routes that support it (and are listed) have configured lambdas.
// This only applies to routes that do not have fallbacks enabled (these are
// routes that have `dynamicParams = false` defined.
if (experimental.ppr) {
if (isAppPPREnabled) {
for (const { srcRoute, dataRoute, experimentalPPR } of Object.values(
prerenderManifest.staticRoutes
)) {
@@ -1903,7 +1932,7 @@ export async function serverBuild({
...(appDir
? [
...(rscPrefetchHeader && experimental.ppr
...(rscPrefetchHeader && isAppPPREnabled
? [
{
src: `^${path.posix.join('/', entryDirectory, '/')}`,
@@ -1952,7 +1981,7 @@ export async function serverBuild({
// Also includes separate handling for index routes which should match to /index.action.
// This follows the same pattern as the rewrites for .rsc files.
{
src: `^${path.posix.join('/', entryDirectory, '/')}`,
src: `^${path.posix.join('/', entryDirectory, '/?')}`,
dest: path.posix.join('/', entryDirectory, '/index.action'),
has: [
{
@@ -1960,6 +1989,12 @@ export async function serverBuild({
key: 'next-action',
},
],
missing: [
{
type: 'header',
key: rscHeader,
},
],
continue: true,
override: true,
},
@@ -1976,6 +2011,12 @@ export async function serverBuild({
key: 'next-action',
},
],
missing: [
{
type: 'header',
key: rscHeader,
},
],
continue: true,
override: true,
},
@@ -2045,10 +2086,45 @@ export async function serverBuild({
]
: []),
// before processing rewrites, remove any special `/index` routes that were added
// as these won't be properly normalized by `afterFilesRewrites` / `dynamicRoutes`
...(appPathRoutesManifest
? [
{
src: path.posix.join(
'/',
entryDirectory,
'/index(\\.action|\\.rsc)'
),
dest: path.posix.join('/', entryDirectory),
continue: true,
},
]
: []),
// These need to come before handle: miss or else they are grouped
// with that routing section
...afterFilesRewrites,
// Ensure that after we normalize `afterFilesRewrites`, unmatched actions are routed to the correct handler
// e.g. /foo/.action -> /foo.action. This should only ever match in cases where we're routing to an action handler
// and the rewrite normalization led to something like /foo/$1$rscsuff, and $1 had no match.
// This is meant to have parity with the .rsc handling below.
...(hasActionOutputSupport
? [
{
src: `${path.posix.join('/', entryDirectory, '/\\.action$')}`,
dest: `${path.posix.join('/', entryDirectory, '/index.action')}`,
check: true,
},
{
src: `${path.posix.join('/', entryDirectory, '(.+)/\\.action$')}`,
dest: `${path.posix.join('/', entryDirectory, '$1.action')}`,
check: true,
},
]
: []),
// ensure non-normalized /.rsc from rewrites is handled
...(appPathRoutesManifest
? [
@@ -2061,11 +2137,29 @@ export async function serverBuild({
),
check: true,
},
{
src: path.posix.join(
'/',
entryDirectory,
'(.+)/\\.prefetch\\.rsc$'
),
dest: path.posix.join(
'/',
entryDirectory,
`$1${RSC_PREFETCH_SUFFIX}`
),
check: true,
},
{
src: path.posix.join('/', entryDirectory, '/\\.rsc$'),
dest: path.posix.join('/', entryDirectory, `/index.rsc`),
check: true,
},
{
src: path.posix.join('/', entryDirectory, '(.+)/\\.rsc$'),
dest: path.posix.join('/', entryDirectory, '$1.rsc'),
check: true,
},
]
: []),

View File

@@ -192,8 +192,12 @@ function normalizePage(page: string): string {
if (!page.startsWith('/')) {
page = `/${page}`;
}
// remove '/index' from the end
page = page.replace(/\/index$/, '/');
// Replace the `/index` with `/`
if (page === '/index') {
page = '/';
}
return page;
}
@@ -320,8 +324,8 @@ export async function getDynamicRoutes({
bypassToken,
isServerMode,
dynamicMiddlewareRouteMap,
experimentalPPRRoutes,
hasActionOutputSupport,
isAppPPREnabled,
}: {
entryPath: string;
entryDirectory: string;
@@ -333,8 +337,8 @@ export async function getDynamicRoutes({
bypassToken?: string;
isServerMode?: boolean;
dynamicMiddlewareRouteMap?: ReadonlyMap<string, RouteWithSrc>;
experimentalPPRRoutes: ReadonlySet<string>;
hasActionOutputSupport: boolean;
isAppPPREnabled: boolean;
}): Promise<RouteWithSrc[]> {
if (routesManifest) {
switch (routesManifest.version) {
@@ -408,7 +412,7 @@ export async function getDynamicRoutes({
];
}
if (experimentalPPRRoutes.has(page)) {
if (isAppPPREnabled) {
let dest = route.dest?.replace(/($|\?)/, '.prefetch.rsc$1');
if (page === '/' || page === '/index') {
@@ -1439,6 +1443,13 @@ async function getSourceFilePathFromPage({
}
}
// if we got here, and didn't find a source not-found file, then it was the one injected
// by Next.js. There's no need to warn or return a source file in this case, as it won't have
// any configuration applied to it.
if (page === '/_not-found/page') {
return '';
}
console.log(
`WARNING: Unable to find source file for page ${page} with extensions: ${extensionsToTry.join(
', '
@@ -1498,8 +1509,8 @@ export type LambdaGroup = {
isAppRouter?: boolean;
isAppRouteHandler?: boolean;
isStreaming?: boolean;
isPrerenders?: boolean;
isExperimentalPPR?: boolean;
readonly isPrerenders: boolean;
readonly isExperimentalPPR: boolean;
isActionLambda?: boolean;
isPages?: boolean;
isApiLambda: boolean;
@@ -1565,15 +1576,13 @@ export async function getPageLambdaGroups({
}
if (config && config.functions) {
// `pages` are normalized without route groups (e.g., /app/(group)/page.js).
// we keep track of that mapping in `inversedAppPathManifest`
// `getSourceFilePathFromPage` needs to use the path from source to properly match the config
const pageFromManifest = inversedAppPathManifest?.[routeName];
const sourceFile = await getSourceFilePathFromPage({
workPath: entryPath,
// since this function is used by both `pages` and `app`, the manifest might not be provided
// so fallback to normal behavior of just checking the `page`.
page: pageFromManifest ?? page,
page: normalizeSourceFilePageFromManifest(
routeName,
page,
inversedAppPathManifest
),
pageExtensions,
});
@@ -1657,6 +1666,43 @@ export async function getPageLambdaGroups({
return groups;
}
// `pages` are normalized without route groups (e.g., /app/(group)/page.js).
// we keep track of that mapping in `inversedAppPathManifest`
// `getSourceFilePathFromPage` needs to use the path from source to properly match the config
function normalizeSourceFilePageFromManifest(
routeName: string,
page: string,
inversedAppPathManifest?: Record<string, string>
) {
const pageFromManifest = inversedAppPathManifest?.[routeName];
if (!pageFromManifest) {
// since this function is used by both `pages` and `app`, the manifest might not be provided
// so fallback to normal behavior of just checking the `page`.
return page;
}
const metadataConventions = [
'/favicon.',
'/icon.',
'/apple-icon.',
'/opengraph-image.',
'/twitter-image.',
'/sitemap.',
'/robots.',
];
// these special metadata files for will not contain `/route` or `/page` suffix, so return the routeName as-is.
const isSpecialFile = metadataConventions.some(convention =>
routeName.startsWith(convention)
);
if (isSpecialFile) {
return routeName;
}
return pageFromManifest;
}
export const outputFunctionFileSizeInfo = (
pages: string[],
pseudoLayer: PseudoLayer,
@@ -1906,6 +1952,7 @@ type OnPrerenderRouteArgs = {
routesManifest?: RoutesManifest;
isCorrectNotFoundRoutes?: boolean;
isEmptyAllowQueryForPrendered?: boolean;
isAppPPREnabled: boolean;
};
let prerenderGroup = 1;
@@ -1942,6 +1989,7 @@ export const onPrerenderRoute =
routesManifest,
isCorrectNotFoundRoutes,
isEmptyAllowQueryForPrendered,
isAppPPREnabled,
} = prerenderRouteArgs;
if (isBlocking && isFallback) {
@@ -2062,14 +2110,14 @@ export const onPrerenderRoute =
// If enabled, try to get the postponed route information from the file
// system and use it to assemble the prerender.
let prerender: string | undefined;
let postponedPrerender: string | undefined;
if (experimentalPPR && appDir) {
const htmlPath = path.join(appDir, `${routeFileNoExt}.html`);
const metaPath = path.join(appDir, `${routeFileNoExt}.meta`);
if (fs.existsSync(htmlPath) && fs.existsSync(metaPath)) {
const meta = JSON.parse(await fs.readFile(metaPath, 'utf8'));
if ('postponed' in meta && typeof meta.postponed === 'string') {
prerender = meta.postponed;
postponedPrerender = meta.postponed;
// Assign the headers Content-Type header to the prerendered type.
initialHeaders ??= {};
@@ -2079,7 +2127,7 @@ export const onPrerenderRoute =
// Read the HTML file and append it to the prerendered content.
const html = await fs.readFileSync(htmlPath, 'utf8');
prerender += html;
postponedPrerender += html;
}
}
@@ -2096,14 +2144,14 @@ export const onPrerenderRoute =
}
}
if (prerender) {
if (postponedPrerender) {
const contentType = initialHeaders?.['content-type'];
if (!contentType) {
throw new Error("Invariant: contentType can't be undefined");
}
// Assemble the prerendered file.
htmlFsRef = new FileBlob({ contentType, data: prerender });
htmlFsRef = new FileBlob({ contentType, data: postponedPrerender });
} else if (
appDir &&
!dataRoute &&
@@ -2167,7 +2215,14 @@ export const onPrerenderRoute =
? addLocaleOrDefault('/404.html', routesManifest, locale)
: '/404.html'
: isAppPathRoute
? prefetchDataRoute || dataRoute
? // When experimental PPR is enabled, we expect that the data
// that should be served as a part of the prerender should
// be from the prefetch data route. If this isn't enabled
// for ppr, the only way to get the data is from the data
// route.
experimentalPPR
? prefetchDataRoute
: dataRoute
: routeFileNoExt + '.json'
}`
),
@@ -2177,22 +2232,6 @@ export const onPrerenderRoute =
initialStatus = 404;
}
/**
* If the route key had an `/index` suffix added, we need to note it so we
* can remove it from the output path later accurately.
*/
let addedIndexSuffix = false;
if (isAppPathRoute) {
// for literal index routes we need to append an additional /index
// due to the proxy's normalizing for /index routes
if (routeKey !== '/index' && routeKey.endsWith('/index')) {
routeKey = `${routeKey}/index`;
routeFileNoExt = routeKey;
addedIndexSuffix = true;
}
}
let outputPathPage = path.posix.join(entryDirectory, routeFileNoExt);
if (!isAppPathRoute) {
@@ -2229,7 +2268,7 @@ export const onPrerenderRoute =
let outputPathPrefetchData: null | string = null;
if (prefetchDataRoute) {
if (!experimentalPPR) {
if (!isAppPPREnabled) {
throw new Error(
"Invariant: prefetchDataRoute can't be set without PPR"
);
@@ -2240,10 +2279,6 @@ export const onPrerenderRoute =
throw new Error('Invariant: expected to find prefetch data route PPR');
}
// When the prefetch data path is available, use it for the prerender,
// otherwise use the data path.
const outputPrerenderPathData = outputPathPrefetchData || outputPathData;
if (isSharedLambdas) {
const outputSrcPathPage = normalizeIndexOutput(
path.join(
@@ -2296,8 +2331,14 @@ export const onPrerenderRoute =
htmlFsRef.contentType = htmlContentType;
prerenders[outputPathPage] = htmlFsRef;
if (outputPrerenderPathData) {
prerenders[outputPrerenderPathData] = jsonFsRef;
if (outputPathPrefetchData) {
prerenders[outputPathPrefetchData] = jsonFsRef;
}
// If experimental ppr is not enabled for this route, then add the data
// route as a target for the prerender as well.
if (outputPathData && !experimentalPPR) {
prerenders[outputPathData] = jsonFsRef;
}
}
}
@@ -2386,7 +2427,7 @@ export const onPrerenderRoute =
// static route first, then try the srcRoute if it doesn't exist. If we
// can't find it at all, this constitutes an error.
experimentalStreamingLambdaPath = experimentalStreamingLambdaPaths.get(
pathnameToOutputName(entryDirectory, routeKey, addedIndexSuffix)
pathnameToOutputName(entryDirectory, routeKey)
);
if (!experimentalStreamingLambdaPath && srcRoute) {
experimentalStreamingLambdaPath =
@@ -2433,21 +2474,20 @@ export const onPrerenderRoute =
: {}),
});
if (outputPrerenderPathData) {
let normalizedPathData = outputPrerenderPathData;
const normalizePathData = (pathData: string) => {
if (
(srcRoute === '/' || srcRoute == '/index') &&
outputPrerenderPathData.endsWith(RSC_PREFETCH_SUFFIX)
pathData.endsWith(RSC_PREFETCH_SUFFIX)
) {
delete lambdas[normalizedPathData];
normalizedPathData = normalizedPathData.replace(
/([^/]+\.prefetch\.rsc)$/,
'__$1'
);
delete lambdas[pathData];
return pathData.replace(/([^/]+\.prefetch\.rsc)$/, '__$1');
}
prerenders[normalizedPathData] = new Prerender({
return pathData;
};
if (outputPathData || outputPathPrefetchData) {
const prerender = new Prerender({
expiration: initialRevalidate,
lambda,
allowQuery,
@@ -2468,21 +2508,30 @@ export const onPrerenderRoute =
...initialHeaders,
'content-type': rscContentTypeHeader,
vary: rscVaryHeader,
// If it contains a pre-render, then it was postponed.
...(prerender && rscDidPostponeHeader
...(postponedPrerender && rscDidPostponeHeader
? { [rscDidPostponeHeader]: '1' }
: {}),
},
}
: {}),
});
if (outputPathPrefetchData) {
prerenders[normalizePathData(outputPathPrefetchData)] = prerender;
}
// If experimental ppr is not enabled for this route, then add the data
// route as a target for the prerender as well.
if (outputPathData && !experimentalPPR) {
prerenders[normalizePathData(outputPathData)] = prerender;
}
}
// we need to ensure all prerenders have a matching .rsc output
// otherwise routing could fall through unexpectedly for the
// fallback: false case as it doesn't have a dynamic route
// to catch the `.rsc` request for app -> pages routing
if (outputPrerenderPathData?.endsWith('.json') && appDir) {
if (outputPathData?.endsWith('.json') && appDir) {
const dummyOutput = new FileBlob({
data: '{}',
contentType: 'application/json',
@@ -2647,19 +2696,10 @@ export function getNextServerPath(nextVersion: string) {
: 'next/dist/next-server/server';
}
function pathnameToOutputName(
entryDirectory: string,
pathname: string,
addedIndexSuffix = false
) {
function pathnameToOutputName(entryDirectory: string, pathname: string) {
if (pathname === '/') {
pathname = '/index';
}
// If the `/index` was added for a route that ended in `/index` we need to
// strip the second one off before joining it with the entryDirectory.
else if (addedIndexSuffix) {
pathname = pathname.replace(/\/index$/, '');
}
return path.posix.join(entryDirectory, pathname);
}

View File

@@ -0,0 +1,6 @@
'use server';
export async function increment(value) {
await new Promise(resolve => setTimeout(resolve, 500));
return value + 1;
}

View File

@@ -0,0 +1,10 @@
export default function Root({ children }) {
return (
<html>
<head>
<title>Hello World</title>
</head>
<body>{children}</body>
</html>
);
}

View File

@@ -0,0 +1,25 @@
"use client";
import { useState } from "react";
import { increment } from "../actions";
export default function Home() {
const [count, setCount] = useState(0);
return (
<div>
{count}
<button
onClick={async () => {
const actionResult = await increment(count);
// @ts-ignore
setCount(actionResult);
console.log(actionResult);
}}
>
Trigger
</button>
Static
</div>
);
}

View File

@@ -0,0 +1,55 @@
/* eslint-env jest */
const path = require('path');
const { deployAndTest } = require('../../utils');
const fetch = require('../../../../../test/lib/deployment/fetch-retry');
const ctx = {};
function findActionId(page, runtime) {
page = `app${page}/page`; // add /app prefix and /page suffix
for (const [actionId, details] of Object.entries(
ctx.actionManifest[runtime]
)) {
if (details.workers[page]) {
return actionId;
}
}
throw new Error("Couldn't find action ID");
}
describe(`${__dirname.split(path.sep).pop()}`, () => {
beforeAll(async () => {
const info = await deployAndTest(__dirname);
const actionManifest = await fetch(
`${info.deploymentUrl}/server-reference-manifest.json`
).then(res => res.json());
ctx.actionManifest = actionManifest;
Object.assign(ctx, info);
});
it('should work when there is a rewrite targeting the root page', async () => {
const actionId = findActionId('/static', 'node');
const res = await fetch(ctx.deploymentUrl, {
method: 'POST',
body: JSON.stringify([1337]),
headers: {
'Content-Type': 'text/plain;charset=UTF-8',
'Next-Action': actionId,
},
});
expect(res.status).toEqual(200);
expect(res.headers.get('x-matched-path')).toBe('/static/');
expect(res.headers.get('x-vercel-cache')).toBe('BYPASS');
const body = await res.text();
// The action incremented the provided count by 1
expect(body).toContain('1338');
});
});

View File

@@ -0,0 +1,10 @@
module.exports = {
rewrites() {
return [
{
source: '/:path*',
destination: '/static/:path*',
},
];
},
};

View File

@@ -0,0 +1,9 @@
{
"dependencies": {
"next": "canary"
},
"scripts": {
"build": "next build && cp .next/server/server-reference-manifest.json public/"
},
"ignoreNextjsUpdates": true
}

View File

@@ -0,0 +1,14 @@
{
"builds": [
{
"src": "package.json",
"use": "@vercel/next"
}
],
"build": {
"env": {
"NEXT_EXPERIMENTAL_STREAMING_ACTIONS": "1"
}
},
"probes": []
}

View File

@@ -0,0 +1,19 @@
'use client';
import { useState } from 'react';
import { increment } from '../../../../actions';
export default function Page() {
const [count, setCount] = useState(0);
async function updateCount() {
const newCount = await increment(count);
setCount(newCount);
}
return (
<form action={updateCount}>
<div id="count">{count}</div>
<button>Submit</button>
</form>
);
}

View File

@@ -0,0 +1,5 @@
export const dynamic = 'force-dynamic';
export default function Layout({ children }) {
return children;
}

View File

@@ -0,0 +1,19 @@
'use client';
import { useState } from 'react';
import { increment } from '../../../../actions';
export default function Page() {
const [count, setCount] = useState(0);
async function updateCount() {
const newCount = await increment(count);
setCount(newCount);
}
return (
<form action={updateCount}>
<div id="count">{count}</div>
<button>Submit</button>
</form>
);
}

View File

@@ -0,0 +1,5 @@
export const dynamic = 'force-static';
export default function Layout({ children }) {
return children;
}

View File

@@ -0,0 +1,19 @@
'use client';
import { useState } from 'react';
import { increment } from '../../../actions';
export default function Page() {
const [count, setCount] = useState(0);
async function updateCount() {
const newCount = await increment(count);
setCount(newCount);
}
return (
<form action={updateCount}>
<div id="count">{count}</div>
<button>Submit</button>
</form>
);
}

View File

@@ -0,0 +1,5 @@
export const runtime = 'edge';
export default function Layout({ children }) {
return <div>{children}</div>;
}

View File

@@ -0,0 +1,45 @@
'use client';
// @ts-ignore
import { useCallback, useState } from 'react';
function request(method) {
return fetch('/api/test', {
method,
headers: {
'content-type': 'multipart/form-data;.*',
},
});
}
export default function Home() {
const [result, setResult] = useState('Press submit');
const onClick = useCallback(async method => {
const res = await request(method);
const text = await res.text();
setResult(res.ok ? `${method} ${text}` : 'Error: ' + res.status);
}, []);
return (
<>
<div className="flex flex-col items-center justify-center h-screen">
<div className="flex flex-row space-x-2 items-center justify-center">
<button
className="border border-white rounded-sm p-4 mb-4"
onClick={() => onClick('GET')}
>
Submit GET
</button>
<button
className="border border-white rounded-sm p-4 mb-4"
onClick={() => onClick('POST')}
>
Submit POST
</button>
</div>
<div className="text-white">{result}</div>
</div>
</>
);
}

View File

@@ -0,0 +1,5 @@
export const dynamic = 'force-dynamic';
export default function Layout({ children }) {
return children;
}

View File

@@ -0,0 +1,15 @@
import { revalidatePath } from 'next/cache';
export default async function Page() {
async function serverAction() {
'use server';
await new Promise(resolve => setTimeout(resolve, 1000));
revalidatePath('/dynamic');
}
return (
<form action={serverAction}>
<button>Submit</button>
</form>
);
}

View File

@@ -0,0 +1,15 @@
import { revalidatePath } from 'next/cache';
export default async function Page() {
async function serverAction() {
'use server';
await new Promise(resolve => setTimeout(resolve, 1000));
revalidatePath('/dynamic');
}
return (
<form action={serverAction}>
<button>Submit</button>
</form>
);
}

View File

@@ -0,0 +1,19 @@
import { revalidatePath } from 'next/cache';
export default async function Page() {
async function serverAction() {
'use server';
await new Promise(resolve => setTimeout(resolve, 1000));
revalidatePath('/dynamic');
}
return (
<form action={serverAction}>
<button>Submit</button>
</form>
);
}
export function generateStaticParams() {
return [{ slug: 'pre-generated' }];
}

View File

@@ -0,0 +1,5 @@
export const dynamic = 'force-static';
export default function Layout({ children }) {
return children;
}

View File

@@ -0,0 +1,15 @@
import { revalidatePath } from 'next/cache'
export default async function Page() {
async function serverAction() {
'use server';
await new Promise((resolve) => setTimeout(resolve, 1000));
revalidatePath('/dynamic');
}
return (
<form action={serverAction}>
<button>Submit</button>
</form>
);
}

View File

@@ -0,0 +1,25 @@
"use client";
import { useState } from "react";
import { increment } from "../../actions";
export default function Home() {
const [count, setCount] = useState(0);
return (
<div>
{count}
<button
onClick={async () => {
const actionResult = await increment(count);
// @ts-ignore
setCount(actionResult);
console.log(actionResult);
}}
>
Trigger
</button>
Static
</div>
);
}

View File

@@ -0,0 +1,25 @@
"use client";
import { useState } from "react";
import { increment } from "./actions";
export default function Home() {
const [count, setCount] = useState(0);
return (
<div>
{count}
<button
onClick={async () => {
const actionResult = await increment(count);
// @ts-ignore
setCount(actionResult);
console.log(actionResult);
}}
>
Trigger
</button>
Static
</div>
);
}

View File

@@ -0,0 +1,25 @@
"use client";
import { useState } from "react";
import { increment } from "../actions";
export default function Home() {
const [count, setCount] = useState(0);
return (
<div>
{count}
<button
onClick={async () => {
const actionResult = await increment(count);
// @ts-ignore
setCount(actionResult);
console.log(actionResult);
}}
>
Trigger
</button>
Static
</div>
);
}

View File

@@ -5,15 +5,18 @@ const fetch = require('../../../../../test/lib/deployment/fetch-retry');
const ctx = {};
function findActionId(page) {
function findActionId(page, runtime) {
page = `app${page}/page`; // add /app prefix and /page suffix
for (const [actionId, details] of Object.entries(ctx.actionManifest.node)) {
for (const [actionId, details] of Object.entries(
ctx.actionManifest[runtime]
)) {
if (details.workers[page]) {
return actionId;
}
}
return null;
throw new Error("Couldn't find action ID");
}
function generateFormDataPayload(actionId) {
@@ -41,141 +44,115 @@ describe(`${__dirname.split(path.sep).pop()}`, () => {
Object.assign(ctx, info);
});
describe('client component', () => {
it('should bypass the static cache for a server action', async () => {
const path = '/client/static';
const actionId = findActionId(path);
describe.each(['node', 'edge'])('runtime: %s', runtime => {
const basePath = runtime === 'edge' ? '/edge' : '';
describe('client component', () => {
it('should bypass the static cache for a server action', async () => {
const path = `${basePath}/client/static`;
const actionId = findActionId(path, runtime);
const res = await fetch(`${ctx.deploymentUrl}${path}`, {
method: 'POST',
body: JSON.stringify([1337]),
headers: {
'Content-Type': 'text/plain;charset=UTF-8',
'Next-Action': actionId,
},
const res = await fetch(`${ctx.deploymentUrl}${path}`, {
method: 'POST',
body: JSON.stringify([1337]),
headers: {
'Content-Type': 'text/plain;charset=UTF-8',
'Next-Action': actionId,
},
});
expect(res.status).toEqual(200);
const body = await res.text();
expect(body).toContain('1338');
expect(res.headers.get('x-matched-path')).toBe(path + '.action');
if (runtime === 'node') {
expect(res.headers.get('x-vercel-cache')).toBe('MISS');
} else {
// in edge runtime, x-vercel-cache is not returned on MISSes for some reason.
// this checks to ensure it was routed to the edge function instead.
expect(res.headers.get('x-edge-runtime')).toBe('1');
}
});
expect(res.status).toEqual(200);
const body = await res.text();
expect(body).toContain('1338');
expect(res.headers.get('x-matched-path')).toBe(path + '.action');
expect(res.headers.get('x-vercel-cache')).toBe('MISS');
});
it('should bypass the static cache for a server action on a page with dynamic params', async () => {
const path = `${basePath}/client/static/[dynamic-static]`;
const actionId = findActionId(path, runtime);
it('should bypass the static cache for a server action on a page with dynamic params', async () => {
const path = '/client/static/[dynamic-static]';
const actionId = findActionId(path);
const res = await fetch(`${ctx.deploymentUrl}${path}`, {
method: 'POST',
body: JSON.stringify([1337]),
headers: {
'Content-Type': 'text/plain;charset=UTF-8',
'Next-Action': actionId,
},
});
const res = await fetch(`${ctx.deploymentUrl}${path}`, {
method: 'POST',
body: JSON.stringify([1337]),
headers: {
'Content-Type': 'text/plain;charset=UTF-8',
'Next-Action': actionId,
},
expect(res.status).toEqual(200);
const body = await res.text();
expect(body).toContain('1338');
expect(res.headers.get('x-matched-path')).toBe(path + '.action');
if (runtime === 'node') {
expect(res.headers.get('x-vercel-cache')).toBe('MISS');
} else {
expect(res.headers.get('x-edge-runtime')).toBe('1');
}
});
expect(res.status).toEqual(200);
const body = await res.text();
expect(body).toContain('1338');
expect(res.headers.get('x-matched-path')).toBe(path + '.action');
expect(res.headers.get('x-vercel-cache')).toBe('MISS');
});
it('should bypass the static cache for a multipart request (no action header)', async () => {
const path = `${basePath}/client/static`;
const actionId = findActionId(path, runtime);
it('should bypass the static cache for a multipart request (no action header)', async () => {
const path = '/client/static';
const actionId = findActionId(path);
const res = await fetch(`${ctx.deploymentUrl}${path}`, {
method: 'POST',
body: `------WebKitFormBoundaryHcVuFa30AN0QV3uZ\r\nContent-Disposition: form-data; name=\"1_$ACTION_ID_${actionId}\"\r\n\r\n\r\n------WebKitFormBoundaryHcVuFa30AN0QV3uZ\r\nContent-Disposition: form-data; name=\"0\"\r\n\r\n[\"$K1\"]\r\n------WebKitFormBoundaryHcVuFa30AN0QV3uZ--\r\n`,
headers: {
'Content-Type':
'multipart/form-data; boundary=----WebKitFormBoundaryHcVuFa30AN0QV3uZ',
},
});
const res = await fetch(`${ctx.deploymentUrl}${path}`, {
method: 'POST',
body: `------WebKitFormBoundaryHcVuFa30AN0QV3uZ\r\nContent-Disposition: form-data; name=\"1_$ACTION_ID_${actionId}\"\r\n\r\n\r\n------WebKitFormBoundaryHcVuFa30AN0QV3uZ\r\nContent-Disposition: form-data; name=\"0\"\r\n\r\n[\"$K1\"]\r\n------WebKitFormBoundaryHcVuFa30AN0QV3uZ--\r\n`,
headers: {
'Content-Type':
'multipart/form-data; boundary=----WebKitFormBoundaryHcVuFa30AN0QV3uZ',
},
});
expect(res.status).toEqual(200);
expect(res.headers.get('content-type')).toBe('text/html; charset=utf-8');
// This is a "BYPASS" because no action ID was provided, so it'll fall back to
// `experimentalBypassFor` handling.
expect(res.headers.get('x-vercel-cache')).toBe('BYPASS');
expect(res.headers.get('x-matched-path')).toBe(path);
});
it('should properly invoke the action on a dynamic page', async () => {
const path = '/client/dynamic/[id]';
const actionId = findActionId(path);
const res = await fetch(`${ctx.deploymentUrl}${path}`, {
method: 'POST',
body: JSON.stringify([1337]),
headers: {
'Content-Type': 'text/plain;charset=UTF-8',
'Next-Action': actionId,
},
});
expect(res.status).toEqual(200);
const body = await res.text();
expect(body).toContain('1338');
expect(res.headers.get('x-matched-path')).toBe(path + '.action');
expect(res.headers.get('x-vercel-cache')).toBe('MISS');
});
});
describe('server component', () => {
it('should bypass the static cache for a server action', async () => {
const path = '/rsc/static';
const actionId = findActionId(path);
const res = await fetch(
`${ctx.deploymentUrl}${path}`,
generateFormDataPayload(actionId)
);
expect(res.status).toEqual(200);
expect(res.headers.get('x-matched-path')).toBe(path + '.action');
expect(res.headers.get('content-type')).toBe('text/x-component');
expect(res.headers.get('x-vercel-cache')).toBe('MISS');
});
it('should bypass the static cache for a server action on a page with dynamic params', async () => {
const path = '/rsc/static/[dynamic-static]';
const actionId = findActionId(path);
const res = await fetch(
`${ctx.deploymentUrl}${path}`,
generateFormDataPayload(actionId)
);
expect(res.status).toEqual(200);
expect(res.headers.get('x-matched-path')).toBe(path + '.action');
expect(res.headers.get('content-type')).toBe('text/x-component');
expect(res.headers.get('x-vercel-cache')).toBe('MISS');
});
it('should properly invoke the action on a dynamic page', async () => {
const path = '/rsc/dynamic';
const actionId = findActionId(path);
const res = await fetch(
`${ctx.deploymentUrl}${path}`,
generateFormDataPayload(actionId)
);
expect(res.status).toEqual(200);
expect(res.headers.get('x-matched-path')).toBe(path + '.action');
expect(res.headers.get('content-type')).toBe('text/x-component');
expect(res.headers.get('x-vercel-cache')).toBe('MISS');
});
describe('generateStaticParams', () => {
it('should bypass the static cache for a server action when pre-generated', async () => {
const path = '/rsc/static/generate-static-params/pre-generated';
const actionId = findActionId(
'/rsc/static/generate-static-params/[slug]'
expect(res.status).toEqual(200);
expect(res.headers.get('content-type')).toBe(
'text/html; charset=utf-8'
);
if (runtime === 'node') {
// This is a "BYPASS" because no action ID was provided, so it'll fall back to
// `experimentalBypassFor` handling.
expect(res.headers.get('x-vercel-cache')).toBe('BYPASS');
} else {
expect(res.headers.get('x-edge-runtime')).toBe('1');
}
expect(res.headers.get('x-matched-path')).toBe(path);
});
it('should properly invoke the action on a dynamic page', async () => {
const path = `${basePath}/client/dynamic/[id]`;
const actionId = findActionId(path, runtime);
const res = await fetch(`${ctx.deploymentUrl}${path}`, {
method: 'POST',
body: JSON.stringify([1337]),
headers: {
'Content-Type': 'text/plain;charset=UTF-8',
'Next-Action': actionId,
},
});
expect(res.status).toEqual(200);
const body = await res.text();
expect(body).toContain('1338');
expect(res.headers.get('x-matched-path')).toBe(path + '.action');
if (runtime === 'node') {
expect(res.headers.get('x-vercel-cache')).toBe('MISS');
} else {
expect(res.headers.get('x-edge-runtime')).toBe('1');
}
});
});
describe('server component', () => {
it('should bypass the static cache for a server action', async () => {
const path = `${basePath}/rsc/static`;
const actionId = findActionId(path, runtime);
const res = await fetch(
`${ctx.deploymentUrl}${path}`,
@@ -183,27 +160,213 @@ describe(`${__dirname.split(path.sep).pop()}`, () => {
);
expect(res.status).toEqual(200);
expect(res.headers.get('x-matched-path')).toBe(
'/rsc/static/generate-static-params/[slug].action'
);
expect(res.headers.get('x-matched-path')).toBe(path + '.action');
expect(res.headers.get('content-type')).toBe('text/x-component');
expect(res.headers.get('x-vercel-cache')).toBe('MISS');
if (runtime === 'node') {
expect(res.headers.get('x-vercel-cache')).toBe('MISS');
} else {
expect(res.headers.get('x-edge-runtime')).toBe('1');
}
});
it('should bypass the static cache for a server action when not pre-generated', async () => {
const page = '/rsc/static/generate-static-params/[slug]';
const actionId = findActionId(page);
it('should bypass the static cache for a server action on a page with dynamic params', async () => {
const path = `${basePath}/rsc/static/[dynamic-static]`;
const actionId = findActionId(path, runtime);
const res = await fetch(
`${ctx.deploymentUrl}/rsc/static/generate-static-params/not-pre-generated`,
`${ctx.deploymentUrl}${path}`,
generateFormDataPayload(actionId)
);
expect(res.status).toEqual(200);
expect(res.headers.get('x-matched-path')).toBe(page + '.action');
expect(res.headers.get('x-matched-path')).toBe(path + '.action');
expect(res.headers.get('content-type')).toBe('text/x-component');
expect(res.headers.get('x-vercel-cache')).toBe('MISS');
if (runtime === 'node') {
expect(res.headers.get('x-vercel-cache')).toBe('MISS');
} else {
expect(res.headers.get('x-edge-runtime')).toBe('1');
}
});
it('should properly invoke the action on a dynamic page', async () => {
const path = `${basePath}/rsc/dynamic`;
const actionId = findActionId(path, runtime);
const res = await fetch(
`${ctx.deploymentUrl}${path}`,
generateFormDataPayload(actionId)
);
expect(res.status).toEqual(200);
expect(res.headers.get('x-matched-path')).toBe(path + '.action');
expect(res.headers.get('content-type')).toBe('text/x-component');
if (runtime === 'node') {
expect(res.headers.get('x-vercel-cache')).toBe('MISS');
} else {
expect(res.headers.get('x-edge-runtime')).toBe('1');
}
});
describe('generateStaticParams', () => {
it('should bypass the static cache for a server action when pre-generated', async () => {
const path = `${basePath}/rsc/static/generate-static-params/pre-generated`;
const dynamicPath = `${basePath}/rsc/static/generate-static-params/[slug]`;
const actionId = findActionId(dynamicPath, runtime);
const res = await fetch(
`${ctx.deploymentUrl}${path}`,
generateFormDataPayload(actionId)
);
expect(res.status).toEqual(200);
expect(res.headers.get('x-matched-path')).toBe(
dynamicPath + '.action'
);
expect(res.headers.get('content-type')).toBe('text/x-component');
if (runtime === 'node') {
expect(res.headers.get('x-vercel-cache')).toBe('MISS');
} else {
expect(res.headers.get('x-edge-runtime')).toBe('1');
}
});
it('should bypass the static cache for a server action when not pre-generated', async () => {
const page = `${basePath}/rsc/static/generate-static-params/[slug]`;
const actionId = findActionId(page, runtime);
const res = await fetch(
`${ctx.deploymentUrl}/${basePath}/rsc/static/generate-static-params/not-pre-generated`,
generateFormDataPayload(actionId)
);
expect(res.status).toEqual(200);
expect(res.headers.get('x-matched-path')).toBe(page + '.action');
expect(res.headers.get('content-type')).toBe('text/x-component');
if (runtime === 'node') {
expect(res.headers.get('x-vercel-cache')).toBe('MISS');
} else {
expect(res.headers.get('x-edge-runtime')).toBe('1');
}
});
});
});
it('should not match to an action output when the RSC header is present', async () => {
const canonicalPath = `${basePath}/client/dynamic/1`;
const pagePath = `${basePath}/client/dynamic/[id]`;
const actionId = findActionId(pagePath, runtime);
const res = await fetch(`${ctx.deploymentUrl}${canonicalPath}`, {
method: 'POST',
body: JSON.stringify([1337]),
headers: {
'Content-Type': 'text/plain;charset=UTF-8',
'Next-Action': actionId,
'Next-Response': 'rsc',
RSC: '1',
},
});
expect(res.status).toEqual(200);
expect(res.headers.get('x-matched-path')).toBe(pagePath + '.rsc');
expect(res.headers.get('content-type')).toBe('text/x-component');
const body = await res.text();
expect(body).toContain(JSON.stringify(['id', '1', 'd']));
expect(body).not.toContain(JSON.stringify(['id', '1.action', 'd']));
});
it('should work when a rewrite targets an action', async () => {
const targetPath = `${basePath}/rsc/static`;
const canonicalPath = `/rewrite/${basePath}/rsc/static`;
const actionId = findActionId(targetPath, runtime);
const res = await fetch(
`${ctx.deploymentUrl}${canonicalPath}`,
generateFormDataPayload(actionId)
);
expect(res.status).toEqual(200);
expect(res.headers.get('x-matched-path')).toBe(targetPath + '.action');
expect(res.headers.get('content-type')).toBe('text/x-component');
if (runtime === 'node') {
expect(res.headers.get('x-vercel-cache')).toBe('MISS');
} else {
expect(res.headers.get('x-edge-runtime')).toBe('1');
}
});
it('should work when a rewrite greedy matches an action rewrite', async () => {
const targetPath = `${basePath}/static`;
const canonicalPath = `/greedy-rewrite/${basePath}/static`;
const actionId = findActionId(targetPath, runtime);
const res = await fetch(
`${ctx.deploymentUrl}${canonicalPath}`,
generateFormDataPayload(actionId)
);
expect(res.status).toEqual(200);
expect(res.headers.get('x-matched-path')).toBe(targetPath + '.action');
expect(res.headers.get('content-type')).toBe('text/x-component');
if (runtime === 'node') {
expect(res.headers.get('x-vercel-cache')).toBe('MISS');
} else {
expect(res.headers.get('x-edge-runtime')).toBe('1');
}
});
it('should work on the index route', async () => {
const canonicalPath = '/';
const actionId = findActionId('', 'node');
const res = await fetch(
`${ctx.deploymentUrl}${canonicalPath}`,
generateFormDataPayload(actionId)
);
expect(res.status).toEqual(200);
expect(res.headers.get('x-matched-path')).toBe('/index.action');
expect(res.headers.get('content-type')).toBe('text/x-component');
expect(res.headers.get('x-vercel-cache')).toBe('MISS');
});
});
describe('rewrite to index', () => {
it('should work when user has a rewrite to the index route', async () => {
const canonicalPath = '/rewritten-to-index';
const actionId = findActionId('', 'node');
const res = await fetch(
`${ctx.deploymentUrl}${canonicalPath}`,
generateFormDataPayload(actionId)
);
expect(res.status).toEqual(200);
expect(res.headers.get('x-matched-path')).toBe('/index.action');
expect(res.headers.get('content-type')).toBe('text/x-component');
expect(res.headers.get('x-vercel-cache')).toBe('MISS');
});
it('should work when entire path is rewritten', async () => {
const actionId = findActionId('/static', 'node');
const res = await fetch(ctx.deploymentUrl, {
method: 'POST',
body: JSON.stringify([1337]),
headers: {
'Content-Type': 'text/plain;charset=UTF-8',
'Next-Action': actionId,
'x-rewrite-me': '1',
},
});
expect(res.status).toEqual(200);
expect(res.headers.get('x-matched-path')).toBe('/index.action');
expect(res.headers.get('x-vercel-cache')).toBe('MISS');
const body = await res.text();
// The action incremented the provided count by 1
expect(body).toContain('1338');
});
});

View File

@@ -1 +1,36 @@
module.exports = {};
module.exports = {
rewrites() {
return [
{
source: '/rewrite/rsc/static',
destination: '/rsc/static',
},
{
source: '/rewrite/edge/rsc/static',
destination: '/edge/rsc/static',
},
{
source: '/greedy-rewrite/static/:path*',
destination: '/static/:path*',
},
{
source: '/greedy-rewrite/edge/static/:path*',
destination: '/edge/static/:path*',
},
{
source: '/rewritten-to-index',
destination: '/?fromRewrite=1',
},
{
source: '/:path*',
destination: '/static/:path*',
has: [
{
type: 'header',
key: 'x-rewrite-me',
},
],
},
];
},
};

View File

@@ -0,0 +1,14 @@
import Link from 'next/link';
const Page = ({ params }) => {
return (
<div>
<div id="page-param">page-param-{params.slug?.[0] ?? ''}</div>
<Link href="/">Home</Link>
<Link href="/foo">Foo</Link>
<Link href="/bar">Bar</Link>
</div>
);
};
export default Page;

View File

@@ -0,0 +1,10 @@
export default function Root({ children }) {
return (
<html>
<head>
<title>Hello World</title>
</head>
<body>{children}</body>
</html>
);
}

View File

@@ -0,0 +1,12 @@
/* eslint-env jest */
const path = require('path');
const { deployAndTest } = require('../../utils');
const ctx = {};
describe(`${__dirname.split(path.sep).pop()}`, () => {
it('should deploy and pass probe checks', async () => {
const info = await deployAndTest(__dirname);
Object.assign(ctx, info);
});
});

View File

@@ -0,0 +1 @@
module.exports = {};

View File

@@ -0,0 +1,8 @@
{
"dependencies": {
"next": "canary",
"react": "19.0.0-rc-f994737d14-20240522",
"react-dom": "19.0.0-rc-f994737d14-20240522"
},
"ignoreNextjsUpdates": true
}

View File

@@ -0,0 +1,27 @@
{
"builds": [
{
"src": "package.json",
"use": "@vercel/next"
}
],
"probes": [
{
"path": "/",
"status": 200,
"mustContain": "\"page-param-\",\"\"",
"mustNotContain": "\"page-param-\",\"index\"",
"headers": {
"RSC": "1"
}
},
{
"path": "/foo",
"status": 200,
"mustContain": "\"page-param-\",\"foo\"",
"headers": {
"RSC": "1"
}
}
]
}

View File

@@ -1,8 +1,8 @@
{
"dependencies": {
"next": "canary",
"react": "experimental",
"react-dom": "experimental"
"react": "19.0.0-rc-f994737d14-20240522",
"react-dom": "19.0.0-rc-f994737d14-20240522"
},
"ignoreNextjsUpdates": true
}

View File

@@ -1,8 +1,8 @@
{
"dependencies": {
"next": "canary",
"react": "experimental",
"react-dom": "experimental"
"react": "19.0.0-rc-f994737d14-20240522",
"react-dom": "19.0.0-rc-f994737d14-20240522"
},
"ignoreNextjsUpdates": true,
"scripts": {

View File

@@ -1,8 +1,8 @@
{
"dependencies": {
"next": "canary",
"react": "experimental",
"react-dom": "experimental"
"react": "19.0.0-rc-f994737d14-20240522",
"react-dom": "19.0.0-rc-f994737d14-20240522"
},
"ignoreNextjsUpdates": true
}

View File

@@ -1,8 +1,8 @@
{
"dependencies": {
"next": "canary",
"react": "experimental",
"react-dom": "experimental"
"react": "19.0.0-rc-f994737d14-20240522",
"react-dom": "19.0.0-rc-f994737d14-20240522"
},
"ignoreNextjsUpdates": true
}

View File

@@ -7,8 +7,8 @@
},
"dependencies": {
"next": "canary",
"react": "experimental",
"react-dom": "experimental"
"react": "19.0.0-rc-f994737d14-20240522",
"react-dom": "19.0.0-rc-f994737d14-20240522"
},
"ignoreNextjsUpdates": true
}

View File

@@ -0,0 +1,3 @@
export { default } from '../page';
export const experimental_ppr = false;

View File

@@ -0,0 +1,7 @@
export default function Layout({ children }) {
return (
<html>
<body>{children}</body>
</html>
);
}

View File

@@ -0,0 +1,17 @@
import { unstable_noStore } from 'next/cache';
import { Suspense } from 'react';
export const experimental_ppr = true;
function Dynamic() {
unstable_noStore();
return <div id="sentinel:dynamic">Dynamic</div>;
}
export default function Page() {
return (
<Suspense fallback={<div id="sentinel:loading">Loading...</div>}>
<Dynamic />
</Suspense>
);
}

View File

@@ -0,0 +1,3 @@
export default function Page() {
return <div id="sentinel:static">Static</div>;
}

View File

@@ -0,0 +1,12 @@
/* eslint-env jest */
const path = require('path');
const { deployAndTest } = require('../../utils');
const ctx = {};
describe(`${__dirname.split(path.sep).pop()}`, () => {
it('should deploy and pass probe checks', async () => {
const info = await deployAndTest(__dirname);
Object.assign(ctx, info);
});
});

View File

@@ -0,0 +1,5 @@
module.exports = {
experimental: {
ppr: 'incremental',
},
};

Some files were not shown because too many files have changed in this diff Show More