@netlify/edge-bundler 12.3.3 → 12.4.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/lib/common.ts +1 -1
- package/dist/node/bridge.d.ts +5 -3
- package/dist/node/bridge.js +8 -4
- package/dist/node/bundler.test.js +5 -10
- package/dist/node/config.js +5 -2
- package/dist/node/server/server.js +2 -1
- package/dist/node/server/server.test.js +2 -1
- package/dist/test/util.js +1 -1
- package/package.json +2 -2
package/deno/lib/common.ts
CHANGED
|
@@ -42,7 +42,7 @@ const loadWithRetry = (specifier: string, delay = 1000, maxTry = 3) => {
|
|
|
42
42
|
maxTry,
|
|
43
43
|
});
|
|
44
44
|
} catch (error) {
|
|
45
|
-
if (isTooManyTries(error)) {
|
|
45
|
+
if (isTooManyTries(error as Error)) {
|
|
46
46
|
console.error(`Loading ${specifier} failed after ${maxTry} tries.`);
|
|
47
47
|
}
|
|
48
48
|
throw error;
|
package/dist/node/bridge.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type WriteStream } from 'fs';
|
|
2
2
|
import { ExecaChildProcess } from 'execa';
|
|
3
3
|
import { Logger } from './logger.js';
|
|
4
|
-
declare const DENO_VERSION_RANGE = "1.39.0 -
|
|
4
|
+
declare const DENO_VERSION_RANGE = "1.39.0 - 2.2.4";
|
|
5
5
|
type OnBeforeDownloadHook = () => void | Promise<void>;
|
|
6
6
|
type OnAfterDownloadHook = (error?: Error) => void | Promise<void>;
|
|
7
7
|
interface DenoOptions {
|
|
@@ -37,14 +37,16 @@ declare class DenoBridge {
|
|
|
37
37
|
versionRange: string;
|
|
38
38
|
constructor(options: DenoOptions);
|
|
39
39
|
private downloadBinary;
|
|
40
|
-
|
|
40
|
+
getBinaryVersion(binaryPath: string): Promise<string | undefined>;
|
|
41
41
|
private getCachedBinary;
|
|
42
42
|
private getGlobalBinary;
|
|
43
43
|
private getRemoteBinary;
|
|
44
44
|
private static runWithBinary;
|
|
45
45
|
private writeVersionFile;
|
|
46
46
|
ensureCacheDirectory(): Promise<void>;
|
|
47
|
-
getBinaryPath(
|
|
47
|
+
getBinaryPath(options?: {
|
|
48
|
+
silent?: boolean;
|
|
49
|
+
}): Promise<{
|
|
48
50
|
global: boolean;
|
|
49
51
|
path: string;
|
|
50
52
|
}>;
|
package/dist/node/bridge.js
CHANGED
|
@@ -12,7 +12,7 @@ const DENO_VERSION_FILE = 'version.txt';
|
|
|
12
12
|
// When updating DENO_VERSION_RANGE, ensure that the deno version
|
|
13
13
|
// on the netlify/buildbot build image satisfies this range!
|
|
14
14
|
// https://github.com/netlify/buildbot/blob/f9c03c9dcb091d6570e9d0778381560d469e78ad/build-image/noble/Dockerfile#L410
|
|
15
|
-
const DENO_VERSION_RANGE = '1.39.0 -
|
|
15
|
+
const DENO_VERSION_RANGE = '1.39.0 - 2.2.4';
|
|
16
16
|
class DenoBridge {
|
|
17
17
|
constructor(options) {
|
|
18
18
|
var _a, _b, _c, _d, _e;
|
|
@@ -119,15 +119,19 @@ class DenoBridge {
|
|
|
119
119
|
async ensureCacheDirectory() {
|
|
120
120
|
await fs.mkdir(this.cacheDirectory, { recursive: true });
|
|
121
121
|
}
|
|
122
|
-
async getBinaryPath() {
|
|
122
|
+
async getBinaryPath(options) {
|
|
123
123
|
const globalPath = await this.getGlobalBinary();
|
|
124
124
|
if (globalPath !== undefined) {
|
|
125
|
-
|
|
125
|
+
if (!(options === null || options === void 0 ? void 0 : options.silent)) {
|
|
126
|
+
this.logger.system('Using global installation of Deno CLI');
|
|
127
|
+
}
|
|
126
128
|
return { global: true, path: globalPath };
|
|
127
129
|
}
|
|
128
130
|
const cachedPath = await this.getCachedBinary();
|
|
129
131
|
if (cachedPath !== undefined) {
|
|
130
|
-
|
|
132
|
+
if (!(options === null || options === void 0 ? void 0 : options.silent)) {
|
|
133
|
+
this.logger.system('Using cached Deno CLI from', cachedPath);
|
|
134
|
+
}
|
|
131
135
|
return { global: false, path: cachedPath };
|
|
132
136
|
}
|
|
133
137
|
const downloadedPath = await this.getRemoteBinary();
|
|
@@ -84,16 +84,11 @@ test('Adds a custom error property to user errors during bundling', async () =>
|
|
|
84
84
|
}
|
|
85
85
|
catch (error) {
|
|
86
86
|
expect(error).toBeInstanceOf(BundleError);
|
|
87
|
-
const
|
|
88
|
-
expect(messageBeforeStack
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
~
|
|
93
|
-
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
94
|
-
^
|
|
95
|
-
"
|
|
96
|
-
`);
|
|
87
|
+
const messageBeforeStack = error.message;
|
|
88
|
+
expect(messageBeforeStack
|
|
89
|
+
.replace(/file:\/\/\/(.*?\/)(build\/packages\/edge-bundler\/deno\/vendor\/deno\.land\/x\/eszip.*)/, 'file://$2')
|
|
90
|
+
// eslint-disable-next-line no-control-regex
|
|
91
|
+
.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '')).toMatchSnapshot();
|
|
97
92
|
expect(error.customErrorInfo).toEqual({
|
|
98
93
|
location: {
|
|
99
94
|
format: 'eszip',
|
package/dist/node/config.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { promises as fs } from 'fs';
|
|
2
2
|
import { join } from 'path';
|
|
3
3
|
import { pathToFileURL } from 'url';
|
|
4
|
+
import { SemVer } from 'semver';
|
|
4
5
|
import tmp from 'tmp-promise';
|
|
5
6
|
import { BundleError } from './bundle_error.js';
|
|
6
7
|
import { getPackagePath } from './package_json.js';
|
|
@@ -39,21 +40,23 @@ export const getFunctionConfig = async ({ func, importMap, deno, log, }) => {
|
|
|
39
40
|
// The extractor will use its exit code to signal different error scenarios,
|
|
40
41
|
// based on the list of exit codes we send as an argument. We then capture
|
|
41
42
|
// the exit code to know exactly what happened and guide people accordingly.
|
|
43
|
+
const version = new SemVer((await deno.getBinaryVersion((await deno.getBinaryPath({ silent: true })).path)) || '');
|
|
42
44
|
const { exitCode, stderr, stdout } = await deno.run([
|
|
43
45
|
'run',
|
|
44
46
|
'--allow-env',
|
|
47
|
+
version.major >= 2 ? '--allow-import' : '',
|
|
45
48
|
'--allow-net',
|
|
46
49
|
'--allow-read',
|
|
47
50
|
`--allow-write=${collector.path}`,
|
|
48
|
-
'--quiet',
|
|
49
51
|
`--import-map=${importMap.toDataURL()}`,
|
|
50
52
|
'--no-config',
|
|
51
53
|
'--node-modules-dir=false',
|
|
54
|
+
'--quiet',
|
|
52
55
|
extractorPath,
|
|
53
56
|
pathToFileURL(func.path).href,
|
|
54
57
|
pathToFileURL(collector.path).href,
|
|
55
58
|
JSON.stringify(ConfigExitCode),
|
|
56
|
-
], { rejectOnExitCode: false });
|
|
59
|
+
].filter(Boolean), { rejectOnExitCode: false });
|
|
57
60
|
if (exitCode !== ConfigExitCode.Success) {
|
|
58
61
|
handleConfigError(func, exitCode, stderr, log);
|
|
59
62
|
return {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { readdir, unlink } from 'fs/promises';
|
|
2
2
|
import { join } from 'path';
|
|
3
|
+
import { pathToFileURL } from 'url';
|
|
3
4
|
import { DenoBridge } from '../bridge.js';
|
|
4
5
|
import { getFunctionConfig } from '../config.js';
|
|
5
6
|
import { generateStage2 } from '../formats/javascript.js';
|
|
@@ -65,7 +66,7 @@ const prepareServer = ({ basePath, bootstrapURL, deno, distDirectory, distImport
|
|
|
65
66
|
// the `stage2Path` file as well as all of their dependencies.
|
|
66
67
|
// Consumers such as the CLI can use this information to watch all the
|
|
67
68
|
// relevant files and issue an isolate restart when one of them changes.
|
|
68
|
-
const { stdout } = await deno.run(['info', '--json', stage2Path]);
|
|
69
|
+
const { stdout } = await deno.run(['info', '--json', pathToFileURL(stage2Path).href]);
|
|
69
70
|
graph = JSON.parse(stdout);
|
|
70
71
|
}
|
|
71
72
|
catch {
|
|
@@ -49,8 +49,9 @@ test('Starts a server and serves requests for edge functions', async () => {
|
|
|
49
49
|
expect(success).toBe(true);
|
|
50
50
|
expect(functionsConfig).toEqual([{ path: '/my-function' }, {}, { path: '/global-netlify' }]);
|
|
51
51
|
expect(npmSpecifiersWithExtraneousFiles).toEqual(['dictionary']);
|
|
52
|
+
const modules = graph === null || graph === void 0 ? void 0 : graph.modules.filter(({ kind, mediaType }) => kind === 'esm' && mediaType === 'TypeScript');
|
|
52
53
|
for (const key in functions) {
|
|
53
|
-
const graphEntry =
|
|
54
|
+
const graphEntry = modules === null || modules === void 0 ? void 0 : modules.some(({ local }) => local === functions[key].path);
|
|
54
55
|
expect(graphEntry).toBe(true);
|
|
55
56
|
}
|
|
56
57
|
const response1 = await fetch(`http://0.0.0.0:${port}/foo`, {
|
package/dist/test/util.js
CHANGED
|
@@ -76,7 +76,7 @@ const runESZIP = async (eszipPath, vendorDirectory) => {
|
|
|
76
76
|
}
|
|
77
77
|
await fs.rename(stage2Path, `${stage2Path}.js`);
|
|
78
78
|
// Run function that imports the extracted stage 2 and invokes each function.
|
|
79
|
-
const evalCommand = execa('deno', ['eval', '--
|
|
79
|
+
const evalCommand = execa('deno', ['eval', '--import-map', importMapPath, inspectFunction(stage2Path)]);
|
|
80
80
|
(_c = evalCommand.stderr) === null || _c === void 0 ? void 0 : _c.pipe(stderr);
|
|
81
81
|
const result = await evalCommand;
|
|
82
82
|
await tmpDir.cleanup();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/edge-bundler",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.4.0",
|
|
4
4
|
"description": "Intelligently prepare Netlify Edge Functions for deployment",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/node/index.js",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"urlpattern-polyfill": "8.0.2",
|
|
81
81
|
"uuid": "^9.0.0"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "0e4628f57a0a7d02594b5070074445a4ff69b809"
|
|
84
84
|
}
|