@netlify/edge-bundler 14.6.0 → 14.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -107,8 +107,11 @@ export async function loadESZIP(filename: string): Promise<ESZIP> {
107
107
  return await V1.load(bytes);
108
108
  }
109
109
 
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);
112
115
  }
113
116
 
114
117
  async function write(path: string, content: string) {
@@ -2,7 +2,7 @@ import { type WriteStream } from 'fs';
2
2
  import { type ExecaChildProcess } from 'execa';
3
3
  import { FeatureFlags } from './feature_flags.js';
4
4
  import { Logger } from './logger.js';
5
- export declare const DENO_VERSION_RANGE = "^2.4.2";
5
+ export declare const DENO_VERSION_RANGE = "1.39.0 - 2.2.4";
6
6
  export type OnBeforeDownloadHook = () => void | Promise<void>;
7
7
  export type OnAfterDownloadHook = (error?: Error) => void | Promise<void>;
8
8
  export interface DenoOptions {
@@ -12,7 +12,8 @@ const DENO_VERSION_FILE = 'version.txt';
12
12
  // When updating DENO_VERSION_RANGE, ensure that the deno version
13
13
  // on the netlify/buildbot build image satisfies this range!
14
14
  // https://github.com/netlify/buildbot/blob/f9c03c9dcb091d6570e9d0778381560d469e78ad/build-image/noble/Dockerfile#L410
15
- export const DENO_VERSION_RANGE = '^2.4.2';
15
+ export const DENO_VERSION_RANGE = '1.39.0 - 2.2.4';
16
+ const NEXT_DENO_VERSION_RANGE = '^2.4.2';
16
17
  export class DenoBridge {
17
18
  cacheDirectory;
18
19
  currentDownload;
@@ -31,7 +32,8 @@ export class DenoBridge {
31
32
  this.onAfterDownload = options.onAfterDownload;
32
33
  this.onBeforeDownload = options.onBeforeDownload;
33
34
  this.useGlobal = options.useGlobal ?? true;
34
- this.versionRange = options.versionRange ?? DENO_VERSION_RANGE;
35
+ const useNextDeno = options.featureFlags?.edge_bundler_generate_tarball || options.featureFlags?.edge_bundler_deno_v2;
36
+ this.versionRange = options.versionRange ?? (useNextDeno ? NEXT_DENO_VERSION_RANGE : DENO_VERSION_RANGE);
35
37
  }
36
38
  async downloadBinary() {
37
39
  await this.onBeforeDownload?.();
@@ -98,6 +98,7 @@ export const bundle = async (sourceDirectories, distDirectory, tomlDeclarations
98
98
  basePath,
99
99
  deno,
100
100
  eszipPath,
101
+ featureFlags,
101
102
  importMap,
102
103
  internalFunctions,
103
104
  log: logger,
@@ -127,7 +128,7 @@ export const bundle = async (sourceDirectories, distDirectory, tomlDeclarations
127
128
  }
128
129
  return { functions, manifest };
129
130
  };
130
- const getFunctionConfigs = async ({ basePath, deno, eszipPath, importMap, log, internalFunctions, userFunctions, }) => {
131
+ const getFunctionConfigs = async ({ basePath, deno, eszipPath, featureFlags, importMap, log, internalFunctions, userFunctions, }) => {
131
132
  try {
132
133
  const internalConfigPromises = internalFunctions.map(async (func) => [func.name, await getFunctionConfig({ functionPath: func.path, importMap, deno, log })]);
133
134
  const userConfigPromises = userFunctions.map(async (func) => [func.name, await getFunctionConfig({ functionPath: func.path, importMap, deno, log })]);
@@ -140,7 +141,7 @@ const getFunctionConfigs = async ({ basePath, deno, eszipPath, importMap, log, i
140
141
  };
141
142
  }
142
143
  catch (err) {
143
- if (!(err instanceof Error && err.cause === 'IMPORT_ASSERT') || !eszipPath) {
144
+ if (!(err instanceof Error && err.cause === 'IMPORT_ASSERT') || !eszipPath || !featureFlags?.edge_bundler_deno_v2) {
144
145
  throw err;
145
146
  }
146
147
  // We failed to extract the configuration because there is an import assert
@@ -505,6 +505,9 @@ test('Emits a system log when import assertions are used', async () => {
505
505
  const systemLogger = vi.fn();
506
506
  await bundle([sourceDirectory], distPath, [], {
507
507
  basePath,
508
+ featureFlags: {
509
+ edge_bundler_deno_v2: true,
510
+ },
508
511
  systemLogger,
509
512
  vendorDirectory: vendorDirectory.path,
510
513
  });
@@ -1,10 +1,12 @@
1
1
  declare const defaultFlags: {
2
2
  edge_bundler_generate_tarball: boolean;
3
+ edge_bundler_deno_v2: boolean;
3
4
  };
4
5
  type FeatureFlag = keyof typeof defaultFlags;
5
6
  type FeatureFlags = Partial<Record<FeatureFlag, boolean>>;
6
7
  declare const getFlags: (input?: Record<string, boolean>, flags?: {
7
8
  edge_bundler_generate_tarball: boolean;
9
+ edge_bundler_deno_v2: boolean;
8
10
  }) => FeatureFlags;
9
11
  export { defaultFlags, getFlags };
10
12
  export type { FeatureFlag, FeatureFlags };
@@ -1,5 +1,6 @@
1
1
  const defaultFlags = {
2
2
  edge_bundler_generate_tarball: false,
3
+ edge_bundler_deno_v2: false,
3
4
  };
4
5
  const getFlags = (input = {}, flags = defaultFlags) => Object.entries(flags).reduce((result, [key, defaultValue]) => ({
5
6
  ...result,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/edge-bundler",
3
- "version": "14.6.0",
3
+ "version": "14.7.0",
4
4
  "description": "Intelligently prepare Netlify Edge Functions for deployment",
5
5
  "type": "module",
6
6
  "main": "./dist/node/index.js",
@@ -80,5 +80,5 @@
80
80
  "urlpattern-polyfill": "8.0.2",
81
81
  "uuid": "^11.0.0"
82
82
  },
83
- "gitHead": "3dfa7bd62ac0c8fe4b9b61128b8c2315d1272b4f"
83
+ "gitHead": "ff114da3f2bcb5bea83bb4a3747201192aecfec0"
84
84
  }