Skip to content

Commit 297177f

Browse files
mrstorkJakeChampionpieh
authored
feat: update deno version range to include v2 (#6118)
* feat: update deno version range to include v2 * fix: use --allow-import flag * chore: sort command line arguments * test: run tests with --no-check to get around isTooManyTries typecheck * test: update snapshot * fix: reintroduce typechecking and resolve isTooManyTries type error * fix: remove allow-import flag * chore: update deno range to 2.2.4 * chore: update deno range to 2.2.5 * fix: re-add --allow-import flag * fix: go back to version 2.2.4 as the max allowed because the deno gh action can not locate 2.2.5 * chore: fix snapshot * fix: add --allow-import only when using deno 2 or greater * chore: fix snapshot * chore: maybe we need to remove the empty flag * chore: fix snapshot * chore: remove ansi escape sequences from the snapshot output * chore: fix snapshots * test: update monitor snapshots * chore: remove deno.lock file * refactor: filter the modules before checking the functions * fix: use file url instead of file path to generate module graph --------- Co-authored-by: jake champion <[email protected]> Co-authored-by: Michal Piechowiak <[email protected]>
1 parent 1b9f2f4 commit 297177f

File tree

14 files changed

+47
-84
lines changed

14 files changed

+47
-84
lines changed

.github/workflows/workflow.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ jobs:
5050
os: [ubuntu-24.04, macos-14, windows-2022]
5151
node-version: ['22']
5252
# Must include the minimum deno version from the `DENO_VERSION_RANGE` constant in `node/bridge.ts`.
53-
deno-version: ['v1.39.0', 'v1.46.3']
53+
deno-version: ['v1.39.0', 'v2.2.4']
5454
include:
5555
- os: ubuntu-24.04
5656
# Earliest supported version
5757
node-version: '14.16.0'
58-
deno-version: 'v1.46.3'
58+
deno-version: 'v2.2.4'
5959
fail-fast: false
6060
steps:
6161
# Sets an output parameter if this is a release PR
@@ -159,7 +159,7 @@ jobs:
159159
- name: Setup Deno
160160
uses: denoland/setup-deno@v1
161161
with:
162-
deno-version: v1.46.3
162+
deno-version: v2.2.4
163163
if: ${{ !steps.release-check.outputs.IS_RELEASE }}
164164
- name: Node.js ${{ matrix.node-version }}
165165
uses: actions/setup-node@v4

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/build/tests/edge_functions/snapshots/tests.js.md

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -511,59 +511,6 @@ Generated by [AVA](https://avajs.dev).
511511
publish: packages/build/tests/edge_functions/fixtures/functions_invalid␊
512512
publishOrigin: default`
513513

514-
## handles failure when validating Edge Functions
515-
516-
> Snapshot 1
517-
518-
`␊
519-
Netlify Build ␊
520-
────────────────────────────────────────────────────────────────␊
521-
522-
> Version␊
523-
@netlify/build 1.0.0␊
524-
525-
> Flags␊
526-
debug: false␊
527-
528-
> Current directory␊
529-
packages/build/tests/edge_functions/fixtures/functions_validation_failed␊
530-
531-
> Config file␊
532-
No config file was defined: using default values.␊
533-
534-
> Context␊
535-
production␊
536-
537-
1. Edge Functions bundling ␊
538-
────────────────────────────────────────────────────────────────␊
539-
540-
Packaging Edge Functions from netlify/edge-functions directory:␊
541-
- functions-1␊
542-
543-
Bundling of edge function failed ␊
544-
────────────────────────────────────────────────────────────────␊
545-
546-
Error message␊
547-
Validation of Edge Functions manifest failed␊
548-
FORMAT pattern needs to be a regex that starts with ^ followed by / and ends with $ without any additional slashes before and afterwards␊
549-
550-
13 | {␊
551-
14 | "function": "functions-1",␊
552-
> 15 | "pattern": "^hello//?$"␊
553-
| ^^^^^^^^^^^^ 👈🏽 format pattern needs to be a regex that starts with ^ followed by / and ends with $ without any additional slashes before and afterwards␊
554-
16 | }␊
555-
17 | ],␊
556-
18 | "post_cache_routes": [],␊
557-
558-
Error location␊
559-
While bundling edge function␊
560-
561-
Resolved config␊
562-
build:␊
563-
edge_functions: packages/build/tests/edge_functions/fixtures/functions_validation_failed/netlify/edge-functions␊
564-
publish: packages/build/tests/edge_functions/fixtures/functions_validation_failed␊
565-
publishOrigin: default`
566-
567514
## bundles Edge Functions via runCoreSteps function
568515

569516
> Snapshot 1
-271 Bytes
Binary file not shown.

packages/build/tests/monitor/snapshots/tests.js.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1606,7 +1606,7 @@ Generated by [AVA](https://avajs.dev).
16061606
Error monitoring payload:␊
16071607
{␊
16081608
"errorClass": "functionsBundling",␊
1609-
"errorMessage": "Command failed with exit code 1: deno run --allow-all --no-config --import-map=packages/edge-bundler/deno/vendor/import_map.json --quiet packages/edge-bundler/deno/bundle.ts {/"basePath/":/"packages/build/tests/monitor/fixtures/edge_function_error",/"destPath/":/"packages/build/tests/monitor/fixtures/edge_function_error/.netlify/edge-functions-dist/HEXADECIMAL_ID.eszip",/"externals/":[],/"functions/":[{/"name/":/"trouble/",/"path/":/"packages/build/tests/monitor/fixtures/edge_function_error/netlify/edge-functions/trouble.ts"}],/"importMapData/":/"{//"imports//":{//"builtins//"://"node:builtins//",//"@netlify/edge-functions//"://"https://edge.netlify.com/v1.0.0/index.ts//",//"netlify:edge//"://"https://edge.netlify.com/v1.0.0/index.ts?v=legacy//"},//"scopes//":{}}/",/"vendorDirectory/":/"/external/path"}/nerror: Uncaught (in promise) Error: Error: Could not find file: packages/build/tests/monitor/fixtures/edge_function_error/netlify/edge-functions/file.ts/n const ret = new Error(getStringFromWasm0(arg0, arg1));/n ^/n at __wbg_new_HEXADECIMAL_ID (packages/edge-bundler/deno/vendor/deno.land/x/[email protected]/eszip_wasm.generated.js:80:80)/n at <anonymous> (packages/edge-bundler/deno/vendor/deno.land/x/[email protected]/eszip_wasm_bg.wasm:1:80)/n at <anonymous> (packages/edge-bundler/deno/vendor/deno.land/x/[email protected]/eszip_wasm_bg.wasm:1:80)/n at <anonymous> (packages/edge-bundler/deno/vendor/deno.land/x/[email protected]/eszip_wasm_bg.wasm:1:80)/n at __wbg_adapter_40 (packages/edge-bundler/deno/vendor/deno.land/x/[email protected]/eszip_wasm.generated.js:80:8)/n at real (packages/edge-bundler/deno/vendor/deno.land/x/[email protected]/eszip_wasm.generated.js:80:80)/n at eventLoopTick (ext:core/01_core.js:80:7)",␊
1609+
"errorMessage": "Command failed with exit code 1: deno run --allow-all --no-config --import-map=packages/edge-bundler/deno/vendor/import_map.json --quiet packages/edge-bundler/deno/bundle.ts {/"basePath/":/"packages/build/tests/monitor/fixtures/edge_function_error",/"destPath/":/"packages/build/tests/monitor/fixtures/edge_function_error/.netlify/edge-functions-dist/HEXADECIMAL_ID.eszip",/"externals/":[],/"functions/":[{/"name/":/"trouble/",/"path/":/"packages/build/tests/monitor/fixtures/edge_function_error/netlify/edge-functions/trouble.ts"}],/"importMapData/":/"{//"imports//":{//"builtins//"://"node:builtins//",//"@netlify/edge-functions//"://"https://edge.netlify.com/v1.0.0/index.ts//",//"netlify:edge//"://"https://edge.netlify.com/v1.0.0/index.ts?v=legacy//"},//"scopes//":{}}/",/"vendorDirectory/":/"/external/path"}/nerror: Uncaught (in promise) Error: Error: Could not find file: packages/build/tests/monitor/fixtures/edge_function_error/netlify/edge-functions/file.ts/n const ret = new Error(getStringFromWasm0(arg0, arg1));/n ^/n at __wbg_new_HEXADECIMAL_ID (packages/edge-bundler/deno/vendor/deno.land/x/[email protected]/eszip_wasm.generated.js:80:80)/n at <anonymous> (wasm://wasm/HEXADECIMAL_ID:1:80)/n at <anonymous> (wasm://wasm/HEXADECIMAL_ID:1:80)/n at <anonymous> (wasm://wasm/HEXADECIMAL_ID:1:80)/n at __wbg_adapter_40 (packages/edge-bundler/deno/vendor/deno.land/x/[email protected]/eszip_wasm.generated.js:80:8)/n at real (packages/edge-bundler/deno/vendor/deno.land/x/[email protected]/eszip_wasm.generated.js:80:80)/n at eventLoopTick (ext:core/01_core.js:80:7)",␊
16101610
"context": "Bundling of edge function failed",␊
16111611
"groupingHash": "Bundling of edge function failed/nCommand failed with exit code 0: deno run --allow-all --no-config /external/path --quiet /external/path {/"/":/"/",/"/":/"/",/"/":[],/"/":[{/"/":/"/",/"/":/"/"}],/"/":/"/"/external/path"/"/external/path"/"/external/path"/"/external/path"/"/external/path"/"/external/path"/"/external/path"/"/external/path"/",/"/":/"/"}/nerror: Uncaught (in promise) Error: Error: Could not find file: /external/path const ret = new Error(getStringFromWasm0(arg0, arg0));/n ^/n at __wbg_new_hex /external/path at <anonymous> /external/path at <anonymous> /external/path at <anonymous> /external/path at __wbg_adapter_0 /external/path at real /external/path at eventLoopTick /external/path",␊
16121612
"severity": "info",␊
-1 Bytes
Binary file not shown.

packages/edge-bundler/deno/lib/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const loadWithRetry = (specifier: string, delay = 1000, maxTry = 3) => {
4242
maxTry,
4343
});
4444
} catch (error) {
45-
if (isTooManyTries(error)) {
45+
if (isTooManyTries(error as Error)) {
4646
console.error(`Loading ${specifier} failed after ${maxTry} tries.`);
4747
}
4848
throw error;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`Adds a custom error property to user errors during bundling 1`] = `
4+
"error: Uncaught (in promise) Error: The module's source code could not be parsed: Unexpected eof at file:///root/functions/func1.ts:1:27
5+
6+
export default async () =>
7+
~
8+
const ret = new Error(getStringFromWasm0(arg0, arg1));
9+
^
10+
at <anonymous> (file://build/packages/edge-bundler/deno/vendor/deno.land/x/[email protected]/eszip_wasm.generated.js:443:19)"
11+
`;

packages/edge-bundler/node/bridge.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const DENO_VERSION_FILE = 'version.txt'
1616
// When updating DENO_VERSION_RANGE, ensure that the deno version
1717
// on the netlify/buildbot build image satisfies this range!
1818
// https://github.com/netlify/buildbot/blob/f9c03c9dcb091d6570e9d0778381560d469e78ad/build-image/noble/Dockerfile#L410
19-
const DENO_VERSION_RANGE = '1.39.0 - 1.46.3'
19+
const DENO_VERSION_RANGE = '1.39.0 - 2.2.4'
2020

2121
type OnBeforeDownloadHook = () => void | Promise<void>
2222
type OnAfterDownloadHook = (error?: Error) => void | Promise<void>
@@ -99,7 +99,7 @@ class DenoBridge {
9999
return binaryPath
100100
}
101101

102-
private async getBinaryVersion(binaryPath: string) {
102+
async getBinaryVersion(binaryPath: string) {
103103
try {
104104
const { stdout } = await execa(binaryPath, ['--version'])
105105
const version = stdout.match(/^deno ([\d.]+)/)
@@ -202,19 +202,23 @@ class DenoBridge {
202202
await fs.mkdir(this.cacheDirectory, { recursive: true })
203203
}
204204

205-
async getBinaryPath() {
205+
async getBinaryPath(options?: { silent?: boolean }) {
206206
const globalPath = await this.getGlobalBinary()
207207

208208
if (globalPath !== undefined) {
209-
this.logger.system('Using global installation of Deno CLI')
209+
if (!options?.silent) {
210+
this.logger.system('Using global installation of Deno CLI')
211+
}
210212

211213
return { global: true, path: globalPath }
212214
}
213215

214216
const cachedPath = await this.getCachedBinary()
215217

216218
if (cachedPath !== undefined) {
217-
this.logger.system('Using cached Deno CLI from', cachedPath)
219+
if (!options?.silent) {
220+
this.logger.system('Using cached Deno CLI from', cachedPath)
221+
}
218222

219223
return { global: false, path: cachedPath }
220224
}

packages/edge-bundler/node/bundler.test.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,13 @@ test('Adds a custom error property to user errors during bundling', async () =>
104104
await bundle([sourceDirectory], distPath, declarations, { basePath })
105105
} catch (error) {
106106
expect(error).toBeInstanceOf(BundleError)
107-
const [messageBeforeStack] = (error as BundleError).message.split('at <anonymous> (file://')
108-
expect(messageBeforeStack).toMatchInlineSnapshot(`
109-
"error: Uncaught (in promise) Error: The module's source code could not be parsed: Unexpected eof at file:///root/functions/func1.ts:1:27
110-
111-
export default async () =>
112-
~
113-
const ret = new Error(getStringFromWasm0(arg0, arg1));
114-
^
115-
"
116-
`)
107+
const messageBeforeStack = (error as BundleError).message
108+
expect(
109+
messageBeforeStack
110+
.replace(/file:\/\/\/(.*?\/)(build\/packages\/edge-bundler\/deno\/vendor\/deno\.land\/x\/eszip.*)/, 'file://$2')
111+
// eslint-disable-next-line no-control-regex
112+
.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, ''),
113+
).toMatchSnapshot()
117114
expect((error as BundleError).customErrorInfo).toEqual({
118115
location: {
119116
format: 'eszip',

0 commit comments

Comments
 (0)