esbuild 0.11.16 → 0.11.20
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/install.js +8 -4
- package/lib/main.d.ts +2 -2
- package/lib/main.js +37 -21
- package/package.json +1 -1
package/install.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
3
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
6
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
7
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
|
|
6
|
-
var
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
7
9
|
for (var prop in b || (b = {}))
|
|
8
10
|
if (__hasOwnProp.call(b, prop))
|
|
9
11
|
__defNormalProp(a, prop, b[prop]);
|
|
@@ -14,13 +16,14 @@ var __objSpread = (a, b) => {
|
|
|
14
16
|
}
|
|
15
17
|
return a;
|
|
16
18
|
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
17
20
|
const fs = require("fs");
|
|
18
21
|
const os = require("os");
|
|
19
22
|
const path = require("path");
|
|
20
23
|
const zlib = require("zlib");
|
|
21
24
|
const https = require("https");
|
|
22
25
|
const child_process = require("child_process");
|
|
23
|
-
const version = "0.11.
|
|
26
|
+
const version = "0.11.20";
|
|
24
27
|
const binPath = path.join(__dirname, "bin", "esbuild");
|
|
25
28
|
async function installBinaryFromPackage(name, fromPath, toPath) {
|
|
26
29
|
const cachePath = getCachePath(name);
|
|
@@ -150,7 +153,7 @@ function installUsingNPM(name, file) {
|
|
|
150
153
|
const installDir = path.join(os.tmpdir(), "esbuild-" + Math.random().toString(36).slice(2));
|
|
151
154
|
fs.mkdirSync(installDir, {recursive: true});
|
|
152
155
|
fs.writeFileSync(path.join(installDir, "package.json"), "{}");
|
|
153
|
-
const env =
|
|
156
|
+
const env = __spreadProps(__spreadValues({}, process.env), {npm_config_global: void 0});
|
|
154
157
|
child_process.execSync(`npm install --loglevel=error --prefer-offline --no-audit --progress=false ${name}@${version}`, {cwd: installDir, stdio: "pipe", env});
|
|
155
158
|
const buffer = fs.readFileSync(path.join(installDir, "node_modules", name, file));
|
|
156
159
|
try {
|
|
@@ -235,6 +238,7 @@ const knownUnixlikePackages = {
|
|
|
235
238
|
"darwin x64 LE": "esbuild-darwin-64",
|
|
236
239
|
"freebsd arm64 LE": "esbuild-freebsd-arm64",
|
|
237
240
|
"freebsd x64 LE": "esbuild-freebsd-64",
|
|
241
|
+
"openbsd x64 LE": "esbuild-openbsd-64",
|
|
238
242
|
"linux arm LE": "esbuild-linux-arm",
|
|
239
243
|
"linux arm64 LE": "esbuild-linux-arm64",
|
|
240
244
|
"linux ia32 LE": "esbuild-linux-32",
|
package/lib/main.d.ts
CHANGED
|
@@ -190,9 +190,9 @@ export interface Plugin {
|
|
|
190
190
|
export interface PluginBuild {
|
|
191
191
|
initialOptions: BuildOptions;
|
|
192
192
|
onStart(callback: () =>
|
|
193
|
-
(OnStartResult | null |
|
|
193
|
+
(OnStartResult | null | void | Promise<OnStartResult | null | void>)): void;
|
|
194
194
|
onEnd(callback: (result: BuildResult) =>
|
|
195
|
-
(
|
|
195
|
+
(void | Promise<void>)): void;
|
|
196
196
|
onResolve(options: OnResolveOptions, callback: (args: OnResolveArgs) =>
|
|
197
197
|
(OnResolveResult | null | undefined | Promise<OnResolveResult | null | undefined>)): void;
|
|
198
198
|
onLoad(options: OnLoadOptions, callback: (args: OnLoadArgs) =>
|
package/lib/main.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
3
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
6
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
7
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
|
|
6
|
-
var
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
7
9
|
for (var prop in b || (b = {}))
|
|
8
10
|
if (__hasOwnProp.call(b, prop))
|
|
9
11
|
__defNormalProp(a, prop, b[prop]);
|
|
@@ -14,6 +16,7 @@ var __objSpread = (a, b) => {
|
|
|
14
16
|
}
|
|
15
17
|
return a;
|
|
16
18
|
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
17
20
|
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
18
21
|
var __export = (target, all) => {
|
|
19
22
|
for (var name in all)
|
|
@@ -251,7 +254,7 @@ function pushLogFlags(flags, options, keys, isTTY2, logLevelDefault) {
|
|
|
251
254
|
let color = getFlag(options, keys, "color", mustBeBoolean);
|
|
252
255
|
let logLevel = getFlag(options, keys, "logLevel", mustBeString);
|
|
253
256
|
let logLimit = getFlag(options, keys, "logLimit", mustBeInteger);
|
|
254
|
-
if (color)
|
|
257
|
+
if (color !== void 0)
|
|
255
258
|
flags.push(`--color=${color}`);
|
|
256
259
|
else if (isTTY2)
|
|
257
260
|
flags.push(`--color=true`);
|
|
@@ -683,8 +686,8 @@ function createChannel(streamIn) {
|
|
|
683
686
|
if (isFirstPacket) {
|
|
684
687
|
isFirstPacket = false;
|
|
685
688
|
let binaryVersion = String.fromCharCode(...bytes);
|
|
686
|
-
if (binaryVersion !== "0.11.
|
|
687
|
-
throw new Error(`Cannot start service: Host version "${"0.11.
|
|
689
|
+
if (binaryVersion !== "0.11.20") {
|
|
690
|
+
throw new Error(`Cannot start service: Host version "${"0.11.20"}" does not match binary version ${JSON.stringify(binaryVersion)}`);
|
|
688
691
|
}
|
|
689
692
|
return;
|
|
690
693
|
}
|
|
@@ -909,15 +912,15 @@ function createChannel(streamIn) {
|
|
|
909
912
|
throw new Error(`Invalid command: ` + request.command);
|
|
910
913
|
}
|
|
911
914
|
};
|
|
912
|
-
let runOnEndCallbacks = (result, done) => done();
|
|
915
|
+
let runOnEndCallbacks = (result, logPluginError, done) => done();
|
|
913
916
|
if (onEndCallbacks.length > 0) {
|
|
914
|
-
runOnEndCallbacks = (result, done) => {
|
|
917
|
+
runOnEndCallbacks = (result, logPluginError, done) => {
|
|
915
918
|
(async () => {
|
|
916
919
|
for (const {name, callback: callback2, note} of onEndCallbacks) {
|
|
917
920
|
try {
|
|
918
921
|
await callback2(result);
|
|
919
922
|
} catch (e) {
|
|
920
|
-
result.errors.push(
|
|
923
|
+
result.errors.push(await new Promise((resolve) => logPluginError(e, name, note && note(), resolve)));
|
|
921
924
|
}
|
|
922
925
|
}
|
|
923
926
|
})().then(done);
|
|
@@ -992,15 +995,20 @@ function createChannel(streamIn) {
|
|
|
992
995
|
plugins = value;
|
|
993
996
|
}
|
|
994
997
|
}
|
|
995
|
-
let
|
|
998
|
+
let logPluginError = (e, pluginName, note, done) => {
|
|
996
999
|
let flags = [];
|
|
997
1000
|
try {
|
|
998
1001
|
pushLogFlags(flags, options, {}, isTTY2, buildLogLevelDefault);
|
|
999
1002
|
} catch (e2) {
|
|
1000
1003
|
}
|
|
1001
|
-
const
|
|
1002
|
-
sendRequest(refs, {command: "error", flags, error}, () => {
|
|
1003
|
-
|
|
1004
|
+
const message = extractErrorMessageV8(e, streamIn, details, note, pluginName);
|
|
1005
|
+
sendRequest(refs, {command: "error", flags, error: message}, () => {
|
|
1006
|
+
message.detail = details.load(message.detail);
|
|
1007
|
+
done(message);
|
|
1008
|
+
});
|
|
1009
|
+
};
|
|
1010
|
+
let handleError = (e, pluginName) => {
|
|
1011
|
+
logPluginError(e, pluginName, void 0, (error) => {
|
|
1004
1012
|
callback(failureErrorWithLog("Build failed", [error], []), null);
|
|
1005
1013
|
});
|
|
1006
1014
|
};
|
|
@@ -1012,9 +1020,10 @@ function createChannel(streamIn) {
|
|
|
1012
1020
|
handleError(result.error, result.pluginName);
|
|
1013
1021
|
} else {
|
|
1014
1022
|
try {
|
|
1015
|
-
buildOrServeContinue(
|
|
1023
|
+
buildOrServeContinue(__spreadProps(__spreadValues({}, args), {
|
|
1016
1024
|
key,
|
|
1017
1025
|
details,
|
|
1026
|
+
logPluginError,
|
|
1018
1027
|
requestPlugins: result.requestPlugins,
|
|
1019
1028
|
runOnEndCallbacks: result.runOnEndCallbacks,
|
|
1020
1029
|
pluginRefs: result.pluginRefs
|
|
@@ -1026,11 +1035,12 @@ function createChannel(streamIn) {
|
|
|
1026
1035
|
}, (e) => handleError(e, ""));
|
|
1027
1036
|
} else {
|
|
1028
1037
|
try {
|
|
1029
|
-
buildOrServeContinue(
|
|
1038
|
+
buildOrServeContinue(__spreadProps(__spreadValues({}, args), {
|
|
1030
1039
|
key,
|
|
1031
1040
|
details,
|
|
1041
|
+
logPluginError,
|
|
1032
1042
|
requestPlugins: null,
|
|
1033
|
-
runOnEndCallbacks: (result, done) => done(),
|
|
1043
|
+
runOnEndCallbacks: (result, logPluginError2, done) => done(),
|
|
1034
1044
|
pluginRefs: null
|
|
1035
1045
|
}));
|
|
1036
1046
|
} catch (e) {
|
|
@@ -1048,6 +1058,7 @@ function createChannel(streamIn) {
|
|
|
1048
1058
|
callback,
|
|
1049
1059
|
key,
|
|
1050
1060
|
details,
|
|
1061
|
+
logPluginError,
|
|
1051
1062
|
requestPlugins,
|
|
1052
1063
|
runOnEndCallbacks,
|
|
1053
1064
|
pluginRefs
|
|
@@ -1109,7 +1120,7 @@ function createChannel(streamIn) {
|
|
|
1109
1120
|
warnings: replaceDetailsInMessages(response.warnings, details)
|
|
1110
1121
|
};
|
|
1111
1122
|
copyResponseToResult(response, result);
|
|
1112
|
-
runOnEndCallbacks(result, () => {
|
|
1123
|
+
runOnEndCallbacks(result, logPluginError, () => {
|
|
1113
1124
|
if (result.errors.length > 0) {
|
|
1114
1125
|
return callback2(failureErrorWithLog("Build failed", result.errors, result.warnings), null);
|
|
1115
1126
|
}
|
|
@@ -1168,13 +1179,13 @@ function createChannel(streamIn) {
|
|
|
1168
1179
|
errors: replaceDetailsInMessages(watchResponse.errors, details),
|
|
1169
1180
|
warnings: replaceDetailsInMessages(watchResponse.warnings, details)
|
|
1170
1181
|
};
|
|
1171
|
-
|
|
1182
|
+
copyResponseToResult(watchResponse, result2);
|
|
1183
|
+
runOnEndCallbacks(result2, logPluginError, () => {
|
|
1172
1184
|
if (result2.errors.length > 0) {
|
|
1173
1185
|
if (watch.onRebuild)
|
|
1174
1186
|
watch.onRebuild(failureErrorWithLog("Build failed", result2.errors, result2.warnings), null);
|
|
1175
1187
|
return;
|
|
1176
1188
|
}
|
|
1177
|
-
copyResponseToResult(watchResponse, result2);
|
|
1178
1189
|
if (watchResponse.rebuildID !== void 0)
|
|
1179
1190
|
result2.rebuild = rebuild;
|
|
1180
1191
|
result2.stop = stop;
|
|
@@ -1538,6 +1549,11 @@ var esbuildCommandAndArgs = () => {
|
|
|
1538
1549
|
if (process.env.ESBUILD_BINARY_PATH) {
|
|
1539
1550
|
return [path.resolve(process.env.ESBUILD_BINARY_PATH), []];
|
|
1540
1551
|
}
|
|
1552
|
+
if (path.basename(__filename) !== "main.js" || path.basename(__dirname) !== "lib") {
|
|
1553
|
+
throw new Error(`The esbuild JavaScript API cannot be bundled. Please mark the "esbuild" package as external so it's not included in the bundle.
|
|
1554
|
+
|
|
1555
|
+
More information: The file containing the code for esbuild's JavaScript API (${__filename}) does not appear to be inside the esbuild package on the file system, which usually means that the esbuild package was bundled into another file. This is problematic because the API needs to run a binary executable inside the esbuild package which is located using a relative path from the API code to the executable. If the esbuild package is bundled, the relative path will be incorrect and the executable won't be found.`);
|
|
1556
|
+
}
|
|
1541
1557
|
if (false) {
|
|
1542
1558
|
return ["node", [path.join(__dirname, "..", "bin", "esbuild")]];
|
|
1543
1559
|
}
|
|
@@ -1597,7 +1613,7 @@ var fsAsync = {
|
|
|
1597
1613
|
}
|
|
1598
1614
|
}
|
|
1599
1615
|
};
|
|
1600
|
-
var version = "0.11.
|
|
1616
|
+
var version = "0.11.20";
|
|
1601
1617
|
var build = (options) => ensureServiceIsRunning().build(options);
|
|
1602
1618
|
var serve = (serveOptions, buildOptions) => ensureServiceIsRunning().serve(serveOptions, buildOptions);
|
|
1603
1619
|
var transform = (input, options) => ensureServiceIsRunning().transform(input, options);
|
|
@@ -1685,7 +1701,7 @@ var ensureServiceIsRunning = () => {
|
|
|
1685
1701
|
if (longLivedService)
|
|
1686
1702
|
return longLivedService;
|
|
1687
1703
|
let [command, args] = esbuildCommandAndArgs();
|
|
1688
|
-
let child = child_process.spawn(command, args.concat(`--service=${"0.11.
|
|
1704
|
+
let child = child_process.spawn(command, args.concat(`--service=${"0.11.20"}`, "--ping"), {
|
|
1689
1705
|
windowsHide: true,
|
|
1690
1706
|
stdio: ["pipe", "pipe", "inherit"],
|
|
1691
1707
|
cwd: defaultWD
|
|
@@ -1783,7 +1799,7 @@ var runServiceSync = (callback) => {
|
|
|
1783
1799
|
isBrowser: false
|
|
1784
1800
|
});
|
|
1785
1801
|
callback(service);
|
|
1786
|
-
let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.11.
|
|
1802
|
+
let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.11.20"}`), {
|
|
1787
1803
|
cwd: defaultWD,
|
|
1788
1804
|
windowsHide: true,
|
|
1789
1805
|
input: stdin,
|