From 789e62bd033497a863a5bc2449eaf7cb26ad5462 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20Bou=C3=A7as?= Date: Tue, 21 Oct 2025 17:49:19 +0100 Subject: [PATCH 1/3] feat: add feature flag for Deno 2.x update --- .../deno/vendor/deno.land/x/eszip@v0.55.2/eszip.ts | 7 +++++-- packages/edge-bundler/node/bridge.ts | 10 ++++++++-- packages/edge-bundler/node/bundler.ts | 5 ++++- packages/edge-bundler/node/feature_flags.ts | 1 + 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/packages/edge-bundler/deno/vendor/deno.land/x/eszip@v0.55.2/eszip.ts b/packages/edge-bundler/deno/vendor/deno.land/x/eszip@v0.55.2/eszip.ts index 9d8c7b548d..3ed2bb0286 100644 --- a/packages/edge-bundler/deno/vendor/deno.land/x/eszip@v0.55.2/eszip.ts +++ b/packages/edge-bundler/deno/vendor/deno.land/x/eszip@v0.55.2/eszip.ts @@ -107,8 +107,11 @@ export async function loadESZIP(filename: string): Promise { return await V1.load(bytes); } -function url2path(url: string) { - return join(...(new URL(url).pathname.split("/").filter(Boolean))); +function url2path(urlString: string) { + const url = new URL(urlString); + const tail = url.pathname.split("/").filter(Boolean); + const relativePath = tail.length === 0 ? [".root"] : tail; + return join(url.hostname, ...relativePath); } async function write(path: string, content: string) { diff --git a/packages/edge-bundler/node/bridge.ts b/packages/edge-bundler/node/bridge.ts index e4b229500f..3d252f4efb 100644 --- a/packages/edge-bundler/node/bridge.ts +++ b/packages/edge-bundler/node/bridge.ts @@ -17,7 +17,9 @@ const DENO_VERSION_FILE = 'version.txt' // When updating DENO_VERSION_RANGE, ensure that the deno version // on the netlify/buildbot build image satisfies this range! // https://github.com/netlify/buildbot/blob/f9c03c9dcb091d6570e9d0778381560d469e78ad/build-image/noble/Dockerfile#L410 -export const DENO_VERSION_RANGE = '^2.4.2' +export const DENO_VERSION_RANGE = '1.39.0 - 2.2.4' + +const NEXT_DENO_VERSION_RANGE = '^2.4.2' export type OnBeforeDownloadHook = () => void | Promise export type OnAfterDownloadHook = (error?: Error) => void | Promise @@ -67,7 +69,11 @@ export class DenoBridge { this.onAfterDownload = options.onAfterDownload this.onBeforeDownload = options.onBeforeDownload this.useGlobal = options.useGlobal ?? true - this.versionRange = options.versionRange ?? DENO_VERSION_RANGE + + const useNextDeno = + options.featureFlags?.edge_bundler_generate_tarball || options.featureFlags?.edge_bundler_deno_v2 + + this.versionRange = options.versionRange ?? (useNextDeno ? NEXT_DENO_VERSION_RANGE : DENO_VERSION_RANGE) } private async downloadBinary() { diff --git a/packages/edge-bundler/node/bundler.ts b/packages/edge-bundler/node/bundler.ts index 827487575e..d9fbf5eea3 100644 --- a/packages/edge-bundler/node/bundler.ts +++ b/packages/edge-bundler/node/bundler.ts @@ -164,6 +164,7 @@ export const bundle = async ( basePath, deno, eszipPath, + featureFlags, importMap, internalFunctions, log: logger, @@ -210,6 +211,7 @@ interface GetFunctionConfigsOptions { basePath: string deno: DenoBridge eszipPath?: string + featureFlags?: FeatureFlags importMap: ImportMap internalFunctions: EdgeFunction[] log: Logger @@ -220,6 +222,7 @@ const getFunctionConfigs = async ({ basePath, deno, eszipPath, + featureFlags, importMap, log, internalFunctions, @@ -242,7 +245,7 @@ const getFunctionConfigs = async ({ userFunctions: userFunctionsWithConfig, } } catch (err) { - if (!(err instanceof Error && err.cause === 'IMPORT_ASSERT') || !eszipPath) { + if (!(err instanceof Error && err.cause === 'IMPORT_ASSERT') || !eszipPath || !featureFlags?.edge_bundler_deno_v2) { throw err } diff --git a/packages/edge-bundler/node/feature_flags.ts b/packages/edge-bundler/node/feature_flags.ts index eb27ce1528..b15d062ace 100644 --- a/packages/edge-bundler/node/feature_flags.ts +++ b/packages/edge-bundler/node/feature_flags.ts @@ -1,5 +1,6 @@ const defaultFlags = { edge_bundler_generate_tarball: false, + edge_bundler_deno_v2: false, } type FeatureFlag = keyof typeof defaultFlags From 68559f97c6a55cfce9063e1f77ad8245833ca427 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20Bou=C3=A7as?= Date: Tue, 21 Oct 2025 17:55:17 +0100 Subject: [PATCH 2/3] chore: add flag to test --- packages/edge-bundler/node/bundler.test.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/edge-bundler/node/bundler.test.ts b/packages/edge-bundler/node/bundler.test.ts index 1947aef704..12b3be4eb9 100644 --- a/packages/edge-bundler/node/bundler.test.ts +++ b/packages/edge-bundler/node/bundler.test.ts @@ -634,6 +634,9 @@ test('Emits a system log when import assertions are used', async () => { await bundle([sourceDirectory], distPath, [], { basePath, + featureFlags: { + edge_bundler_deno_v2: true, + }, systemLogger, vendorDirectory: vendorDirectory.path, }) From 7bcd12a63a86f6ddab5f8b3fc5c276b8d7c0b42e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20Bou=C3=A7as?= Date: Tue, 21 Oct 2025 18:07:09 +0100 Subject: [PATCH 3/3] chore: revert CI changes --- .github/workflows/workflow.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index bdeed6f9ba..b10378994e 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -54,12 +54,14 @@ jobs: os: [ubuntu-24.04, macos-14, windows-2025] node-version: ['22'] # Must include the minimum deno version from the `DENO_VERSION_RANGE` constant in `node/bridge.ts`. - deno-version: ['v2.4.2'] + # We're adding v2.4.2 here because it's needed for the upcoming nimble release, so we can test + # those workflows ahead of time before we can update the base version across the board. + deno-version: ['v1.39.0', 'v2.2.4', 'v2.4.2'] include: - os: ubuntu-24.04 # Earliest supported version node-version: '18.14.0' - deno-version: 'v2.4.2' + deno-version: 'v2.2.4' fail-fast: false steps: # Sets an output parameter if this is a release PR @@ -157,7 +159,7 @@ jobs: - name: Setup Deno uses: denoland/setup-deno@v1 with: - deno-version: v2.4.2 + deno-version: v2.2.4 if: ${{ !steps.release-check.outputs.IS_RELEASE }} - name: Node.js ${{ matrix.node-version }} uses: actions/setup-node@v5