@netlify/edge-bundler 1.10.0 → 1.12.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 +6 -3
- package/dist/bridge.js +11 -8
- 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 +2 -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>;
|
|
@@ -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
|
@@ -2,6 +2,7 @@ import { promises as fs } from 'fs';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import process from 'process';
|
|
4
4
|
import { execa } from 'execa';
|
|
5
|
+
import pathKey from 'path-key';
|
|
5
6
|
import semver from 'semver';
|
|
6
7
|
import { download } from './downloader.js';
|
|
7
8
|
import { getPathInHome } from './home_path.js';
|
|
@@ -116,27 +117,29 @@ class DenoBridge {
|
|
|
116
117
|
const downloadedPath = await this.getRemoteBinary();
|
|
117
118
|
return { global: false, path: downloadedPath };
|
|
118
119
|
}
|
|
119
|
-
getEnvironmentVariables() {
|
|
120
|
-
const env = {};
|
|
120
|
+
getEnvironmentVariables(inputEnv = {}) {
|
|
121
|
+
const env = { ...inputEnv };
|
|
121
122
|
if (this.denoDir !== undefined) {
|
|
122
123
|
env.DENO_DIR = this.denoDir;
|
|
123
124
|
}
|
|
125
|
+
// Ensure PATH is always set as otherwise we are not able to find the global deno binary
|
|
126
|
+
env[pathKey()] = inputEnv[pathKey({ env: inputEnv })] || process.env[pathKey()];
|
|
124
127
|
return env;
|
|
125
128
|
}
|
|
126
129
|
// Runs the Deno CLI in the background and returns a reference to the child
|
|
127
130
|
// process, awaiting its execution.
|
|
128
|
-
async run(args, { pipeOutput } = {}) {
|
|
131
|
+
async run(args, { pipeOutput, env: inputEnv, extendEnv = true } = {}) {
|
|
129
132
|
const { path: binaryPath } = await this.getBinaryPath();
|
|
130
|
-
const env = this.getEnvironmentVariables();
|
|
131
|
-
const options = { env };
|
|
133
|
+
const env = this.getEnvironmentVariables(inputEnv);
|
|
134
|
+
const options = { env, extendEnv };
|
|
132
135
|
return DenoBridge.runWithBinary(binaryPath, args, options, pipeOutput);
|
|
133
136
|
}
|
|
134
137
|
// Runs the Deno CLI in the background, assigning a reference of the child
|
|
135
138
|
// process to a `ps` property in the `ref` argument, if one is supplied.
|
|
136
|
-
async runInBackground(args, pipeOutput,
|
|
139
|
+
async runInBackground(args, ref, { pipeOutput, env: inputEnv, extendEnv = true } = {}) {
|
|
137
140
|
const { path: binaryPath } = await this.getBinaryPath();
|
|
138
|
-
const env = this.getEnvironmentVariables();
|
|
139
|
-
const options = { env };
|
|
141
|
+
const env = this.getEnvironmentVariables(inputEnv);
|
|
142
|
+
const options = { env, extendEnv };
|
|
140
143
|
const ps = DenoBridge.runWithBinary(binaryPath, args, options, pipeOutput);
|
|
141
144
|
if (ref !== undefined) {
|
|
142
145
|
// 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,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/edge-bundler",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.1",
|
|
4
4
|
"description": "Intelligently prepare Netlify Edge Functions for deployment",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -87,6 +87,7 @@
|
|
|
87
87
|
"node-fetch": "^3.1.1",
|
|
88
88
|
"node-stream-zip": "^1.15.0",
|
|
89
89
|
"p-wait-for": "^4.1.0",
|
|
90
|
+
"path-key": "^4.0.0",
|
|
90
91
|
"semver": "^7.3.5",
|
|
91
92
|
"tmp-promise": "^3.0.3",
|
|
92
93
|
"uuid": "^8.3.2"
|