Commit Graph

417 Commits

Author SHA1 Message Date
Chris Barber
fa443035f6 [tests] Add test for set-cookie with multiple cookies (#9916)
This adds the missing test for https://github.com/vercel/vercel/pull/9899.
2023-05-06 10:18:52 +00:00
Kiko Beats
e3fe368baa [cli][node] upgrade async-listen to 3.0.0 (#9907)
The `async-listen@3.0.0` is ESM ready and always returns a `URL`
instance; That helps us to unify code.
2023-05-05 16:09:10 +02:00
Chris Barber
cd7d3ef1c5 [node] Explicitly set 'set-cookie' header (#9899)
When looping over the response headers returned by `node-fetch`, it will join `set-cookie` header value into a single string. The whatwg calls for a `headers.getSetCookie()` function to handle the `set-cookie` special case, but `node-fetch@2.x` doesn't support it.

As a workaround, we need to grab the raw `set-cookie` header value.
2023-05-03 22:12:45 +00:00
Sean Massa
672c1681cc Publish Stable
- vercel@29.1.0
 - @vercel/frameworks@1.4.0
 - @vercel/fs-detectors@3.9.0
 - @vercel/gatsby-plugin-vercel-builder@1.3.2
 - @vercel/node@2.14.1
 - @vercel/remix-builder@1.8.7
 - @vercel/static-build@1.3.28
2023-05-03 14:08:25 -05:00
Kiko Beats
5ee4acb23b use ws instead of undici.WebSocket (#9893)
The `WebSocket` constructor exposed by `undici` is not working against some db connections.

That can be considered kind of expected since `undici` docs is saying it's experimental.

We're working into isolate the issue and report at `undici` repository, but for now, let's just use `ws` for all the node versions.
2023-05-02 18:01:40 +00:00
Steven
b5db13c970 Publish Stable
- vercel@29.0.1
 - @vercel/fs-detectors@3.8.13
 - @vercel/gatsby-plugin-vercel-builder@1.3.1
 - @vercel/next@3.8.0
 - @vercel/node@2.14.0
 - @vercel/static-build@1.3.27
2023-04-29 18:02:35 -04:00
JJ Kasper
cc140d6e28 [node] Fix exposing WebSocket to edge runtime and legacy next tests (#9871)
This ensures we expose WebSocket correctly for edge runtime for Node.js
v16 and v18 properly. This also fixes failing legacy Next.js tests due
to a bad `@babel/compat-data` package publish from 8 hours ago.

x-ref: [slack
thread](https://vercel.slack.com/archives/C04R82GSDBN/p1682709850008189?thread_ts=1682707749.424459&cid=C04R82GSDBN)
x-ref: https://github.com/vercel/next.js/pull/48924
x-ref: https://github.com/vercel/vercel/pull/9860
Closes: https://github.com/vercel/vercel/pull/9870
2023-04-29 10:43:40 +02:00
Kiko Beats
09ac96ae21 [node] expose WebSocket constructor in Edge functions (#9860)
This PR exposes `WebSocket` to be used for Edge Runtime for `vc dev`.

Ideally, that's a thing we should to handle inside `edge-runtime`
dependency.

Unfortunately, that is not as easy as it sounds, since Edge Runtime is
doing a heavy use of vm module and `undici` is using some Node.js APIs
that are not available, or they are hard to make them working inside vm.

Related PR: https://github.com/vercel/edge-runtime/pull/309

While we're finishing that work, in order to don't delay users to start
using `WebSocket`, we can simply expose it directly from `undici` as
dependency.

---------

Co-authored-by: Chris Barber <chris.barber@vercel.com>
2023-04-28 23:03:35 +02:00
Nathan Rajlich
ebd1bf41b6 [node] Don't compile "edge" functions with Babel (#9868) 2023-04-28 20:37:26 +00:00
Steven
e1a16b0333 [node] Add log message about compiling ESM to CJS (#9866)
When `@vercel/node` was created 5 or so years ago, Node.js didn't support ESM out of the box. So to create a zero configuration experience, babel was introduce to compile the authored ESM into the runtime CJS.

Today, Node.js supports ESM but you have to opt in using `type: module` in package.json or the `.mjs` file extension.

Indeed `@vercel/node` detects ESM and skips babel compilation. However, there is a case where the source code is ESM and a dependency supports both ESM and CJS via `imports` in package.json. This case will break because `@vercel/nft` traces the source file as ESM and assumes the dependency will be resolved as ESM too. But after `@vercel/nft` traces the source file, `@vercel/node` will compile to CJS and thus the trace will be incorrect and fail at runtime.

So this PR adds a warning when babel compiles ESM to CJS because it is no longer expected in 2023.
2023-04-28 19:58:43 +00:00
Sean Massa
ce597ce0ec [node] validate function runtime and throw when "nodejs" (#9851)
We want to keep the currently unused `runtime: "nodejs"` value clear for future use. This PR effectively makes any unrecognized value fail the build. If the value is "nodejs" specifically, a direct error is thrown suggesting they remove the value.

Only a handful of projects set this value currently. We're reaching out to them to let them know that this value is not currently supported and that they should remove it. Then, we should deploy this PR so that anyone else using this value will know to remove it.
2023-04-27 19:22:47 +00:00
Sean Massa
2de365f9cf Publish Stable
- @vercel/build-utils@6.7.2
 - vercel@29.0.0
 - @vercel/client@12.4.12
 - @vercel/edge@0.3.4
 - @vercel/frameworks@1.3.5
 - @vercel/fs-detectors@3.8.12
 - @vercel/gatsby-plugin-vercel-builder@1.3.0
 - @vercel/go@2.5.1
 - @vercel/hydrogen@0.0.64
 - @vercel/next@3.7.6
 - @vercel/node@2.13.0
 - @vercel/python@3.1.60
 - @vercel/redwood@1.1.15
 - @vercel/remix-builder@1.8.6
 - @vercel/routing-utils@2.2.1
 - @vercel/ruby@1.3.76
 - @vercel/static-build@1.3.26
 - @vercel/static-config@2.0.17
2023-04-27 13:09:25 -05:00
Chris Barber
9e183b2e8d [tests] Move allowJs: true to test tsconfig.json (#9862) 2023-04-27 10:27:02 -05:00
Sean Massa
0490a7733b [tests] install root typescript version 4.9.5 and standardize on that version (#9858)
This add a root-level `typescript` version that matches the one used throughout for VS Code (and other IDEs) to use when browsing the code. After this PR merges, you will be able to set VS Code's TypeScript version to match the project's version.

This will remove issues where the IDE says TypeScript compilation is good to go, but `pnpm build` disagrees.

If there's a better way to allow this, please suggest it!

---

To enable:

<img width="849" alt="Screenshot 2023-04-25 at 4 28 22 PM" src="https://user-images.githubusercontent.com/41545/234408245-205b3260-7b1d-4c43-a531-d616915dbefb.png">

Then:

<img width="1015" alt="Screenshot 2023-04-25 at 4 29 20 PM" src="https://user-images.githubusercontent.com/41545/234408271-4e7b4ec8-0be3-4743-afd7-813a267c0756.png">
2023-04-27 08:13:53 +00:00
Chris Barber
65a6e713c8 [node] Fix ESM dependency support (#9692) 2023-04-26 12:23:43 -05:00
Sean Massa
c0380cac5a [node] remove last mention of node-bridge (#9838) 2023-04-21 11:57:19 -05:00
Chris Barber
7082da8451 Publish Stable
- vercel@28.20.0
 - @vercel/client@12.4.11
 - @vercel/gatsby-plugin-vercel-analytics@1.0.10
 - @vercel/gatsby-plugin-vercel-builder@1.2.10
 - @vercel/node@2.12.0
 - @vercel/static-build@1.3.25
2023-04-20 09:19:59 -05:00
Kiko Beats
6dded87426 [node] Add streaming support for vc dev (#9745)
Until now, the user code response it's buffered and serialized. This is
mismatching how Vercel works these days.

This PR enables streaming response in `vc dev` for Edge/Serverless.

As part of the implementation, the `node-bridge` which spawns a process
to consume the user code is not necessary anymore.

Some necessary files (like HTTP server helpers) have been moved to live
in node builder package instead.

---------

Co-authored-by: Ethan Arrowood <ethan.arrowood@vercel.com>
Co-authored-by: Sean Massa <EndangeredMassa@gmail.com>
2023-04-19 23:56:41 +02:00
Chris Barber
a63b9d960b Publish Stable
- vercel@28.19.0
 - @vercel/client@12.4.10
 - @vercel/edge@0.3.3
 - @vercel/error-utils@1.0.10
 - @vercel/fs-detectors@3.8.11
 - @vercel/gatsby-plugin-vercel-builder@1.2.9
 - @vercel/go@2.5.0
 - @vercel/hydrogen@0.0.63
 - @vercel/next@3.7.5
 - @vercel/node@2.11.0
 - @vercel/python@3.1.59
 - @vercel/remix-builder@1.8.5
 - @vercel/static-build@1.3.24
 - @vercel/static-config@2.0.16
2023-04-19 10:14:58 -05:00
Chris Barber
2081f10b22 [node] Move path-to-regexp and ts-morph from dev deps to deps (#9823)
`@vercel/node` uses `ncc` to bundle the `index.js` spawns the dev server entrypoint which does not bundle the required dependencies, thus `path-to-regexp` and `ts-morph` must be moved from dev dependencies to dependencies.

Fixes #9735.
2023-04-18 16:37:09 +00:00
Chris Barber
732ac2072c [tests] Update Typescript, Jest, and ts-jest (#9782)
Co-authored-by: Nathan Rajlich <n@n8.io>
Co-authored-by: Swarnava Sengupta <swarnavasengupta@gmail.com>
2023-04-12 08:38:03 -05:00
Sean Massa
925c8ba18c Publish Stable
- @vercel/build-utils@6.7.1
 - vercel@28.18.4
 - @vercel/client@12.4.9
 - @vercel/edge@0.3.2
 - @vercel/error-utils@1.0.9
 - @vercel/frameworks@1.3.4
 - @vercel/fs-detectors@3.8.9
 - @vercel/gatsby-plugin-vercel-analytics@1.0.9
 - @vercel/gatsby-plugin-vercel-builder@1.2.7
 - @vercel/go@2.4.4
 - @vercel/hydrogen@0.0.62
 - @vercel/next@3.7.4
 - @vercel/node-bridge@4.0.1
 - @vercel/node@2.10.3
 - @vercel/python@3.1.58
 - @vercel/redwood@1.1.14
 - @vercel/remix-entry-server@0.1.1
 - @vercel/remix-builder@1.8.4
 - @vercel/routing-utils@2.2.0
 - @vercel/ruby@1.3.75
 - @vercel/static-build@1.3.22
 - @vercel/static-config@2.0.15
2023-04-07 16:43:42 -05:00
Nathan Rajlich
ee4ba6ccbe [all] Use correct "license" field in package.json (#9754)
Follow-up to #9696. Ensures that all packages in this repository have
the correct "license" field in their respective `package.json` files set
to "Apache-2.0", to match the `LICENSE` file at the root of the
repository.

The `LICENSE` file the authoritative source, so the "MIT" value was
incorrect. This change corrects the previous values and is not
considered a relicensing.
2023-04-06 15:33:55 -07:00
Kiko Beats
434c794713 [tests] move test files to subdirectory (#9749)
Some unit tests didn't run since Aug 2022 because they are not included as part of the testing command.

This PR introduce `unit` and `integration` folders for testing, so anything that it's placed there will be run as part of the testing command.
2023-04-04 16:49:41 +00:00
Nathan Rajlich
46348201b4 Publish Stable
- @vercel/build-utils@6.7.0
 - vercel@28.18.3
 - @vercel/client@12.4.8
 - @vercel/fs-detectors@3.8.8
 - @vercel/gatsby-plugin-vercel-builder@1.2.6
 - @vercel/go@2.4.3
 - @vercel/hydrogen@0.0.61
 - @vercel/next@3.7.3
 - @vercel/node@2.10.2
 - @vercel/python@3.1.57
 - @vercel/redwood@1.1.13
 - @vercel/remix-builder@1.8.3
 - @vercel/ruby@1.3.74
 - @vercel/static-build@1.3.21
2023-03-29 12:25:26 -07:00
Nathan Rajlich
509926545e [build-utils] Rename Lambda experimentalResponseStreaming prop to supportsResponseStreaming (#9721) 2023-03-29 12:11:09 -07:00
Sean Massa
54514a44af Publish Stable
- @vercel/build-utils@6.6.0
 - vercel@28.18.2
 - @vercel/client@12.4.7
 - @vercel/fs-detectors@3.8.7
 - @vercel/gatsby-plugin-vercel-builder@1.2.5
 - @vercel/go@2.4.2
 - @vercel/hydrogen@0.0.60
 - @vercel/next@3.7.2
 - @vercel/node-bridge@4.0.0
 - @vercel/node@2.10.1
 - @vercel/python@3.1.56
 - @vercel/redwood@1.1.12
 - @vercel/remix-builder@1.8.2
 - @vercel/ruby@1.3.73
 - @vercel/static-build@1.3.20
2023-03-27 22:25:08 -05:00
Kiko Beats
22e1a6a9ce [node-bridge]: remove API Gateway normalization (#9711)
We no longer use since a long time ago
2023-03-24 20:12:36 +01:00
Sean Massa
6a7fa1526c Publish Stable
- vercel@28.18.1
 - @vercel/gatsby-plugin-vercel-builder@1.2.4
 - @vercel/next@3.7.1
 - @vercel/node@2.10.0
 - @vercel/remix-builder@1.8.1
 - @vercel/static-build@1.3.19
2023-03-23 14:45:33 -05:00
Gal Schlezinger
40f73e7978 [node] support node:[lib] in vc dev (#9694)
- [node] add edge-node-compat-plugin
- [node] implement edge-handler
2023-03-23 17:48:49 +00:00
Sean Massa
ab9915af32 Publish Stable
- @vercel/build-utils@6.5.0
 - vercel@28.18.0
 - @vercel/client@12.4.6
 - @vercel/fs-detectors@3.8.6
 - @vercel/gatsby-plugin-vercel-builder@1.2.3
 - @vercel/go@2.4.1
 - @vercel/hydrogen@0.0.59
 - @vercel/next@3.7.0
 - @vercel/node@2.9.14
 - @vercel/python@3.1.55
 - @vercel/redwood@1.1.11
 - @vercel/remix-builder@1.8.0
 - @vercel/ruby@1.3.72
 - @vercel/static-build@1.3.18
2023-03-22 12:37:51 -05:00
Sean Massa
0fb0601d19 [node] Improve edge-handler-template error handling (#9697) 2023-03-22 11:31:44 -05:00
Nathan Rajlich
20bd71ce70 [node][remix] Update nft conditions to include "edge-light" for Edge Functions (#9700) 2023-03-21 23:59:49 +00:00
Nathan Rajlich
b2c68f1301 Publish Stable
- @vercel/build-utils@6.4.0
 - vercel@28.17.0
 - @vercel/client@12.4.5
 - @vercel/frameworks@1.3.3
 - @vercel/fs-detectors@3.8.5
 - @vercel/gatsby-plugin-vercel-builder@1.2.2
 - @vercel/go@2.4.0
 - @vercel/hydrogen@0.0.58
 - @vercel/next@3.6.7
 - @vercel/node@2.9.13
 - @vercel/python@3.1.54
 - @vercel/redwood@1.1.10
 - @vercel/remix-builder@1.7.0
 - @vercel/routing-utils@2.1.11
 - @vercel/ruby@1.3.71
 - @vercel/static-build@1.3.17
 - @vercel/static-config@2.0.14
2023-03-16 12:23:51 -07:00
Vladislav Ponomarev
af7b34aa45 [node] Handle multi-protocol in Edge Functions (#9502)
Co-authored-by: Chris Barber <chris.barber@vercel.com>
Co-authored-by: Sean Massa <EndangeredMassa@gmail.com>
fix #9501
2023-03-16 11:01:07 -05:00
Steven
bada86b8d6 [tests] Add prettier check (#9664)
This PR fixes the formatting on several files that were never run through `prettier`.

It also makes sure to run `prettier` in CI to to [fail fast](https://github.com/vercel/vercel/actions/runs/4408442998/jobs/7723453978) when the incorrect formatting is attempted.
2023-03-13 19:55:59 +00:00
Sean Massa
66fe3db888 [tests] add tests to edge handler template (#9528)
The Edge Handler wrapping logic we add during `vc dev` was not testable. This PR refactors it to be testable and adds some basic tests.
2023-03-08 22:56:51 +00:00
Steven
c06209901c [tests] Run unit tests concurrently in chunks (#9615)
We can separate each package `test-unit` into a separate job. This will help isolate problems and we can re-run CI for a specific package.
2023-03-07 23:50:21 +00:00
Steven
21a440b832 Publish Stable
- @vercel/build-utils@6.3.4
 - vercel@28.16.15
 - @vercel/client@12.4.4
 - @vercel/fs-detectors@3.8.4
 - @vercel/gatsby-plugin-vercel-builder@1.2.1
 - @vercel/go@2.3.11
 - @vercel/hydrogen@0.0.57
 - @vercel/next@3.6.6
 - @vercel/node@2.9.12
 - @vercel/python@3.1.53
 - @vercel/redwood@1.1.9
 - @vercel/remix@1.6.2
 - @vercel/ruby@1.3.70
 - @vercel/static-build@1.3.16
2023-03-07 13:56:14 -05:00
Steven
48d925f105 Publish Stable
- @vercel/build-utils@6.3.3
 - vercel@28.16.14
 - @vercel/client@12.4.3
 - @vercel/fs-detectors@3.8.3
 - @vercel/gatsby-plugin-vercel-builder@1.2.0
 - @vercel/go@2.3.10
 - @vercel/hydrogen@0.0.56
 - @vercel/next@3.6.5
 - @vercel/node@2.9.11
 - @vercel/python@3.1.52
 - @vercel/redwood@1.1.8
 - @vercel/remix@1.6.1
 - @vercel/ruby@1.3.69
 - @vercel/static-build@1.3.15
2023-03-07 13:17:14 -05:00
Sean Massa
cd09a38c19 [tests] skip recent flakey tests (#9613)
This test has been flakey on mac for a long time.
2023-03-07 17:21:53 +00:00
Chris Barber
803a9363f9 Publish Stable
- vercel@28.16.9
 - @vercel/gatsby-plugin-vercel-analytics@1.0.8
 - @vercel/gatsby-plugin-vercel-builder@1.1.11
 - @vercel/node-bridge@3.1.14
 - @vercel/node@2.9.10
 - @vercel/static-build@1.3.14
2023-02-28 15:32:23 -06:00
Chris Barber
4a0a3b64a2 [node] Added middlewareRawSrc to BOA route config (#9435)
Blocked by https://github.com/vercel/vercel/pull/9564

The build output's route configuration contains a compiled `src` from the list of `matchers` in middleware config, however we need to also save the original inputs so that we can render something meaningful in the web UI. The new prop added to the route is called `middlewareRawSrc` of type `string[]`.

This PR depends on https://github.com/vercel/api/pull/17231.

Linear: https://linear.app/vercel/issue/VCCLI-411/display-uncompressed-edge-middleware-matcher-show-the-list-of-matches
2023-02-28 21:26:26 +00:00
Sean Massa
e0f8bc9820 Publish Stable
- @vercel/build-utils@6.3.2
 - vercel@28.16.8
 - @vercel/client@12.4.2
 - @vercel/edge@0.3.1
 - @vercel/frameworks@1.3.2
 - @vercel/fs-detectors@3.8.2
 - @vercel/gatsby-plugin-vercel-builder@1.1.10
 - @vercel/go@2.3.9
 - @vercel/hydrogen@0.0.55
 - @vercel/next@3.6.2
 - @vercel/node-bridge@3.1.13
 - @vercel/node@2.9.9
 - @vercel/python@3.1.51
 - @vercel/redwood@1.1.7
 - @vercel/remix@1.4.2
 - @vercel/routing-utils@2.1.10
 - @vercel/ruby@1.3.68
 - @vercel/static-build@1.3.13
2023-02-28 10:26:29 -06:00
Sean Massa
40fbc993d7 [tests] extract noisey setup to make test clearer (#9509)
Clarify dev server tests with a small function extraction.
2023-02-27 17:05:27 +00:00
Nathan Rajlich
7845bef826 Publish Stable
- vercel@28.16.7
 - @vercel/edge@0.3.0
 - @vercel/gatsby-plugin-vercel-builder@1.1.9
 - @vercel/next@3.6.1
 - @vercel/node-bridge@3.1.12
 - @vercel/node@2.9.8
 - @vercel/static-build@1.3.12
2023-02-24 04:04:16 -08:00
Steven
34d199bd49 Publish Stable
- @vercel/build-utils@6.3.1
 - vercel@28.16.5
 - @vercel/client@12.4.1
 - @vercel/fs-detectors@3.8.1
 - @vercel/gatsby-plugin-vercel-builder@1.1.8
 - @vercel/go@2.3.8
 - @vercel/hydrogen@0.0.54
 - @vercel/next@3.6.0
 - @vercel/node@2.9.7
 - @vercel/python@3.1.50
 - @vercel/redwood@1.1.6
 - @vercel/remix@1.4.0
 - @vercel/ruby@1.3.67
 - @vercel/static-build@1.3.11
2023-02-22 20:23:55 -05:00
Steven
264437c751 [tests] Increase test timeout from 5s to 10s (#9515)
Fixes this error:

```
@vercel/node:test-unit: FAIL test/dev.test.ts (14.891 s)
@vercel/node:test-unit:   × runs a mjs endpoint (5057 ms)
@vercel/node:test-unit:   × runs a esm typescript endpoint (5122 ms)
@vercel/node:test-unit: 
@vercel/node:test-unit:   ● runs a mjs endpoint
@vercel/node:test-unit: 
@vercel/node:test-unit:     thrown: "Exceeded timeout of 5000 ms for a test.
@vercel/node:test-unit:     Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."
```


https://github.com/vercel/vercel/actions/runs/4247588973/jobs/7385801227#step:9:1039
2023-02-22 18:50:25 -05:00
Gal Schlezinger
e682e9cd7d [node] fix TypeScript + ESM in Windows (#9487)
ESM on Windows versions of Node.js require `--loader PATH` to be a `file://` protocol.
This PR allows `vc dev` to be used with both TypeScript and ESM
2023-02-22 05:54:39 +00:00
Vincent Voyer
3d98d1cdea Publish Stable
- @vercel/build-utils@6.3.0
 - vercel@28.16.0
 - @vercel/client@12.4.0
 - @vercel/fs-detectors@3.7.14
 - @vercel/gatsby-plugin-vercel-builder@1.1.7
 - @vercel/go@2.3.7
 - @vercel/hydrogen@0.0.53
 - @vercel/next@3.4.7
 - @vercel/node@2.9.6
 - @vercel/python@3.1.49
 - @vercel/redwood@1.1.5
 - @vercel/remix@1.3.3
 - @vercel/ruby@1.3.65
 - @vercel/static-build@1.3.9
 - @vercel/static-config@2.0.13
2023-02-16 12:08:50 +01:00