@netlify/edge-bundler 1.11.0 → 1.13.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.js +11 -5
- package/dist/downloader.d.ts +2 -1
- package/dist/downloader.js +9 -2
- package/dist/formats/javascript.js +1 -1
- package/package.json +3 -1
package/deno/bundle.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { writeStage2 } from 'https://
|
|
1
|
+
import { writeStage2 } from 'https://62f5f45fbc76ed0009624267--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.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';
|
|
@@ -26,7 +27,7 @@ class DenoBridge {
|
|
|
26
27
|
await ((_a = this.onBeforeDownload) === null || _a === void 0 ? void 0 : _a.call(this));
|
|
27
28
|
await this.ensureCacheDirectory();
|
|
28
29
|
this.logger.system(`Downloading Deno CLI to ${this.cacheDirectory}`);
|
|
29
|
-
const binaryPath = await download(this.cacheDirectory, this.versionRange);
|
|
30
|
+
const binaryPath = await download(this.cacheDirectory, this.versionRange, this.logger);
|
|
30
31
|
const downloadedVersion = await this.getBinaryVersion(binaryPath);
|
|
31
32
|
// We should never get here, because it means that `DENO_VERSION_RANGE` is
|
|
32
33
|
// a malformed semver range. If this does happen, let's throw an error so
|
|
@@ -34,6 +35,7 @@ class DenoBridge {
|
|
|
34
35
|
if (downloadedVersion === undefined) {
|
|
35
36
|
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.');
|
|
36
37
|
await ((_b = this.onAfterDownload) === null || _b === void 0 ? void 0 : _b.call(this, error));
|
|
38
|
+
this.logger.system('Could not run downloaded Deno CLI', error);
|
|
37
39
|
throw error;
|
|
38
40
|
}
|
|
39
41
|
await this.writeVersionFile(downloadedVersion);
|
|
@@ -45,13 +47,12 @@ class DenoBridge {
|
|
|
45
47
|
const { stdout } = await execa(binaryPath, ['--version']);
|
|
46
48
|
const version = stdout.match(/^deno ([\d.]+)/);
|
|
47
49
|
if (!version) {
|
|
50
|
+
this.logger.system(`getBinaryVersion no version found. binaryPath ${binaryPath}`);
|
|
48
51
|
return;
|
|
49
52
|
}
|
|
50
53
|
return version[1];
|
|
51
54
|
}
|
|
52
|
-
catch
|
|
53
|
-
this.logger.system('Error checking Deno binary version', error);
|
|
54
|
-
}
|
|
55
|
+
catch { }
|
|
55
56
|
}
|
|
56
57
|
async getCachedBinary() {
|
|
57
58
|
const versionFilePath = path.join(this.cacheDirectory, DENO_VERSION_FILE);
|
|
@@ -59,10 +60,12 @@ class DenoBridge {
|
|
|
59
60
|
try {
|
|
60
61
|
cachedVersion = await fs.readFile(versionFilePath, 'utf8');
|
|
61
62
|
}
|
|
62
|
-
catch {
|
|
63
|
+
catch (error) {
|
|
64
|
+
this.logger.system('Error getting cached binary', error);
|
|
63
65
|
return;
|
|
64
66
|
}
|
|
65
67
|
if (!semver.satisfies(cachedVersion, this.versionRange)) {
|
|
68
|
+
this.logger.system(`semver not satisfied. cachedVersion: ${cachedVersion}, versionRange: ${this.versionRange}`);
|
|
66
69
|
return;
|
|
67
70
|
}
|
|
68
71
|
const binaryName = `deno${getBinaryExtension()}`;
|
|
@@ -75,6 +78,7 @@ class DenoBridge {
|
|
|
75
78
|
const globalBinaryName = 'deno';
|
|
76
79
|
const globalVersion = await this.getBinaryVersion(globalBinaryName);
|
|
77
80
|
if (globalVersion === undefined || !semver.satisfies(globalVersion, this.versionRange)) {
|
|
81
|
+
this.logger.system(`No globalVersion or semver not satisfied. globalVersion: ${globalVersion}, versionRange: ${this.versionRange}`);
|
|
78
82
|
return;
|
|
79
83
|
}
|
|
80
84
|
return globalBinaryName;
|
|
@@ -121,6 +125,8 @@ class DenoBridge {
|
|
|
121
125
|
if (this.denoDir !== undefined) {
|
|
122
126
|
env.DENO_DIR = this.denoDir;
|
|
123
127
|
}
|
|
128
|
+
// Ensure PATH is always set as otherwise we are not able to find the global deno binary
|
|
129
|
+
env[pathKey()] = inputEnv[pathKey({ env: inputEnv })] || process.env[pathKey()];
|
|
124
130
|
return env;
|
|
125
131
|
}
|
|
126
132
|
// Runs the Deno CLI in the background and returns a reference to the child
|
package/dist/downloader.d.ts
CHANGED
package/dist/downloader.js
CHANGED
|
@@ -2,11 +2,12 @@ import fs from 'fs';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import fetch from 'node-fetch';
|
|
4
4
|
import StreamZip from 'node-stream-zip';
|
|
5
|
+
import pRetry from 'p-retry';
|
|
5
6
|
import semver from 'semver';
|
|
6
7
|
import { getBinaryExtension, getPlatformTarget } from './platform.js';
|
|
7
|
-
const download = async (targetDirectory, versionRange) => {
|
|
8
|
+
const download = async (targetDirectory, versionRange, logger) => {
|
|
8
9
|
const zipPath = path.join(targetDirectory, 'deno-cli-latest.zip');
|
|
9
|
-
const data = await
|
|
10
|
+
const data = await downloadVersionWithRetry(versionRange, logger);
|
|
10
11
|
const binaryName = `deno${getBinaryExtension()}`;
|
|
11
12
|
const binaryPath = path.join(targetDirectory, binaryName);
|
|
12
13
|
const file = fs.createWriteStream(zipPath);
|
|
@@ -33,6 +34,12 @@ const downloadVersion = async (versionRange) => {
|
|
|
33
34
|
}
|
|
34
35
|
return res.body;
|
|
35
36
|
};
|
|
37
|
+
const downloadVersionWithRetry = async (versionRange, logger) => await pRetry(async () => await downloadVersion(versionRange), {
|
|
38
|
+
retries: 3,
|
|
39
|
+
onFailedAttempt: (error) => {
|
|
40
|
+
logger.system('Deno CLI download retry attempt error', error);
|
|
41
|
+
},
|
|
42
|
+
});
|
|
36
43
|
const extractBinaryFromZip = async (zipPath, binaryPath, binaryName) => {
|
|
37
44
|
const { async: StreamZipAsync } = StreamZip;
|
|
38
45
|
const zip = new StreamZipAsync({ file: zipPath });
|
|
@@ -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://62f5f45fbc76ed0009624267--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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/edge-bundler",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"description": "Intelligently prepare Netlify Edge Functions for deployment",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -86,7 +86,9 @@
|
|
|
86
86
|
"glob-to-regexp": "^0.4.1",
|
|
87
87
|
"node-fetch": "^3.1.1",
|
|
88
88
|
"node-stream-zip": "^1.15.0",
|
|
89
|
+
"p-retry": "^5.1.1",
|
|
89
90
|
"p-wait-for": "^4.1.0",
|
|
91
|
+
"path-key": "^4.0.0",
|
|
90
92
|
"semver": "^7.3.5",
|
|
91
93
|
"tmp-promise": "^3.0.3",
|
|
92
94
|
"uuid": "^8.3.2"
|