@netlify/edge-bundler 1.7.0 → 1.8.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/dist/bridge.d.ts +4 -1
- package/dist/bridge.js +16 -4
- package/dist/bundler.d.ts +1 -0
- package/dist/bundler.js +6 -2
- package/dist/feature_flags.js +1 -0
- package/package.json +1 -1
package/dist/bridge.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ declare type OnAfterDownloadHook = (error?: Error) => void | Promise<void>;
|
|
|
4
4
|
interface DenoOptions {
|
|
5
5
|
cacheDirectory?: string;
|
|
6
6
|
debug?: boolean;
|
|
7
|
+
denoDir?: string;
|
|
7
8
|
onAfterDownload?: OnAfterDownloadHook;
|
|
8
9
|
onBeforeDownload?: OnBeforeDownloadHook;
|
|
9
10
|
useGlobal?: boolean;
|
|
@@ -19,6 +20,7 @@ declare class DenoBridge {
|
|
|
19
20
|
cacheDirectory: string;
|
|
20
21
|
currentDownload?: ReturnType<DenoBridge['downloadBinary']>;
|
|
21
22
|
debug: boolean;
|
|
23
|
+
denoDir?: string;
|
|
22
24
|
onAfterDownload?: OnAfterDownloadHook;
|
|
23
25
|
onBeforeDownload?: OnBeforeDownloadHook;
|
|
24
26
|
useGlobal: boolean;
|
|
@@ -36,9 +38,10 @@ declare class DenoBridge {
|
|
|
36
38
|
global: boolean;
|
|
37
39
|
path: string;
|
|
38
40
|
}>;
|
|
41
|
+
getEnvironmentVariables(): Record<string, string>;
|
|
39
42
|
log(...data: unknown[]): void;
|
|
40
43
|
run(args: string[], { pipeOutput }?: RunOptions): Promise<import("execa").ExecaReturnValue<string>>;
|
|
41
44
|
runInBackground(args: string[], pipeOutput?: boolean, ref?: ProcessRef): Promise<void>;
|
|
42
45
|
}
|
|
43
46
|
export { DenoBridge };
|
|
44
|
-
export type { OnAfterDownloadHook, OnBeforeDownloadHook, ProcessRef };
|
|
47
|
+
export type { DenoOptions, OnAfterDownloadHook, OnBeforeDownloadHook, ProcessRef };
|
package/dist/bridge.js
CHANGED
|
@@ -13,6 +13,7 @@ class DenoBridge {
|
|
|
13
13
|
var _a, _b, _c, _d;
|
|
14
14
|
this.cacheDirectory = (_a = options.cacheDirectory) !== null && _a !== void 0 ? _a : getPathInHome('deno-cli');
|
|
15
15
|
this.debug = (_b = options.debug) !== null && _b !== void 0 ? _b : false;
|
|
16
|
+
this.denoDir = options.denoDir;
|
|
16
17
|
this.onAfterDownload = options.onAfterDownload;
|
|
17
18
|
this.onBeforeDownload = options.onBeforeDownload;
|
|
18
19
|
this.useGlobal = (_c = options.useGlobal) !== null && _c !== void 0 ? _c : true;
|
|
@@ -82,9 +83,9 @@ class DenoBridge {
|
|
|
82
83
|
}
|
|
83
84
|
return this.currentDownload;
|
|
84
85
|
}
|
|
85
|
-
static runWithBinary(binaryPath, args, pipeOutput) {
|
|
86
|
+
static runWithBinary(binaryPath, args, options, pipeOutput) {
|
|
86
87
|
var _a, _b;
|
|
87
|
-
const runDeno = execa(binaryPath, args);
|
|
88
|
+
const runDeno = execa(binaryPath, args, options);
|
|
88
89
|
if (pipeOutput) {
|
|
89
90
|
(_a = runDeno.stdout) === null || _a === void 0 ? void 0 : _a.pipe(process.stdout);
|
|
90
91
|
(_b = runDeno.stderr) === null || _b === void 0 ? void 0 : _b.pipe(process.stderr);
|
|
@@ -113,6 +114,13 @@ class DenoBridge {
|
|
|
113
114
|
const downloadedPath = await this.getRemoteBinary();
|
|
114
115
|
return { global: false, path: downloadedPath };
|
|
115
116
|
}
|
|
117
|
+
getEnvironmentVariables() {
|
|
118
|
+
const env = {};
|
|
119
|
+
if (this.denoDir !== undefined) {
|
|
120
|
+
env.DENO_DIR = this.denoDir;
|
|
121
|
+
}
|
|
122
|
+
return env;
|
|
123
|
+
}
|
|
116
124
|
log(...data) {
|
|
117
125
|
if (!this.debug) {
|
|
118
126
|
return;
|
|
@@ -123,13 +131,17 @@ class DenoBridge {
|
|
|
123
131
|
// process, awaiting its execution.
|
|
124
132
|
async run(args, { pipeOutput } = {}) {
|
|
125
133
|
const { path: binaryPath } = await this.getBinaryPath();
|
|
126
|
-
|
|
134
|
+
const env = this.getEnvironmentVariables();
|
|
135
|
+
const options = { env };
|
|
136
|
+
return DenoBridge.runWithBinary(binaryPath, args, options, pipeOutput);
|
|
127
137
|
}
|
|
128
138
|
// Runs the Deno CLI in the background, assigning a reference of the child
|
|
129
139
|
// process to a `ps` property in the `ref` argument, if one is supplied.
|
|
130
140
|
async runInBackground(args, pipeOutput, ref) {
|
|
131
141
|
const { path: binaryPath } = await this.getBinaryPath();
|
|
132
|
-
const
|
|
142
|
+
const env = this.getEnvironmentVariables();
|
|
143
|
+
const options = { env };
|
|
144
|
+
const ps = DenoBridge.runWithBinary(binaryPath, args, options, pipeOutput);
|
|
133
145
|
if (ref !== undefined) {
|
|
134
146
|
// eslint-disable-next-line no-param-reassign
|
|
135
147
|
ref.ps = ps;
|
package/dist/bundler.d.ts
CHANGED
package/dist/bundler.js
CHANGED
|
@@ -37,12 +37,16 @@ const createBundleOps = ({ basePath, buildID, debug, deno, distDirectory, functi
|
|
|
37
37
|
};
|
|
38
38
|
const bundle = async (sourceDirectories, distDirectory, declarations = [], { basePath: inputBasePath, cacheDirectory, debug, distImportMapPath, featureFlags: inputFeatureFlags, importMaps, onAfterDownload, onBeforeDownload, } = {}) => {
|
|
39
39
|
const featureFlags = getFlags(inputFeatureFlags);
|
|
40
|
-
const
|
|
40
|
+
const options = {
|
|
41
41
|
debug,
|
|
42
42
|
cacheDirectory,
|
|
43
43
|
onAfterDownload,
|
|
44
44
|
onBeforeDownload,
|
|
45
|
-
}
|
|
45
|
+
};
|
|
46
|
+
if (cacheDirectory !== undefined && featureFlags.edge_functions_cache_deno_dir) {
|
|
47
|
+
options.denoDir = join(cacheDirectory, 'deno_dir');
|
|
48
|
+
}
|
|
49
|
+
const deno = new DenoBridge(options);
|
|
46
50
|
const basePath = getBasePath(sourceDirectories, inputBasePath);
|
|
47
51
|
await ensureLatestTypes(deno);
|
|
48
52
|
// The name of the bundle will be the hash of its contents, which we can't
|
package/dist/feature_flags.js
CHANGED