@netlify/edge-bundler 1.2.1 → 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/deno/bundle.ts +1 -1
- package/dist/bridge.d.ts +7 -6
- package/dist/bridge.js +6 -7
- package/dist/bundler.d.ts +6 -4
- package/dist/bundler.js +36 -22
- package/dist/formats/javascript.js +1 -1
- package/dist/manifest.d.ts +1 -1
- package/dist/manifest.js +3 -2
- package/dist/server/server.d.ts +3 -3
- package/dist/server/util.d.ts +1 -1
- package/package.json +1 -1
package/deno/bundle.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { writeStage2 } from 'https://
|
|
1
|
+
import { writeStage2 } from 'https://62ac9c589c16c50008b6ef55--edge-bootstrap.netlify.app/bundler/mod.ts'
|
|
2
2
|
|
|
3
3
|
const [payload] = Deno.args
|
|
4
4
|
const { basePath, destPath, functions } = JSON.parse(payload)
|
package/dist/bridge.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { ExecaChildProcess } from 'execa';
|
|
2
|
-
declare type
|
|
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?:
|
|
7
|
-
onBeforeDownload?:
|
|
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?:
|
|
22
|
-
onBeforeDownload?:
|
|
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 {
|
|
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
|
-
|
|
23
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OnAfterDownloadHook, OnBeforeDownloadHook } from './bridge.js';
|
|
2
2
|
import type { Declaration } from './declaration.js';
|
|
3
|
+
import { EdgeFunction } from './edge_function.js';
|
|
3
4
|
import { FeatureFlags } from './feature_flags.js';
|
|
4
5
|
import { ImportMapFile } from './import_map.js';
|
|
5
6
|
interface BundleOptions {
|
|
@@ -8,10 +9,11 @@ interface BundleOptions {
|
|
|
8
9
|
distImportMapPath?: string;
|
|
9
10
|
featureFlags?: FeatureFlags;
|
|
10
11
|
importMaps?: ImportMapFile[];
|
|
11
|
-
onAfterDownload?:
|
|
12
|
-
onBeforeDownload?:
|
|
12
|
+
onAfterDownload?: OnAfterDownloadHook;
|
|
13
|
+
onBeforeDownload?: OnBeforeDownloadHook;
|
|
13
14
|
}
|
|
14
15
|
declare const bundle: (sourceDirectories: string[], distDirectory: string, declarations?: Declaration[], { cacheDirectory, debug, distImportMapPath, featureFlags: inputFeatureFlags, importMaps, onAfterDownload, onBeforeDownload, }?: BundleOptions) => Promise<{
|
|
15
|
-
functions:
|
|
16
|
+
functions: EdgeFunction[];
|
|
17
|
+
manifest: import("./manifest.js").Manifest;
|
|
16
18
|
}>;
|
|
17
19
|
export { bundle };
|
package/dist/bundler.js
CHANGED
|
@@ -9,6 +9,30 @@ import { bundle as bundleESZIP } from './formats/eszip.js';
|
|
|
9
9
|
import { bundle as bundleJS } from './formats/javascript.js';
|
|
10
10
|
import { ImportMap } from './import_map.js';
|
|
11
11
|
import { writeManifest } from './manifest.js';
|
|
12
|
+
const createBundleOps = ({ basePath, buildID, debug, deno, distDirectory, functions, importMap, featureFlags, }) => {
|
|
13
|
+
const bundleOps = [];
|
|
14
|
+
if (featureFlags.edge_functions_produce_eszip) {
|
|
15
|
+
bundleOps.push(bundleESZIP({
|
|
16
|
+
basePath,
|
|
17
|
+
buildID,
|
|
18
|
+
debug,
|
|
19
|
+
deno,
|
|
20
|
+
distDirectory,
|
|
21
|
+
functions,
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
bundleOps.push(bundleJS({
|
|
26
|
+
buildID,
|
|
27
|
+
debug,
|
|
28
|
+
deno,
|
|
29
|
+
distDirectory,
|
|
30
|
+
functions,
|
|
31
|
+
importMap,
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
return bundleOps;
|
|
35
|
+
};
|
|
12
36
|
const bundle = async (sourceDirectories, distDirectory, declarations = [], { cacheDirectory, debug, distImportMapPath, featureFlags: inputFeatureFlags, importMaps, onAfterDownload, onBeforeDownload, } = {}) => {
|
|
13
37
|
const featureFlags = getFlags(inputFeatureFlags);
|
|
14
38
|
const deno = new DenoBridge({
|
|
@@ -26,32 +50,22 @@ const bundle = async (sourceDirectories, distDirectory, declarations = [], { cac
|
|
|
26
50
|
// if any.
|
|
27
51
|
const importMap = new ImportMap(importMaps);
|
|
28
52
|
const functions = await findFunctions(sourceDirectories);
|
|
29
|
-
const bundleOps =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (featureFlags.edge_functions_produce_eszip) {
|
|
40
|
-
bundleOps.push(bundleESZIP({
|
|
41
|
-
basePath,
|
|
42
|
-
buildID,
|
|
43
|
-
debug,
|
|
44
|
-
deno,
|
|
45
|
-
distDirectory,
|
|
46
|
-
functions,
|
|
47
|
-
}));
|
|
48
|
-
}
|
|
53
|
+
const bundleOps = createBundleOps({
|
|
54
|
+
basePath,
|
|
55
|
+
buildID,
|
|
56
|
+
debug,
|
|
57
|
+
deno,
|
|
58
|
+
distDirectory,
|
|
59
|
+
functions,
|
|
60
|
+
importMap,
|
|
61
|
+
featureFlags,
|
|
62
|
+
});
|
|
49
63
|
const bundles = await Promise.all(bundleOps);
|
|
50
64
|
// The final file name of the bundles contains a SHA256 hash of the contents,
|
|
51
65
|
// which we can only compute now that the files have been generated. So let's
|
|
52
66
|
// rename the bundles to their permanent names.
|
|
53
67
|
await createFinalBundles(bundles, distDirectory, buildID);
|
|
54
|
-
await writeManifest({
|
|
68
|
+
const manifest = await writeManifest({
|
|
55
69
|
bundles,
|
|
56
70
|
declarations,
|
|
57
71
|
distDirectory,
|
|
@@ -60,7 +74,7 @@ const bundle = async (sourceDirectories, distDirectory, declarations = [], { cac
|
|
|
60
74
|
if (distImportMapPath) {
|
|
61
75
|
await importMap.writeToFile(distImportMapPath);
|
|
62
76
|
}
|
|
63
|
-
return { functions };
|
|
77
|
+
return { functions, manifest };
|
|
64
78
|
};
|
|
65
79
|
const createFinalBundles = async (bundles, distDirectory, buildID) => {
|
|
66
80
|
const renamingOps = bundles.map(async ({ extension, hash }) => {
|
|
@@ -5,7 +5,7 @@ import { pathToFileURL } from 'url';
|
|
|
5
5
|
import del from 'del';
|
|
6
6
|
import { wrapBundleError } from '../bundle_error.js';
|
|
7
7
|
import { getFileHash } from '../utils/sha256.js';
|
|
8
|
-
const BOOTSTRAP_LATEST = 'https://
|
|
8
|
+
const BOOTSTRAP_LATEST = 'https://62ac9c589c16c50008b6ef55--edge-bootstrap.netlify.app/bootstrap/index-combined.ts';
|
|
9
9
|
const bundle = async (options) => {
|
|
10
10
|
try {
|
|
11
11
|
return await bundleJS(options);
|
package/dist/manifest.d.ts
CHANGED
|
@@ -24,5 +24,5 @@ interface WriteManifestOptions {
|
|
|
24
24
|
distDirectory: string;
|
|
25
25
|
functions: EdgeFunction[];
|
|
26
26
|
}
|
|
27
|
-
declare const writeManifest: ({ bundles, declarations, distDirectory, functions }: WriteManifestOptions) => Promise<
|
|
27
|
+
declare const writeManifest: ({ bundles, declarations, distDirectory, functions }: WriteManifestOptions) => Promise<Manifest>;
|
|
28
28
|
export { generateManifest, Manifest, writeManifest };
|
package/dist/manifest.js
CHANGED
|
@@ -40,9 +40,10 @@ const getRegularExpression = (declaration) => {
|
|
|
40
40
|
const normalizedSource = `^${regularExpression.source}\\/?$`;
|
|
41
41
|
return new RegExp(normalizedSource);
|
|
42
42
|
};
|
|
43
|
-
const writeManifest = ({ bundles, declarations = [], distDirectory, functions }) => {
|
|
43
|
+
const writeManifest = async ({ bundles, declarations = [], distDirectory, functions }) => {
|
|
44
44
|
const manifest = generateManifest({ bundles, declarations, functions });
|
|
45
45
|
const manifestPath = join(distDirectory, 'manifest.json');
|
|
46
|
-
|
|
46
|
+
await fs.writeFile(manifestPath, JSON.stringify(manifest));
|
|
47
|
+
return manifest;
|
|
47
48
|
};
|
|
48
49
|
export { generateManifest, writeManifest };
|
package/dist/server/server.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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?:
|
|
17
|
-
onBeforeDownload?:
|
|
16
|
+
onAfterDownload?: OnAfterDownloadHook;
|
|
17
|
+
onBeforeDownload?: OnBeforeDownloadHook;
|
|
18
18
|
formatExportTypeError?: FormatFunction;
|
|
19
19
|
formatImportError?: FormatFunction;
|
|
20
20
|
port: number;
|
package/dist/server/util.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ExecaChildProcess } from 'execa';
|
|
2
2
|
declare const killProcess: (ps: ExecaChildProcess<string>) => Promise<unknown> | undefined;
|
|
3
|
-
declare const waitForServer: (port: number, ps?: ExecaChildProcess<string>
|
|
3
|
+
declare const waitForServer: (port: number, ps?: ExecaChildProcess<string>) => Promise<boolean>;
|
|
4
4
|
export { killProcess, waitForServer };
|