@netlify/edge-bundler 1.9.0 → 1.12.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.
- package/deno/bundle.ts +1 -1
- package/dist/bridge.d.ts +7 -4
- package/dist/bridge.js +13 -12
- package/dist/formats/javascript.js +1 -1
- package/dist/server/server.d.ts +5 -1
- package/dist/server/server.js +9 -2
- package/package.json +1 -1
package/deno/bundle.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { writeStage2 } from 'https://
|
|
1
|
+
import { writeStage2 } from 'https://62ea8d05a6858300091547ed--edge.netlify.com/bundler/mod.ts'
|
|
2
2
|
|
|
3
3
|
const [payload] = Deno.args
|
|
4
4
|
const { basePath, destPath, functions, imports } = JSON.parse(payload)
|
package/dist/bridge.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { ExecaChildProcess } from 'execa';
|
|
2
3
|
import { Logger } from './logger.js';
|
|
3
4
|
declare type OnBeforeDownloadHook = () => void | Promise<void>;
|
|
@@ -6,7 +7,7 @@ interface DenoOptions {
|
|
|
6
7
|
cacheDirectory?: string;
|
|
7
8
|
debug?: boolean;
|
|
8
9
|
denoDir?: string;
|
|
9
|
-
logger
|
|
10
|
+
logger?: Logger;
|
|
10
11
|
onAfterDownload?: OnAfterDownloadHook;
|
|
11
12
|
onBeforeDownload?: OnBeforeDownloadHook;
|
|
12
13
|
useGlobal?: boolean;
|
|
@@ -17,6 +18,8 @@ interface ProcessRef {
|
|
|
17
18
|
}
|
|
18
19
|
interface RunOptions {
|
|
19
20
|
pipeOutput?: boolean;
|
|
21
|
+
env?: NodeJS.ProcessEnv;
|
|
22
|
+
extendEnv?: boolean;
|
|
20
23
|
}
|
|
21
24
|
declare class DenoBridge {
|
|
22
25
|
cacheDirectory: string;
|
|
@@ -41,9 +44,9 @@ declare class DenoBridge {
|
|
|
41
44
|
global: boolean;
|
|
42
45
|
path: string;
|
|
43
46
|
}>;
|
|
44
|
-
getEnvironmentVariables():
|
|
45
|
-
run(args: string[], { pipeOutput }?: RunOptions): Promise<import("execa").ExecaReturnValue<string>>;
|
|
46
|
-
runInBackground(args: string[],
|
|
47
|
+
getEnvironmentVariables(inputEnv?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
48
|
+
run(args: string[], { pipeOutput, env: inputEnv, extendEnv }?: RunOptions): Promise<import("execa").ExecaReturnValue<string>>;
|
|
49
|
+
runInBackground(args: string[], ref?: ProcessRef, { pipeOutput, env: inputEnv, extendEnv }?: RunOptions): Promise<void>;
|
|
47
50
|
}
|
|
48
51
|
export { DenoBridge };
|
|
49
52
|
export type { DenoOptions, OnAfterDownloadHook, OnBeforeDownloadHook, ProcessRef };
|
package/dist/bridge.js
CHANGED
|
@@ -5,20 +5,21 @@ import { execa } from 'execa';
|
|
|
5
5
|
import semver from 'semver';
|
|
6
6
|
import { download } from './downloader.js';
|
|
7
7
|
import { getPathInHome } from './home_path.js';
|
|
8
|
+
import { getLogger } from './logger.js';
|
|
8
9
|
import { getBinaryExtension } from './platform.js';
|
|
9
10
|
const DENO_VERSION_FILE = 'version.txt';
|
|
10
11
|
const DENO_VERSION_RANGE = '^1.20.3';
|
|
11
12
|
class DenoBridge {
|
|
12
13
|
constructor(options) {
|
|
13
|
-
var _a, _b, _c, _d;
|
|
14
|
+
var _a, _b, _c, _d, _e;
|
|
14
15
|
this.cacheDirectory = (_a = options.cacheDirectory) !== null && _a !== void 0 ? _a : getPathInHome('deno-cli');
|
|
15
16
|
this.debug = (_b = options.debug) !== null && _b !== void 0 ? _b : false;
|
|
16
17
|
this.denoDir = options.denoDir;
|
|
17
|
-
this.logger = options.logger;
|
|
18
|
+
this.logger = (_c = options.logger) !== null && _c !== void 0 ? _c : getLogger(undefined, options.debug);
|
|
18
19
|
this.onAfterDownload = options.onAfterDownload;
|
|
19
20
|
this.onBeforeDownload = options.onBeforeDownload;
|
|
20
|
-
this.useGlobal = (
|
|
21
|
-
this.versionRange = (
|
|
21
|
+
this.useGlobal = (_d = options.useGlobal) !== null && _d !== void 0 ? _d : true;
|
|
22
|
+
this.versionRange = (_e = options.versionRange) !== null && _e !== void 0 ? _e : DENO_VERSION_RANGE;
|
|
22
23
|
}
|
|
23
24
|
async downloadBinary() {
|
|
24
25
|
var _a, _b, _c;
|
|
@@ -115,8 +116,8 @@ class DenoBridge {
|
|
|
115
116
|
const downloadedPath = await this.getRemoteBinary();
|
|
116
117
|
return { global: false, path: downloadedPath };
|
|
117
118
|
}
|
|
118
|
-
getEnvironmentVariables() {
|
|
119
|
-
const env = {};
|
|
119
|
+
getEnvironmentVariables(inputEnv = {}) {
|
|
120
|
+
const env = { ...inputEnv };
|
|
120
121
|
if (this.denoDir !== undefined) {
|
|
121
122
|
env.DENO_DIR = this.denoDir;
|
|
122
123
|
}
|
|
@@ -124,18 +125,18 @@ class DenoBridge {
|
|
|
124
125
|
}
|
|
125
126
|
// Runs the Deno CLI in the background and returns a reference to the child
|
|
126
127
|
// process, awaiting its execution.
|
|
127
|
-
async run(args, { pipeOutput } = {}) {
|
|
128
|
+
async run(args, { pipeOutput, env: inputEnv, extendEnv = true } = {}) {
|
|
128
129
|
const { path: binaryPath } = await this.getBinaryPath();
|
|
129
|
-
const env = this.getEnvironmentVariables();
|
|
130
|
-
const options = { env };
|
|
130
|
+
const env = this.getEnvironmentVariables(inputEnv);
|
|
131
|
+
const options = { env, extendEnv };
|
|
131
132
|
return DenoBridge.runWithBinary(binaryPath, args, options, pipeOutput);
|
|
132
133
|
}
|
|
133
134
|
// Runs the Deno CLI in the background, assigning a reference of the child
|
|
134
135
|
// process to a `ps` property in the `ref` argument, if one is supplied.
|
|
135
|
-
async runInBackground(args, pipeOutput,
|
|
136
|
+
async runInBackground(args, ref, { pipeOutput, env: inputEnv, extendEnv = true } = {}) {
|
|
136
137
|
const { path: binaryPath } = await this.getBinaryPath();
|
|
137
|
-
const env = this.getEnvironmentVariables();
|
|
138
|
-
const options = { env };
|
|
138
|
+
const env = this.getEnvironmentVariables(inputEnv);
|
|
139
|
+
const options = { env, extendEnv };
|
|
139
140
|
const ps = DenoBridge.runWithBinary(binaryPath, args, options, pipeOutput);
|
|
140
141
|
if (ref !== undefined) {
|
|
141
142
|
// eslint-disable-next-line no-param-reassign
|
|
@@ -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://62ea8d05a6858300091547ed--edge.netlify.com/bootstrap/index-combined.ts';
|
|
9
9
|
const bundleJS = async ({ buildID, debug, deno, distDirectory, functions, importMap, }) => {
|
|
10
10
|
const stage2Path = await generateStage2({ distDirectory, functions, fileName: `${buildID}-pre.js` });
|
|
11
11
|
const extension = '.js';
|
package/dist/server/server.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
/// <reference types="node" />
|
|
1
5
|
import { OnAfterDownloadHook, OnBeforeDownloadHook } from '../bridge.js';
|
|
2
6
|
import type { EdgeFunction } from '../edge_function.js';
|
|
3
7
|
import { ImportMapFile } from '../import_map.js';
|
|
@@ -21,7 +25,7 @@ interface ServeOptions {
|
|
|
21
25
|
port: number;
|
|
22
26
|
systemLogger?: LogFunction;
|
|
23
27
|
}
|
|
24
|
-
declare const serve: ({ certificatePath, debug, distImportMapPath, inspectSettings, formatExportTypeError, formatImportError, importMaps, onAfterDownload, onBeforeDownload, port, systemLogger, }: ServeOptions) => Promise<(newFunctions: EdgeFunction[]) => Promise<{
|
|
28
|
+
declare const serve: ({ certificatePath, debug, distImportMapPath, inspectSettings, formatExportTypeError, formatImportError, importMaps, onAfterDownload, onBeforeDownload, port, systemLogger, }: ServeOptions) => Promise<(newFunctions: EdgeFunction[], env?: NodeJS.ProcessEnv) => Promise<{
|
|
25
29
|
graph: any;
|
|
26
30
|
success: boolean;
|
|
27
31
|
}>>;
|
package/dist/server/server.js
CHANGED
|
@@ -7,7 +7,7 @@ import { ensureLatestTypes } from '../types.js';
|
|
|
7
7
|
import { killProcess, waitForServer } from './util.js';
|
|
8
8
|
const prepareServer = ({ deno, distDirectory, flags: denoFlags, formatExportTypeError, formatImportError, port, }) => {
|
|
9
9
|
const processRef = {};
|
|
10
|
-
const startIsolate = async (newFunctions) => {
|
|
10
|
+
const startIsolate = async (newFunctions, env = {}) => {
|
|
11
11
|
if ((processRef === null || processRef === void 0 ? void 0 : processRef.ps) !== undefined) {
|
|
12
12
|
await killProcess(processRef.ps);
|
|
13
13
|
}
|
|
@@ -32,7 +32,14 @@ const prepareServer = ({ deno, distDirectory, flags: denoFlags, formatExportType
|
|
|
32
32
|
// no-op
|
|
33
33
|
}
|
|
34
34
|
const bootstrapFlags = ['--port', port.toString()];
|
|
35
|
-
|
|
35
|
+
// We set `extendEnv: false` to avoid polluting the edge function context
|
|
36
|
+
// with variables from the user's system, since those will not be available
|
|
37
|
+
// in the production environment.
|
|
38
|
+
await deno.runInBackground(['run', ...denoFlags, stage2Path, ...bootstrapFlags], processRef, {
|
|
39
|
+
pipeOutput: true,
|
|
40
|
+
env,
|
|
41
|
+
extendEnv: false,
|
|
42
|
+
});
|
|
36
43
|
const success = await waitForServer(port, processRef.ps);
|
|
37
44
|
return {
|
|
38
45
|
graph,
|