Skip to content

Commit 99236bd

Browse files
feat: add feature flag for Deno 2.x update (#6720)
1 parent a200bea commit 99236bd

File tree

6 files changed

+26
-8
lines changed

6 files changed

+26
-8
lines changed

.github/workflows/workflow.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,14 @@ jobs:
5454
os: [ubuntu-24.04, macos-14, windows-2025]
5555
node-version: ['22']
5656
# Must include the minimum deno version from the `DENO_VERSION_RANGE` constant in `node/bridge.ts`.
57-
deno-version: ['v2.4.2']
57+
# We're adding v2.4.2 here because it's needed for the upcoming nimble release, so we can test
58+
# those workflows ahead of time before we can update the base version across the board.
59+
deno-version: ['v1.39.0', 'v2.2.4', 'v2.4.2']
5860
include:
5961
- os: ubuntu-24.04
6062
# Earliest supported version
6163
node-version: '18.14.0'
62-
deno-version: 'v2.4.2'
64+
deno-version: 'v2.2.4'
6365
fail-fast: false
6466
steps:
6567
# Sets an output parameter if this is a release PR
@@ -157,7 +159,7 @@ jobs:
157159
- name: Setup Deno
158160
uses: denoland/setup-deno@v1
159161
with:
160-
deno-version: v2.4.2
162+
deno-version: v2.2.4
161163
if: ${{ !steps.release-check.outputs.IS_RELEASE }}
162164
- name: Node.js ${{ matrix.node-version }}
163165
uses: actions/setup-node@v5

packages/edge-bundler/deno/vendor/deno.land/x/[email protected]/eszip.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,11 @@ export async function loadESZIP(filename: string): Promise<ESZIP> {
107107
return await V1.load(bytes);
108108
}
109109

110-
function url2path(url: string) {
111-
return join(...(new URL(url).pathname.split("/").filter(Boolean)));
110+
function url2path(urlString: string) {
111+
const url = new URL(urlString);
112+
const tail = url.pathname.split("/").filter(Boolean);
113+
const relativePath = tail.length === 0 ? [".root"] : tail;
114+
return join(url.hostname, ...relativePath);
112115
}
113116

114117
async function write(path: string, content: string) {

packages/edge-bundler/node/bridge.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ const DENO_VERSION_FILE = 'version.txt'
1717
// When updating DENO_VERSION_RANGE, ensure that the deno version
1818
// on the netlify/buildbot build image satisfies this range!
1919
// https://github.com/netlify/buildbot/blob/f9c03c9dcb091d6570e9d0778381560d469e78ad/build-image/noble/Dockerfile#L410
20-
export const DENO_VERSION_RANGE = '^2.4.2'
20+
export const DENO_VERSION_RANGE = '1.39.0 - 2.2.4'
21+
22+
const NEXT_DENO_VERSION_RANGE = '^2.4.2'
2123

2224
export type OnBeforeDownloadHook = () => void | Promise<void>
2325
export type OnAfterDownloadHook = (error?: Error) => void | Promise<void>
@@ -67,7 +69,11 @@ export class DenoBridge {
6769
this.onAfterDownload = options.onAfterDownload
6870
this.onBeforeDownload = options.onBeforeDownload
6971
this.useGlobal = options.useGlobal ?? true
70-
this.versionRange = options.versionRange ?? DENO_VERSION_RANGE
72+
73+
const useNextDeno =
74+
options.featureFlags?.edge_bundler_generate_tarball || options.featureFlags?.edge_bundler_deno_v2
75+
76+
this.versionRange = options.versionRange ?? (useNextDeno ? NEXT_DENO_VERSION_RANGE : DENO_VERSION_RANGE)
7177
}
7278

7379
private async downloadBinary() {

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,9 @@ test('Emits a system log when import assertions are used', async () => {
634634

635635
await bundle([sourceDirectory], distPath, [], {
636636
basePath,
637+
featureFlags: {
638+
edge_bundler_deno_v2: true,
639+
},
637640
systemLogger,
638641
vendorDirectory: vendorDirectory.path,
639642
})

packages/edge-bundler/node/bundler.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ export const bundle = async (
164164
basePath,
165165
deno,
166166
eszipPath,
167+
featureFlags,
167168
importMap,
168169
internalFunctions,
169170
log: logger,
@@ -210,6 +211,7 @@ interface GetFunctionConfigsOptions {
210211
basePath: string
211212
deno: DenoBridge
212213
eszipPath?: string
214+
featureFlags?: FeatureFlags
213215
importMap: ImportMap
214216
internalFunctions: EdgeFunction[]
215217
log: Logger
@@ -220,6 +222,7 @@ const getFunctionConfigs = async ({
220222
basePath,
221223
deno,
222224
eszipPath,
225+
featureFlags,
223226
importMap,
224227
log,
225228
internalFunctions,
@@ -242,7 +245,7 @@ const getFunctionConfigs = async ({
242245
userFunctions: userFunctionsWithConfig,
243246
}
244247
} catch (err) {
245-
if (!(err instanceof Error && err.cause === 'IMPORT_ASSERT') || !eszipPath) {
248+
if (!(err instanceof Error && err.cause === 'IMPORT_ASSERT') || !eszipPath || !featureFlags?.edge_bundler_deno_v2) {
246249
throw err
247250
}
248251

packages/edge-bundler/node/feature_flags.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const defaultFlags = {
22
edge_bundler_generate_tarball: false,
3+
edge_bundler_deno_v2: false,
34
}
45

56
type FeatureFlag = keyof typeof defaultFlags

0 commit comments

Comments
 (0)