@netlify/edge-bundler 1.4.0 → 1.4.1

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.
package/dist/bridge.d.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import { ExecaChildProcess } from 'execa';
2
- declare type LifecycleHook = () => void | Promise<void>;
2
+ declare type OnBeforeDownloadHook = () => void | Promise<void>;
3
+ declare type OnAfterDownloadHook = (error?: Error) => void | Promise<void>;
3
4
  interface DenoOptions {
4
5
  cacheDirectory?: string;
5
6
  debug?: boolean;
6
- onAfterDownload?: LifecycleHook;
7
- onBeforeDownload?: LifecycleHook;
7
+ onAfterDownload?: OnAfterDownloadHook;
8
+ onBeforeDownload?: OnBeforeDownloadHook;
8
9
  useGlobal?: boolean;
9
10
  versionRange?: string;
10
11
  }
@@ -18,8 +19,8 @@ declare class DenoBridge {
18
19
  cacheDirectory: string;
19
20
  currentDownload?: ReturnType<DenoBridge['downloadBinary']>;
20
21
  debug: boolean;
21
- onAfterDownload?: LifecycleHook;
22
- onBeforeDownload?: LifecycleHook;
22
+ onAfterDownload?: OnAfterDownloadHook;
23
+ onBeforeDownload?: OnBeforeDownloadHook;
23
24
  useGlobal: boolean;
24
25
  versionRange: string;
25
26
  constructor(options?: DenoOptions);
@@ -39,4 +40,4 @@ declare class DenoBridge {
39
40
  runInBackground(args: string[], pipeOutput?: boolean, ref?: ProcessRef): Promise<void>;
40
41
  }
41
42
  export { DenoBridge };
42
- export type { LifecycleHook, ProcessRef };
43
+ export type { OnAfterDownloadHook, OnBeforeDownloadHook, ProcessRef };
package/dist/bridge.js CHANGED
@@ -19,9 +19,8 @@ class DenoBridge {
19
19
  this.versionRange = (_d = options.versionRange) !== null && _d !== void 0 ? _d : DENO_VERSION_RANGE;
20
20
  }
21
21
  async downloadBinary() {
22
- if (this.onBeforeDownload) {
23
- this.onBeforeDownload();
24
- }
22
+ var _a, _b, _c;
23
+ (_a = this.onBeforeDownload) === null || _a === void 0 ? void 0 : _a.call(this);
25
24
  await fs.mkdir(this.cacheDirectory, { recursive: true });
26
25
  this.log(`Downloading Deno CLI to ${this.cacheDirectory}...`);
27
26
  const binaryPath = await download(this.cacheDirectory, this.versionRange);
@@ -30,12 +29,12 @@ class DenoBridge {
30
29
  // a malformed semver range. If this does happen, let's throw an error so
31
30
  // that the tests catch it.
32
31
  if (downloadedVersion === undefined) {
33
- throw new Error('Could not read downloaded binary');
32
+ const error = new Error('There was a problem setting up the Edge Functions environment. To try a manual installation, visit https://ntl.fyi/install-deno.');
33
+ (_b = this.onAfterDownload) === null || _b === void 0 ? void 0 : _b.call(this, error);
34
+ throw error;
34
35
  }
35
36
  await this.writeVersionFile(downloadedVersion);
36
- if (this.onAfterDownload) {
37
- this.onAfterDownload();
38
- }
37
+ (_c = this.onAfterDownload) === null || _c === void 0 ? void 0 : _c.call(this);
39
38
  return binaryPath;
40
39
  }
41
40
  static async getBinaryVersion(binaryPath) {
package/dist/bundler.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { LifecycleHook } from './bridge.js';
1
+ import { OnAfterDownloadHook, OnBeforeDownloadHook } from './bridge.js';
2
2
  import type { Declaration } from './declaration.js';
3
3
  import { EdgeFunction } from './edge_function.js';
4
4
  import { FeatureFlags } from './feature_flags.js';
@@ -9,8 +9,8 @@ interface BundleOptions {
9
9
  distImportMapPath?: string;
10
10
  featureFlags?: FeatureFlags;
11
11
  importMaps?: ImportMapFile[];
12
- onAfterDownload?: LifecycleHook;
13
- onBeforeDownload?: LifecycleHook;
12
+ onAfterDownload?: OnAfterDownloadHook;
13
+ onBeforeDownload?: OnBeforeDownloadHook;
14
14
  }
15
15
  declare const bundle: (sourceDirectories: string[], distDirectory: string, declarations?: Declaration[], { cacheDirectory, debug, distImportMapPath, featureFlags: inputFeatureFlags, importMaps, onAfterDownload, onBeforeDownload, }?: BundleOptions) => Promise<{
16
16
  functions: EdgeFunction[];
@@ -1,4 +1,4 @@
1
- import { LifecycleHook } from '../bridge.js';
1
+ import { OnAfterDownloadHook, OnBeforeDownloadHook } from '../bridge.js';
2
2
  import type { EdgeFunction } from '../edge_function.js';
3
3
  import { ImportMapFile } from '../import_map.js';
4
4
  declare type FormatFunction = (name: string) => string;
@@ -13,8 +13,8 @@ interface ServeOptions {
13
13
  distImportMapPath?: string;
14
14
  inspectSettings?: InspectSettings;
15
15
  importMaps?: ImportMapFile[];
16
- onAfterDownload?: LifecycleHook;
17
- onBeforeDownload?: LifecycleHook;
16
+ onAfterDownload?: OnAfterDownloadHook;
17
+ onBeforeDownload?: OnBeforeDownloadHook;
18
18
  formatExportTypeError?: FormatFunction;
19
19
  formatImportError?: FormatFunction;
20
20
  port: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/edge-bundler",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "Intelligently prepare Netlify Edge Functions for deployment",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",