esbuild 0.16.17 → 0.17.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/bin/esbuild +1 -1
- package/install.js +4 -4
- package/lib/main.d.ts +36 -42
- package/lib/main.js +251 -280
- package/package.json +23 -23
package/bin/esbuild
CHANGED
|
@@ -198,7 +198,7 @@ for your current platform.`);
|
|
|
198
198
|
"node_modules",
|
|
199
199
|
".cache",
|
|
200
200
|
"esbuild",
|
|
201
|
-
`pnpapi-${pkg.replace("/", "-")}-${"0.
|
|
201
|
+
`pnpapi-${pkg.replace("/", "-")}-${"0.17.0"}-${path.basename(subpath)}`
|
|
202
202
|
);
|
|
203
203
|
if (!fs.existsSync(binTargetPath)) {
|
|
204
204
|
fs.mkdirSync(path.dirname(binTargetPath), { recursive: true });
|
package/install.js
CHANGED
|
@@ -126,8 +126,8 @@ which means the "esbuild" binary executable can't be run. You can either:
|
|
|
126
126
|
}
|
|
127
127
|
throw err;
|
|
128
128
|
}
|
|
129
|
-
if (stdout !== "0.
|
|
130
|
-
throw new Error(`Expected ${JSON.stringify("0.
|
|
129
|
+
if (stdout !== "0.17.0") {
|
|
130
|
+
throw new Error(`Expected ${JSON.stringify("0.17.0")} but got ${JSON.stringify(stdout)}`);
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
function isYarn() {
|
|
@@ -179,7 +179,7 @@ function installUsingNPM(pkg, subpath, binPath) {
|
|
|
179
179
|
try {
|
|
180
180
|
fs2.writeFileSync(path2.join(installDir, "package.json"), "{}");
|
|
181
181
|
child_process.execSync(
|
|
182
|
-
`npm install --loglevel=error --prefer-offline --no-audit --progress=false ${pkg}@${"0.
|
|
182
|
+
`npm install --loglevel=error --prefer-offline --no-audit --progress=false ${pkg}@${"0.17.0"}`,
|
|
183
183
|
{ cwd: installDir, stdio: "pipe", env }
|
|
184
184
|
);
|
|
185
185
|
const installedBinPath = path2.join(installDir, "node_modules", pkg, subpath);
|
|
@@ -230,7 +230,7 @@ function maybeOptimizePackage(binPath) {
|
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
async function downloadDirectlyFromNPM(pkg, subpath, binPath) {
|
|
233
|
-
const url = `https://registry.npmjs.org/${pkg}/-/${pkg.replace("@esbuild/", "")}-${"0.
|
|
233
|
+
const url = `https://registry.npmjs.org/${pkg}/-/${pkg.replace("@esbuild/", "")}-${"0.17.0"}.tgz`;
|
|
234
234
|
console.error(`[esbuild] Trying to download ${JSON.stringify(url)}`);
|
|
235
235
|
try {
|
|
236
236
|
fs2.writeFileSync(binPath, extractFileFromTarGzip(await fetch(url), subpath));
|
package/lib/main.d.ts
CHANGED
|
@@ -132,8 +132,6 @@ export interface BuildOptions extends CommonOptions {
|
|
|
132
132
|
banner?: { [type: string]: string };
|
|
133
133
|
/** Documentation: https://esbuild.github.io/api/#footer */
|
|
134
134
|
footer?: { [type: string]: string };
|
|
135
|
-
/** Documentation: https://esbuild.github.io/api/#incremental */
|
|
136
|
-
incremental?: boolean;
|
|
137
135
|
/** Documentation: https://esbuild.github.io/api/#entry-points */
|
|
138
136
|
entryPoints?: string[] | Record<string, string>;
|
|
139
137
|
/** Documentation: https://esbuild.github.io/api/#stdin */
|
|
@@ -144,12 +142,6 @@ export interface BuildOptions extends CommonOptions {
|
|
|
144
142
|
absWorkingDir?: string;
|
|
145
143
|
/** Documentation: https://esbuild.github.io/api/#node-paths */
|
|
146
144
|
nodePaths?: string[]; // The "NODE_PATH" variable from Node.js
|
|
147
|
-
/** Documentation: https://esbuild.github.io/api/#watch */
|
|
148
|
-
watch?: boolean | WatchMode;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
export interface WatchMode {
|
|
152
|
-
onRebuild?: (error: BuildFailure | null, result: BuildResult | null) => void;
|
|
153
145
|
}
|
|
154
146
|
|
|
155
147
|
export interface StdinOptions {
|
|
@@ -199,28 +191,15 @@ export interface OutputFile {
|
|
|
199
191
|
readonly text: string;
|
|
200
192
|
}
|
|
201
193
|
|
|
202
|
-
export interface
|
|
203
|
-
(): Promise<BuildIncremental>;
|
|
204
|
-
dispose(): void;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
export interface BuildIncremental extends BuildResult {
|
|
208
|
-
rebuild: BuildInvalidate;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
export interface BuildResult {
|
|
194
|
+
export interface BuildResult<SpecificOptions extends BuildOptions = BuildOptions> {
|
|
212
195
|
errors: Message[];
|
|
213
196
|
warnings: Message[];
|
|
214
197
|
/** Only when "write: false" */
|
|
215
|
-
outputFiles
|
|
216
|
-
/** Only when "incremental: true" */
|
|
217
|
-
rebuild?: BuildInvalidate;
|
|
218
|
-
/** Only when "watch: true" */
|
|
219
|
-
stop?: () => void;
|
|
198
|
+
outputFiles: OutputFile[] | (SpecificOptions['write'] extends false ? never : undefined);
|
|
220
199
|
/** Only when "metafile: true" */
|
|
221
|
-
metafile
|
|
200
|
+
metafile: Metafile | (SpecificOptions['metafile'] extends true ? never : undefined);
|
|
222
201
|
/** Only when "mangleCache" is present */
|
|
223
|
-
mangleCache
|
|
202
|
+
mangleCache: Record<string, string | false> | (SpecificOptions['mangleCache'] extends Object ? never : undefined);
|
|
224
203
|
}
|
|
225
204
|
|
|
226
205
|
export interface BuildFailure extends Error {
|
|
@@ -233,6 +212,8 @@ export interface ServeOptions {
|
|
|
233
212
|
port?: number;
|
|
234
213
|
host?: string;
|
|
235
214
|
servedir?: string;
|
|
215
|
+
keyfile?: string
|
|
216
|
+
certfile?: string
|
|
236
217
|
onRequest?: (args: ServeOnRequestArgs) => void;
|
|
237
218
|
}
|
|
238
219
|
|
|
@@ -249,8 +230,6 @@ export interface ServeOnRequestArgs {
|
|
|
249
230
|
export interface ServeResult {
|
|
250
231
|
port: number;
|
|
251
232
|
host: string;
|
|
252
|
-
wait: Promise<void>;
|
|
253
|
-
stop: () => void;
|
|
254
233
|
}
|
|
255
234
|
|
|
256
235
|
export interface TransformOptions extends CommonOptions {
|
|
@@ -274,14 +253,14 @@ export interface TransformOptions extends CommonOptions {
|
|
|
274
253
|
footer?: string;
|
|
275
254
|
}
|
|
276
255
|
|
|
277
|
-
export interface TransformResult {
|
|
256
|
+
export interface TransformResult<SpecificOptions extends TransformOptions = TransformOptions> {
|
|
278
257
|
code: string;
|
|
279
258
|
map: string;
|
|
280
259
|
warnings: Message[];
|
|
281
260
|
/** Only when "mangleCache" is present */
|
|
282
|
-
mangleCache
|
|
261
|
+
mangleCache: Record<string, string | false> | (SpecificOptions['mangleCache'] extends Object ? never : undefined);
|
|
283
262
|
/** Only when "legalComments" is "external" */
|
|
284
|
-
legalComments
|
|
263
|
+
legalComments: string | (SpecificOptions['legalComments'] extends 'external' ? never : undefined);
|
|
285
264
|
}
|
|
286
265
|
|
|
287
266
|
export interface TransformFailure extends Error {
|
|
@@ -301,7 +280,7 @@ export interface PluginBuild {
|
|
|
301
280
|
onStart(callback: () =>
|
|
302
281
|
(OnStartResult | null | void | Promise<OnStartResult | null | void>)): void;
|
|
303
282
|
onEnd(callback: (result: BuildResult) =>
|
|
304
|
-
(void | Promise<void>)): void;
|
|
283
|
+
(OnEndResult | null | void | Promise<OnEndResult | null | void>)): void;
|
|
305
284
|
onResolve(options: OnResolveOptions, callback: (args: OnResolveArgs) =>
|
|
306
285
|
(OnResolveResult | null | undefined | Promise<OnResolveResult | null | undefined>)): void;
|
|
307
286
|
onLoad(options: OnLoadOptions, callback: (args: OnLoadArgs) =>
|
|
@@ -309,7 +288,7 @@ export interface PluginBuild {
|
|
|
309
288
|
|
|
310
289
|
// This is a full copy of the esbuild library in case you need it
|
|
311
290
|
esbuild: {
|
|
312
|
-
|
|
291
|
+
context: typeof context,
|
|
313
292
|
build: typeof build,
|
|
314
293
|
buildSync: typeof buildSync,
|
|
315
294
|
transform: typeof transform,
|
|
@@ -349,6 +328,11 @@ export interface OnStartResult {
|
|
|
349
328
|
warnings?: PartialMessage[];
|
|
350
329
|
}
|
|
351
330
|
|
|
331
|
+
export interface OnEndResult {
|
|
332
|
+
errors?: PartialMessage[];
|
|
333
|
+
warnings?: PartialMessage[];
|
|
334
|
+
}
|
|
335
|
+
|
|
352
336
|
export interface OnResolveOptions {
|
|
353
337
|
filter: RegExp;
|
|
354
338
|
namespace?: string;
|
|
@@ -478,6 +462,16 @@ export interface AnalyzeMetafileOptions {
|
|
|
478
462
|
verbose?: boolean;
|
|
479
463
|
}
|
|
480
464
|
|
|
465
|
+
export interface WatchOptions {
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
export interface BuildContext<SpecificOptions extends BuildOptions = BuildOptions> {
|
|
469
|
+
rebuild(): Promise<BuildResult<SpecificOptions>>
|
|
470
|
+
watch(options?: WatchOptions): void
|
|
471
|
+
serve(options?: ServeOptions): Promise<ServeResult>
|
|
472
|
+
dispose(): Promise<void>
|
|
473
|
+
}
|
|
474
|
+
|
|
481
475
|
/**
|
|
482
476
|
* This function invokes the "esbuild" command-line tool for you. It returns a
|
|
483
477
|
* promise that either resolves with a "BuildResult" object or rejects with a
|
|
@@ -488,22 +482,20 @@ export interface AnalyzeMetafileOptions {
|
|
|
488
482
|
*
|
|
489
483
|
* Documentation: https://esbuild.github.io/api/#build-api
|
|
490
484
|
*/
|
|
491
|
-
export declare function build(options:
|
|
492
|
-
export declare function build(options: BuildOptions & { incremental: true, metafile: true }): Promise<BuildIncremental & { metafile: Metafile }>;
|
|
493
|
-
export declare function build(options: BuildOptions & { incremental: true }): Promise<BuildIncremental>;
|
|
494
|
-
export declare function build(options: BuildOptions & { metafile: true }): Promise<BuildResult & { metafile: Metafile }>;
|
|
485
|
+
export declare function build<SpecificOptions extends BuildOptions>(options: SpecificOptions): Promise<BuildResult<SpecificOptions>>;
|
|
495
486
|
export declare function build(options: BuildOptions): Promise<BuildResult>;
|
|
496
487
|
|
|
497
488
|
/**
|
|
498
|
-
* This
|
|
499
|
-
*
|
|
489
|
+
* This is the advanced long-running form of "build" that supports additional
|
|
490
|
+
* features such as watch mode and a local development server.
|
|
500
491
|
*
|
|
501
492
|
* - Works in node: yes
|
|
502
493
|
* - Works in browser: no
|
|
503
494
|
*
|
|
504
|
-
* Documentation: https://esbuild.github.io/api/#
|
|
495
|
+
* Documentation: https://esbuild.github.io/api/#context-api
|
|
505
496
|
*/
|
|
506
|
-
export declare function
|
|
497
|
+
export declare function context<T extends BuildOptions>(options: T): Promise<BuildContext<T>>;
|
|
498
|
+
export declare function context(options: BuildOptions): Promise<BuildContext>;
|
|
507
499
|
|
|
508
500
|
/**
|
|
509
501
|
* This function transforms a single JavaScript file. It can be used to minify
|
|
@@ -516,6 +508,7 @@ export declare function serve(serveOptions: ServeOptions, buildOptions: BuildOpt
|
|
|
516
508
|
*
|
|
517
509
|
* Documentation: https://esbuild.github.io/api/#transform-api
|
|
518
510
|
*/
|
|
511
|
+
export declare function transform<SpecificOptions extends TransformOptions>(input: string | Uint8Array, options?: SpecificOptions): Promise<TransformResult<SpecificOptions>>;
|
|
519
512
|
export declare function transform(input: string | Uint8Array, options?: TransformOptions): Promise<TransformResult>;
|
|
520
513
|
|
|
521
514
|
/**
|
|
@@ -548,7 +541,7 @@ export declare function analyzeMetafile(metafile: Metafile | string, options?: A
|
|
|
548
541
|
*
|
|
549
542
|
* Documentation: https://esbuild.github.io/api/#build-api
|
|
550
543
|
*/
|
|
551
|
-
export declare function buildSync(options:
|
|
544
|
+
export declare function buildSync<SpecificOptions extends BuildOptions>(options: SpecificOptions): BuildResult<SpecificOptions>;
|
|
552
545
|
export declare function buildSync(options: BuildOptions): BuildResult;
|
|
553
546
|
|
|
554
547
|
/**
|
|
@@ -559,7 +552,8 @@ export declare function buildSync(options: BuildOptions): BuildResult;
|
|
|
559
552
|
*
|
|
560
553
|
* Documentation: https://esbuild.github.io/api/#transform-api
|
|
561
554
|
*/
|
|
562
|
-
export declare function transformSync(input: string, options?:
|
|
555
|
+
export declare function transformSync<SpecificOptions extends TransformOptions>(input: string, options?: SpecificOptions): TransformResult<SpecificOptions>;
|
|
556
|
+
export declare function transformSync(input: string | Uint8Array, options?: TransformOptions): TransformResult;
|
|
563
557
|
|
|
564
558
|
/**
|
|
565
559
|
* A synchronous version of "formatMessages".
|
package/lib/main.js
CHANGED
|
@@ -34,11 +34,11 @@ __export(node_exports, {
|
|
|
34
34
|
analyzeMetafileSync: () => analyzeMetafileSync,
|
|
35
35
|
build: () => build,
|
|
36
36
|
buildSync: () => buildSync,
|
|
37
|
+
context: () => context,
|
|
37
38
|
default: () => node_default,
|
|
38
39
|
formatMessages: () => formatMessages,
|
|
39
40
|
formatMessagesSync: () => formatMessagesSync,
|
|
40
41
|
initialize: () => initialize,
|
|
41
|
-
serve: () => serve,
|
|
42
42
|
transform: () => transform,
|
|
43
43
|
transformSync: () => transformSync,
|
|
44
44
|
version: () => version
|
|
@@ -225,7 +225,6 @@ function validateTarget(target) {
|
|
|
225
225
|
}
|
|
226
226
|
var canBeAnything = () => null;
|
|
227
227
|
var mustBeBoolean = (value) => typeof value === "boolean" ? null : "a boolean";
|
|
228
|
-
var mustBeBooleanOrObject = (value) => typeof value === "boolean" || typeof value === "object" && !Array.isArray(value) ? null : "a boolean or an object";
|
|
229
228
|
var mustBeString = (value) => typeof value === "string" ? null : "a string";
|
|
230
229
|
var mustBeRegExp = (value) => value instanceof RegExp ? null : "a RegExp object";
|
|
231
230
|
var mustBeInteger = (value) => typeof value === "number" && value === (value | 0) ? null : "an integer";
|
|
@@ -421,12 +420,10 @@ function flagsForBuildOptions(callName, options, isTTY2, logLevelDefault, writeD
|
|
|
421
420
|
let keys = /* @__PURE__ */ Object.create(null);
|
|
422
421
|
let stdinContents = null;
|
|
423
422
|
let stdinResolveDir = null;
|
|
424
|
-
let watchMode = null;
|
|
425
423
|
pushLogFlags(flags, options, keys, isTTY2, logLevelDefault);
|
|
426
424
|
pushCommonFlags(flags, options, keys);
|
|
427
425
|
let sourcemap = getFlag(options, keys, "sourcemap", mustBeStringOrBoolean);
|
|
428
426
|
let bundle = getFlag(options, keys, "bundle", mustBeBoolean);
|
|
429
|
-
let watch = getFlag(options, keys, "watch", mustBeBooleanOrObject);
|
|
430
427
|
let splitting = getFlag(options, keys, "splitting", mustBeBoolean);
|
|
431
428
|
let preserveSymlinks = getFlag(options, keys, "preserveSymlinks", mustBeBoolean);
|
|
432
429
|
let metafile = getFlag(options, keys, "metafile", mustBeBoolean);
|
|
@@ -455,7 +452,6 @@ function flagsForBuildOptions(callName, options, isTTY2, logLevelDefault, writeD
|
|
|
455
452
|
let stdin = getFlag(options, keys, "stdin", mustBeObject);
|
|
456
453
|
let write = (_a2 = getFlag(options, keys, "write", mustBeBoolean)) != null ? _a2 : writeDefault;
|
|
457
454
|
let allowOverwrite = getFlag(options, keys, "allowOverwrite", mustBeBoolean);
|
|
458
|
-
let incremental = getFlag(options, keys, "incremental", mustBeBoolean) === true;
|
|
459
455
|
let mangleCache = getFlag(options, keys, "mangleCache", mustBeObject);
|
|
460
456
|
keys.plugins = true;
|
|
461
457
|
checkForInvalidFlags(options, keys, `in ${callName}() call`);
|
|
@@ -465,17 +461,6 @@ function flagsForBuildOptions(callName, options, isTTY2, logLevelDefault, writeD
|
|
|
465
461
|
flags.push("--bundle");
|
|
466
462
|
if (allowOverwrite)
|
|
467
463
|
flags.push("--allow-overwrite");
|
|
468
|
-
if (watch) {
|
|
469
|
-
flags.push("--watch");
|
|
470
|
-
if (typeof watch === "boolean") {
|
|
471
|
-
watchMode = {};
|
|
472
|
-
} else {
|
|
473
|
-
let watchKeys = /* @__PURE__ */ Object.create(null);
|
|
474
|
-
let onRebuild = getFlag(watch, watchKeys, "onRebuild", mustBeFunction);
|
|
475
|
-
checkForInvalidFlags(watch, watchKeys, `on "watch" in ${callName}() call`);
|
|
476
|
-
watchMode = { onRebuild };
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
464
|
if (splitting)
|
|
480
465
|
flags.push("--splitting");
|
|
481
466
|
if (preserveSymlinks)
|
|
@@ -614,9 +599,7 @@ function flagsForBuildOptions(callName, options, isTTY2, logLevelDefault, writeD
|
|
|
614
599
|
stdinContents,
|
|
615
600
|
stdinResolveDir,
|
|
616
601
|
absWorkingDir,
|
|
617
|
-
incremental,
|
|
618
602
|
nodePaths,
|
|
619
|
-
watch: watchMode,
|
|
620
603
|
mangleCache: validateMangleCache(mangleCache)
|
|
621
604
|
};
|
|
622
605
|
}
|
|
@@ -739,8 +722,8 @@ function createChannel(streamIn) {
|
|
|
739
722
|
if (isFirstPacket) {
|
|
740
723
|
isFirstPacket = false;
|
|
741
724
|
let binaryVersion = String.fromCharCode(...bytes);
|
|
742
|
-
if (binaryVersion !== "0.
|
|
743
|
-
throw new Error(`Cannot start service: Host version "${"0.
|
|
725
|
+
if (binaryVersion !== "0.17.0") {
|
|
726
|
+
throw new Error(`Cannot start service: Host version "${"0.17.0"}" does not match binary version ${quote(binaryVersion)}`);
|
|
744
727
|
}
|
|
745
728
|
return;
|
|
746
729
|
}
|
|
@@ -756,7 +739,7 @@ function createChannel(streamIn) {
|
|
|
756
739
|
callback(null, packet.value);
|
|
757
740
|
}
|
|
758
741
|
};
|
|
759
|
-
let
|
|
742
|
+
let buildOrContext = ({ callName, refs, options, isTTY: isTTY2, defaultWD: defaultWD2, callback }) => {
|
|
760
743
|
let refCount = 0;
|
|
761
744
|
const buildKey = nextBuildKey++;
|
|
762
745
|
const requestCallbacks = {};
|
|
@@ -777,7 +760,7 @@ function createChannel(streamIn) {
|
|
|
777
760
|
};
|
|
778
761
|
requestCallbacksByKey[buildKey] = requestCallbacks;
|
|
779
762
|
buildRefs.ref();
|
|
780
|
-
|
|
763
|
+
buildOrContextImpl(
|
|
781
764
|
callName,
|
|
782
765
|
buildKey,
|
|
783
766
|
sendRequest,
|
|
@@ -786,10 +769,8 @@ function createChannel(streamIn) {
|
|
|
786
769
|
streamIn,
|
|
787
770
|
requestCallbacks,
|
|
788
771
|
options,
|
|
789
|
-
serveOptions,
|
|
790
772
|
isTTY2,
|
|
791
773
|
defaultWD2,
|
|
792
|
-
closeData,
|
|
793
774
|
(err, res) => {
|
|
794
775
|
try {
|
|
795
776
|
callback(err, res);
|
|
@@ -825,7 +806,13 @@ function createChannel(streamIn) {
|
|
|
825
806
|
let outstanding = 1;
|
|
826
807
|
let next = () => {
|
|
827
808
|
if (--outstanding === 0) {
|
|
828
|
-
let result = {
|
|
809
|
+
let result = {
|
|
810
|
+
warnings,
|
|
811
|
+
code: response.code,
|
|
812
|
+
map: response.map,
|
|
813
|
+
mangleCache: void 0,
|
|
814
|
+
legalComments: void 0
|
|
815
|
+
};
|
|
829
816
|
if ("legalComments" in response)
|
|
830
817
|
result.legalComments = response == null ? void 0 : response.legalComments;
|
|
831
818
|
if (response.mangleCache)
|
|
@@ -931,30 +918,26 @@ function createChannel(streamIn) {
|
|
|
931
918
|
readFromStdout,
|
|
932
919
|
afterClose,
|
|
933
920
|
service: {
|
|
934
|
-
|
|
921
|
+
buildOrContext,
|
|
935
922
|
transform: transform2,
|
|
936
923
|
formatMessages: formatMessages2,
|
|
937
924
|
analyzeMetafile: analyzeMetafile2
|
|
938
925
|
}
|
|
939
926
|
};
|
|
940
927
|
}
|
|
941
|
-
function
|
|
928
|
+
function buildOrContextImpl(callName, buildKey, sendRequest, sendResponse, refs, streamIn, requestCallbacks, options, isTTY2, defaultWD2, callback) {
|
|
942
929
|
const details = createObjectStash();
|
|
943
|
-
const
|
|
930
|
+
const isContext = callName === "context";
|
|
931
|
+
const handleError = (e, pluginName) => {
|
|
944
932
|
const flags = [];
|
|
945
933
|
try {
|
|
946
934
|
pushLogFlags(flags, options, {}, isTTY2, buildLogLevelDefault);
|
|
947
935
|
} catch {
|
|
948
936
|
}
|
|
949
|
-
const message = extractErrorMessageV8(e, streamIn, details,
|
|
937
|
+
const message = extractErrorMessageV8(e, streamIn, details, void 0, pluginName);
|
|
950
938
|
sendRequest(refs, { command: "error", flags, error: message }, () => {
|
|
951
939
|
message.detail = details.load(message.detail);
|
|
952
|
-
|
|
953
|
-
});
|
|
954
|
-
};
|
|
955
|
-
const handleError = (e, pluginName) => {
|
|
956
|
-
logPluginError(e, pluginName, void 0, (error) => {
|
|
957
|
-
callback(failureErrorWithLog("Build failed", [error], []), null);
|
|
940
|
+
callback(failureErrorWithLog(isContext ? "Context failed" : "Build failed", [message], []), null);
|
|
958
941
|
});
|
|
959
942
|
};
|
|
960
943
|
let plugins;
|
|
@@ -962,15 +945,13 @@ function buildOrServeImpl(callName, buildKey, sendRequest, sendResponse, refs, s
|
|
|
962
945
|
const value = options.plugins;
|
|
963
946
|
if (value !== void 0) {
|
|
964
947
|
if (!Array.isArray(value))
|
|
965
|
-
|
|
948
|
+
return handleError(new Error(`"plugins" must be an array`), "");
|
|
966
949
|
plugins = value;
|
|
967
950
|
}
|
|
968
951
|
}
|
|
969
952
|
if (plugins && plugins.length > 0) {
|
|
970
|
-
if (streamIn.isSync)
|
|
971
|
-
handleError(new Error("Cannot use plugins in synchronous API calls"), "");
|
|
972
|
-
return;
|
|
973
|
-
}
|
|
953
|
+
if (streamIn.isSync)
|
|
954
|
+
return handleError(new Error("Cannot use plugins in synchronous API calls"), "");
|
|
974
955
|
handlePlugins(
|
|
975
956
|
buildKey,
|
|
976
957
|
sendRequest,
|
|
@@ -983,12 +964,10 @@ function buildOrServeImpl(callName, buildKey, sendRequest, sendResponse, refs, s
|
|
|
983
964
|
details
|
|
984
965
|
).then(
|
|
985
966
|
(result) => {
|
|
986
|
-
if (!result.ok)
|
|
987
|
-
handleError(result.error, result.pluginName);
|
|
988
|
-
return;
|
|
989
|
-
}
|
|
967
|
+
if (!result.ok)
|
|
968
|
+
return handleError(result.error, result.pluginName);
|
|
990
969
|
try {
|
|
991
|
-
|
|
970
|
+
buildOrContextContinue(result.requestPlugins, result.runOnEndCallbacks);
|
|
992
971
|
} catch (e) {
|
|
993
972
|
handleError(e, "");
|
|
994
973
|
}
|
|
@@ -998,25 +977,25 @@ function buildOrServeImpl(callName, buildKey, sendRequest, sendResponse, refs, s
|
|
|
998
977
|
return;
|
|
999
978
|
}
|
|
1000
979
|
try {
|
|
1001
|
-
|
|
980
|
+
buildOrContextContinue(null, (result, done) => done([], []));
|
|
1002
981
|
} catch (e) {
|
|
1003
982
|
handleError(e, "");
|
|
1004
983
|
}
|
|
1005
|
-
function
|
|
1006
|
-
|
|
1007
|
-
|
|
984
|
+
function buildOrContextContinue(requestPlugins, runOnEndCallbacks) {
|
|
985
|
+
const writeDefault = streamIn.hasFS;
|
|
986
|
+
const {
|
|
1008
987
|
entries,
|
|
1009
988
|
flags,
|
|
1010
989
|
write,
|
|
1011
990
|
stdinContents,
|
|
1012
991
|
stdinResolveDir,
|
|
1013
992
|
absWorkingDir,
|
|
1014
|
-
incremental,
|
|
1015
993
|
nodePaths,
|
|
1016
|
-
watch,
|
|
1017
994
|
mangleCache
|
|
1018
995
|
} = flagsForBuildOptions(callName, options, isTTY2, buildLogLevelDefault, writeDefault);
|
|
1019
|
-
|
|
996
|
+
if (write && !streamIn.hasFS)
|
|
997
|
+
throw new Error(`The "write" option is unavailable in this environment`);
|
|
998
|
+
const request = {
|
|
1020
999
|
command: "build",
|
|
1021
1000
|
key: buildKey,
|
|
1022
1001
|
entries,
|
|
@@ -1025,17 +1004,23 @@ function buildOrServeImpl(callName, buildKey, sendRequest, sendResponse, refs, s
|
|
|
1025
1004
|
stdinContents,
|
|
1026
1005
|
stdinResolveDir,
|
|
1027
1006
|
absWorkingDir: absWorkingDir || defaultWD2,
|
|
1028
|
-
|
|
1029
|
-
|
|
1007
|
+
nodePaths,
|
|
1008
|
+
context: isContext
|
|
1030
1009
|
};
|
|
1031
1010
|
if (requestPlugins)
|
|
1032
1011
|
request.plugins = requestPlugins;
|
|
1033
1012
|
if (mangleCache)
|
|
1034
1013
|
request.mangleCache = mangleCache;
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1014
|
+
const buildResponseToResult = (response, callback2) => {
|
|
1015
|
+
const result = {
|
|
1016
|
+
errors: replaceDetailsInMessages(response.errors, details),
|
|
1017
|
+
warnings: replaceDetailsInMessages(response.warnings, details),
|
|
1018
|
+
outputFiles: void 0,
|
|
1019
|
+
metafile: void 0,
|
|
1020
|
+
mangleCache: void 0
|
|
1021
|
+
};
|
|
1022
|
+
const originalErrors = result.errors.slice();
|
|
1023
|
+
const originalWarnings = result.warnings.slice();
|
|
1039
1024
|
if (response.outputFiles)
|
|
1040
1025
|
result.outputFiles = response.outputFiles.map(convertOutputFiles);
|
|
1041
1026
|
if (response.metafile)
|
|
@@ -1044,165 +1029,141 @@ function buildOrServeImpl(callName, buildKey, sendRequest, sendResponse, refs, s
|
|
|
1044
1029
|
result.mangleCache = response.mangleCache;
|
|
1045
1030
|
if (response.writeToStdout !== void 0)
|
|
1046
1031
|
console.log(decodeUTF8(response.writeToStdout).replace(/\n$/, ""));
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
warnings: replaceDetailsInMessages(response.warnings, details)
|
|
1052
|
-
};
|
|
1053
|
-
copyResponseToResult(response, result);
|
|
1054
|
-
runOnEndCallbacks(result, logPluginError, () => {
|
|
1055
|
-
if (result.errors.length > 0) {
|
|
1056
|
-
return callback2(failureErrorWithLog("Build failed", result.errors, result.warnings), null);
|
|
1032
|
+
runOnEndCallbacks(result, (onEndErrors, onEndWarnings) => {
|
|
1033
|
+
if (originalErrors.length > 0 || onEndErrors.length > 0) {
|
|
1034
|
+
const error = failureErrorWithLog("Build failed", originalErrors.concat(onEndErrors), originalWarnings.concat(onEndWarnings));
|
|
1035
|
+
return callback2(error, null, onEndErrors, onEndWarnings);
|
|
1057
1036
|
}
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1037
|
+
callback2(null, result, onEndErrors, onEndWarnings);
|
|
1038
|
+
});
|
|
1039
|
+
};
|
|
1040
|
+
let latestResultPromise;
|
|
1041
|
+
let provideLatestResult;
|
|
1042
|
+
if (isContext)
|
|
1043
|
+
requestCallbacks["on-end"] = (id, request2) => new Promise((resolve) => {
|
|
1044
|
+
buildResponseToResult(request2, (err, result, onEndErrors, onEndWarnings) => {
|
|
1045
|
+
const response = {
|
|
1046
|
+
errors: onEndErrors,
|
|
1047
|
+
warnings: onEndWarnings
|
|
1048
|
+
};
|
|
1049
|
+
if (provideLatestResult)
|
|
1050
|
+
provideLatestResult(err, result);
|
|
1051
|
+
latestResultPromise = void 0;
|
|
1052
|
+
provideLatestResult = void 0;
|
|
1053
|
+
sendResponse(id, response);
|
|
1054
|
+
resolve();
|
|
1055
|
+
});
|
|
1056
|
+
});
|
|
1057
|
+
sendRequest(refs, request, (error, response) => {
|
|
1058
|
+
if (error)
|
|
1059
|
+
return callback(new Error(error), null);
|
|
1060
|
+
if (!isContext) {
|
|
1061
|
+
return buildResponseToResult(response, callback);
|
|
1062
|
+
}
|
|
1063
|
+
if (response.errors.length > 0) {
|
|
1064
|
+
return callback(failureErrorWithLog("Context failed", response.errors, response.warnings), null);
|
|
1065
|
+
}
|
|
1066
|
+
let didDispose = false;
|
|
1067
|
+
const result = {
|
|
1068
|
+
rebuild: () => {
|
|
1069
|
+
if (!latestResultPromise)
|
|
1070
|
+
latestResultPromise = new Promise((resolve, reject) => {
|
|
1071
|
+
let settlePromise;
|
|
1072
|
+
provideLatestResult = (err, result2) => {
|
|
1073
|
+
if (!settlePromise)
|
|
1074
|
+
settlePromise = () => err ? reject(err) : resolve(result2);
|
|
1075
|
+
};
|
|
1076
|
+
const triggerAnotherBuild = () => {
|
|
1077
|
+
const request2 = {
|
|
1078
|
+
command: "rebuild",
|
|
1079
|
+
key: buildKey
|
|
1080
|
+
};
|
|
1081
|
+
sendRequest(refs, request2, (error2, response2) => {
|
|
1068
1082
|
if (error2) {
|
|
1069
|
-
|
|
1070
|
-
|
|
1083
|
+
reject(new Error(error2));
|
|
1084
|
+
} else if (settlePromise) {
|
|
1085
|
+
settlePromise();
|
|
1086
|
+
} else {
|
|
1087
|
+
triggerAnotherBuild();
|
|
1071
1088
|
}
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
else
|
|
1076
|
-
resolve(result3);
|
|
1077
|
-
});
|
|
1078
|
-
}
|
|
1079
|
-
);
|
|
1089
|
+
});
|
|
1090
|
+
};
|
|
1091
|
+
triggerAnotherBuild();
|
|
1080
1092
|
});
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1093
|
+
return latestResultPromise;
|
|
1094
|
+
},
|
|
1095
|
+
watch: (options2 = {}) => new Promise((resolve, reject) => {
|
|
1096
|
+
if (!streamIn.hasFS)
|
|
1097
|
+
throw new Error(`Cannot use the "watch" API in this environment`);
|
|
1098
|
+
const keys = {};
|
|
1099
|
+
checkForInvalidFlags(options2, keys, `in watch() call`);
|
|
1100
|
+
const request2 = {
|
|
1101
|
+
command: "watch",
|
|
1102
|
+
key: buildKey
|
|
1103
|
+
};
|
|
1104
|
+
sendRequest(refs, request2, (error2) => {
|
|
1105
|
+
if (error2)
|
|
1106
|
+
reject(new Error(error2));
|
|
1107
|
+
else
|
|
1108
|
+
resolve(void 0);
|
|
1109
|
+
});
|
|
1110
|
+
}),
|
|
1111
|
+
serve: (options2 = {}) => new Promise((resolve, reject) => {
|
|
1112
|
+
if (!streamIn.hasFS)
|
|
1113
|
+
throw new Error(`Cannot use the "serve" API in this environment`);
|
|
1114
|
+
const keys = {};
|
|
1115
|
+
const port = getFlag(options2, keys, "port", mustBeInteger);
|
|
1116
|
+
const host = getFlag(options2, keys, "host", mustBeString);
|
|
1117
|
+
const servedir = getFlag(options2, keys, "servedir", mustBeString);
|
|
1118
|
+
const keyfile = getFlag(options2, keys, "keyfile", mustBeString);
|
|
1119
|
+
const certfile = getFlag(options2, keys, "certfile", mustBeString);
|
|
1120
|
+
const onRequest = getFlag(options2, keys, "onRequest", mustBeFunction);
|
|
1121
|
+
checkForInvalidFlags(options2, keys, `in serve() call`);
|
|
1122
|
+
const request2 = {
|
|
1123
|
+
command: "serve",
|
|
1124
|
+
key: buildKey,
|
|
1125
|
+
onRequest: !!onRequest
|
|
1126
|
+
};
|
|
1127
|
+
if (port !== void 0)
|
|
1128
|
+
request2.port = port;
|
|
1129
|
+
if (host !== void 0)
|
|
1130
|
+
request2.host = host;
|
|
1131
|
+
if (servedir !== void 0)
|
|
1132
|
+
request2.servedir = servedir;
|
|
1133
|
+
if (keyfile !== void 0)
|
|
1134
|
+
request2.keyfile = keyfile;
|
|
1135
|
+
if (certfile !== void 0)
|
|
1136
|
+
request2.certfile = certfile;
|
|
1137
|
+
sendRequest(refs, request2, (error2, response2) => {
|
|
1138
|
+
if (error2)
|
|
1139
|
+
return reject(new Error(error2));
|
|
1140
|
+
if (onRequest) {
|
|
1141
|
+
requestCallbacks["serve-request"] = (id, request3) => {
|
|
1142
|
+
onRequest(request3.args);
|
|
1128
1143
|
sendResponse(id, {});
|
|
1129
1144
|
};
|
|
1130
1145
|
}
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
}
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
sendRequest(refs, request, (error, response) => {
|
|
1144
|
-
if (error)
|
|
1145
|
-
return callback(new Error(error), null);
|
|
1146
|
-
if (serve2) {
|
|
1147
|
-
let serveResponse = response;
|
|
1148
|
-
let isStopped = false;
|
|
1149
|
-
refs.ref();
|
|
1150
|
-
let result = {
|
|
1151
|
-
port: serveResponse.port,
|
|
1152
|
-
host: serveResponse.host,
|
|
1153
|
-
wait: serve2.wait,
|
|
1154
|
-
stop() {
|
|
1155
|
-
if (isStopped)
|
|
1156
|
-
return;
|
|
1157
|
-
isStopped = true;
|
|
1158
|
-
serve2.stop();
|
|
1146
|
+
resolve(response2);
|
|
1147
|
+
});
|
|
1148
|
+
}),
|
|
1149
|
+
dispose: () => new Promise((resolve) => {
|
|
1150
|
+
if (didDispose)
|
|
1151
|
+
return resolve();
|
|
1152
|
+
const request2 = {
|
|
1153
|
+
command: "dispose",
|
|
1154
|
+
key: buildKey
|
|
1155
|
+
};
|
|
1156
|
+
sendRequest(refs, request2, () => {
|
|
1157
|
+
resolve();
|
|
1159
1158
|
refs.unref();
|
|
1160
|
-
}
|
|
1161
|
-
}
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
}
|
|
1166
|
-
return buildResponseToResult(response, callback);
|
|
1159
|
+
});
|
|
1160
|
+
})
|
|
1161
|
+
};
|
|
1162
|
+
refs.ref();
|
|
1163
|
+
callback(null, result);
|
|
1167
1164
|
});
|
|
1168
1165
|
}
|
|
1169
1166
|
}
|
|
1170
|
-
var buildServeData = (buildKey, sendRequest, sendResponse, refs, requestCallbacks, options, request) => {
|
|
1171
|
-
let keys = {};
|
|
1172
|
-
let port = getFlag(options, keys, "port", mustBeInteger);
|
|
1173
|
-
let host = getFlag(options, keys, "host", mustBeString);
|
|
1174
|
-
let servedir = getFlag(options, keys, "servedir", mustBeString);
|
|
1175
|
-
let onRequest = getFlag(options, keys, "onRequest", mustBeFunction);
|
|
1176
|
-
let wait = new Promise((resolve, reject) => {
|
|
1177
|
-
requestCallbacks["serve-wait"] = (id, request2) => {
|
|
1178
|
-
if (request2.error !== null)
|
|
1179
|
-
reject(new Error(request2.error));
|
|
1180
|
-
else
|
|
1181
|
-
resolve();
|
|
1182
|
-
sendResponse(id, {});
|
|
1183
|
-
};
|
|
1184
|
-
});
|
|
1185
|
-
request.serve = {};
|
|
1186
|
-
checkForInvalidFlags(options, keys, `in serve() call`);
|
|
1187
|
-
if (port !== void 0)
|
|
1188
|
-
request.serve.port = port;
|
|
1189
|
-
if (host !== void 0)
|
|
1190
|
-
request.serve.host = host;
|
|
1191
|
-
if (servedir !== void 0)
|
|
1192
|
-
request.serve.servedir = servedir;
|
|
1193
|
-
requestCallbacks["serve-request"] = (id, request2) => {
|
|
1194
|
-
if (onRequest)
|
|
1195
|
-
onRequest(request2.args);
|
|
1196
|
-
sendResponse(id, {});
|
|
1197
|
-
};
|
|
1198
|
-
return {
|
|
1199
|
-
wait,
|
|
1200
|
-
stop() {
|
|
1201
|
-
sendRequest(refs, { command: "serve-stop", key: buildKey }, () => {
|
|
1202
|
-
});
|
|
1203
|
-
}
|
|
1204
|
-
};
|
|
1205
|
-
};
|
|
1206
1167
|
var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn, requestCallbacks, initialOptions, plugins, details) => {
|
|
1207
1168
|
let onStartCallbacks = [];
|
|
1208
1169
|
let onEndCallbacks = [];
|
|
@@ -1473,18 +1434,49 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
|
|
|
1473
1434
|
}
|
|
1474
1435
|
sendResponse(id, response);
|
|
1475
1436
|
};
|
|
1476
|
-
let runOnEndCallbacks = (result,
|
|
1437
|
+
let runOnEndCallbacks = (result, done) => done([], []);
|
|
1477
1438
|
if (onEndCallbacks.length > 0) {
|
|
1478
|
-
runOnEndCallbacks = (result,
|
|
1439
|
+
runOnEndCallbacks = (result, done) => {
|
|
1479
1440
|
(async () => {
|
|
1441
|
+
const onEndErrors = [];
|
|
1442
|
+
const onEndWarnings = [];
|
|
1480
1443
|
for (const { name, callback, note } of onEndCallbacks) {
|
|
1444
|
+
let newErrors;
|
|
1445
|
+
let newWarnings;
|
|
1481
1446
|
try {
|
|
1482
|
-
await callback(result);
|
|
1447
|
+
const value = await callback(result);
|
|
1448
|
+
if (value != null) {
|
|
1449
|
+
if (typeof value !== "object")
|
|
1450
|
+
throw new Error(`Expected onEnd() callback in plugin ${quote(name)} to return an object`);
|
|
1451
|
+
let keys = {};
|
|
1452
|
+
let errors = getFlag(value, keys, "errors", mustBeArray);
|
|
1453
|
+
let warnings = getFlag(value, keys, "warnings", mustBeArray);
|
|
1454
|
+
checkForInvalidFlags(value, keys, `from onEnd() callback in plugin ${quote(name)}`);
|
|
1455
|
+
if (errors != null)
|
|
1456
|
+
newErrors = sanitizeMessages(errors, "errors", details, name);
|
|
1457
|
+
if (warnings != null)
|
|
1458
|
+
newWarnings = sanitizeMessages(warnings, "warnings", details, name);
|
|
1459
|
+
}
|
|
1483
1460
|
} catch (e) {
|
|
1484
|
-
|
|
1461
|
+
newErrors = [extractErrorMessageV8(e, streamIn, details, note && note(), name)];
|
|
1462
|
+
}
|
|
1463
|
+
if (newErrors) {
|
|
1464
|
+
onEndErrors.push(...newErrors);
|
|
1465
|
+
try {
|
|
1466
|
+
result.errors.push(...newErrors);
|
|
1467
|
+
} catch {
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
if (newWarnings) {
|
|
1471
|
+
onEndWarnings.push(...newWarnings);
|
|
1472
|
+
try {
|
|
1473
|
+
result.warnings.push(...newWarnings);
|
|
1474
|
+
} catch {
|
|
1475
|
+
}
|
|
1485
1476
|
}
|
|
1486
1477
|
}
|
|
1487
|
-
|
|
1478
|
+
done(onEndErrors, onEndWarnings);
|
|
1479
|
+
})();
|
|
1488
1480
|
};
|
|
1489
1481
|
}
|
|
1490
1482
|
isSetupDone = true;
|
|
@@ -1872,7 +1864,7 @@ for your current platform.`);
|
|
|
1872
1864
|
"node_modules",
|
|
1873
1865
|
".cache",
|
|
1874
1866
|
"esbuild",
|
|
1875
|
-
`pnpapi-${pkg.replace("/", "-")}-${"0.
|
|
1867
|
+
`pnpapi-${pkg.replace("/", "-")}-${"0.17.0"}-${path.basename(subpath)}`
|
|
1876
1868
|
);
|
|
1877
1869
|
if (!fs.existsSync(binTargetPath)) {
|
|
1878
1870
|
fs.mkdirSync(path.dirname(binTargetPath), { recursive: true });
|
|
@@ -1907,7 +1899,7 @@ if (process.env.ESBUILD_WORKER_THREADS !== "0") {
|
|
|
1907
1899
|
}
|
|
1908
1900
|
}
|
|
1909
1901
|
var _a;
|
|
1910
|
-
var isInternalWorkerThread = ((_a = worker_threads == null ? void 0 : worker_threads.workerData) == null ? void 0 : _a.esbuildVersion) === "0.
|
|
1902
|
+
var isInternalWorkerThread = ((_a = worker_threads == null ? void 0 : worker_threads.workerData) == null ? void 0 : _a.esbuildVersion) === "0.17.0";
|
|
1911
1903
|
var esbuildCommandAndArgs = () => {
|
|
1912
1904
|
if ((!ESBUILD_BINARY_PATH || false) && (path2.basename(__filename) !== "main.js" || path2.basename(__dirname) !== "lib")) {
|
|
1913
1905
|
throw new Error(
|
|
@@ -1974,9 +1966,9 @@ var fsAsync = {
|
|
|
1974
1966
|
}
|
|
1975
1967
|
}
|
|
1976
1968
|
};
|
|
1977
|
-
var version = "0.
|
|
1969
|
+
var version = "0.17.0";
|
|
1978
1970
|
var build = (options) => ensureServiceIsRunning().build(options);
|
|
1979
|
-
var
|
|
1971
|
+
var context = (buildOptions) => ensureServiceIsRunning().context(buildOptions);
|
|
1980
1972
|
var transform = (input, options) => ensureServiceIsRunning().transform(input, options);
|
|
1981
1973
|
var formatMessages = (messages, options) => ensureServiceIsRunning().formatMessages(messages, options);
|
|
1982
1974
|
var analyzeMetafile = (messages, options) => ensureServiceIsRunning().analyzeMetafile(messages, options);
|
|
@@ -1987,10 +1979,9 @@ var buildSync = (options) => {
|
|
|
1987
1979
|
return workerThreadService.buildSync(options);
|
|
1988
1980
|
}
|
|
1989
1981
|
let result;
|
|
1990
|
-
runServiceSync((service) => service.
|
|
1982
|
+
runServiceSync((service) => service.buildOrContext({
|
|
1991
1983
|
callName: "buildSync",
|
|
1992
1984
|
refs: null,
|
|
1993
|
-
serveOptions: null,
|
|
1994
1985
|
options,
|
|
1995
1986
|
isTTY: isTTY(),
|
|
1996
1987
|
defaultWD,
|
|
@@ -2085,7 +2076,7 @@ var ensureServiceIsRunning = () => {
|
|
|
2085
2076
|
if (longLivedService)
|
|
2086
2077
|
return longLivedService;
|
|
2087
2078
|
let [command, args] = esbuildCommandAndArgs();
|
|
2088
|
-
let child = child_process.spawn(command, args.concat(`--service=${"0.
|
|
2079
|
+
let child = child_process.spawn(command, args.concat(`--service=${"0.17.0"}`, "--ping"), {
|
|
2089
2080
|
windowsHide: true,
|
|
2090
2081
|
stdio: ["pipe", "pipe", "inherit"],
|
|
2091
2082
|
cwd: defaultWD
|
|
@@ -2099,7 +2090,7 @@ var ensureServiceIsRunning = () => {
|
|
|
2099
2090
|
},
|
|
2100
2091
|
readFileSync: fs2.readFileSync,
|
|
2101
2092
|
isSync: false,
|
|
2102
|
-
|
|
2093
|
+
hasFS: true,
|
|
2103
2094
|
esbuild: node_exports
|
|
2104
2095
|
});
|
|
2105
2096
|
child.stdin.on("error", afterClose);
|
|
@@ -2127,61 +2118,47 @@ var ensureServiceIsRunning = () => {
|
|
|
2127
2118
|
}
|
|
2128
2119
|
};
|
|
2129
2120
|
longLivedService = {
|
|
2130
|
-
build: (options) => {
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
callName: "build",
|
|
2134
|
-
refs,
|
|
2135
|
-
serveOptions: null,
|
|
2136
|
-
options,
|
|
2137
|
-
isTTY: isTTY(),
|
|
2138
|
-
defaultWD,
|
|
2139
|
-
callback: (err, res) => err ? reject(err) : resolve(res)
|
|
2140
|
-
});
|
|
2141
|
-
});
|
|
2142
|
-
},
|
|
2143
|
-
serve: (serveOptions, buildOptions) => {
|
|
2144
|
-
if (serveOptions === null || typeof serveOptions !== "object")
|
|
2145
|
-
throw new Error("The first argument must be an object");
|
|
2146
|
-
return new Promise((resolve, reject) => service.buildOrServe({
|
|
2147
|
-
callName: "serve",
|
|
2121
|
+
build: (options) => new Promise((resolve, reject) => {
|
|
2122
|
+
service.buildOrContext({
|
|
2123
|
+
callName: "build",
|
|
2148
2124
|
refs,
|
|
2149
|
-
|
|
2150
|
-
options: buildOptions,
|
|
2125
|
+
options,
|
|
2151
2126
|
isTTY: isTTY(),
|
|
2152
2127
|
defaultWD,
|
|
2153
2128
|
callback: (err, res) => err ? reject(err) : resolve(res)
|
|
2154
|
-
})
|
|
2155
|
-
},
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2129
|
+
});
|
|
2130
|
+
}),
|
|
2131
|
+
context: (options) => new Promise((resolve, reject) => service.buildOrContext({
|
|
2132
|
+
callName: "context",
|
|
2133
|
+
refs,
|
|
2134
|
+
options,
|
|
2135
|
+
isTTY: isTTY(),
|
|
2136
|
+
defaultWD,
|
|
2137
|
+
callback: (err, res) => err ? reject(err) : resolve(res)
|
|
2138
|
+
})),
|
|
2139
|
+
transform: (input, options) => new Promise((resolve, reject) => service.transform({
|
|
2140
|
+
callName: "transform",
|
|
2141
|
+
refs,
|
|
2142
|
+
input,
|
|
2143
|
+
options: options || {},
|
|
2144
|
+
isTTY: isTTY(),
|
|
2145
|
+
fs: fsAsync,
|
|
2146
|
+
callback: (err, res) => err ? reject(err) : resolve(res)
|
|
2147
|
+
})),
|
|
2148
|
+
formatMessages: (messages, options) => new Promise((resolve, reject) => service.formatMessages({
|
|
2149
|
+
callName: "formatMessages",
|
|
2150
|
+
refs,
|
|
2151
|
+
messages,
|
|
2152
|
+
options,
|
|
2153
|
+
callback: (err, res) => err ? reject(err) : resolve(res)
|
|
2154
|
+
})),
|
|
2155
|
+
analyzeMetafile: (metafile, options) => new Promise((resolve, reject) => service.analyzeMetafile({
|
|
2156
|
+
callName: "analyzeMetafile",
|
|
2157
|
+
refs,
|
|
2158
|
+
metafile: typeof metafile === "string" ? metafile : JSON.stringify(metafile),
|
|
2159
|
+
options,
|
|
2160
|
+
callback: (err, res) => err ? reject(err) : resolve(res)
|
|
2161
|
+
}))
|
|
2185
2162
|
};
|
|
2186
2163
|
return longLivedService;
|
|
2187
2164
|
};
|
|
@@ -2195,11 +2172,11 @@ var runServiceSync = (callback) => {
|
|
|
2195
2172
|
stdin = bytes;
|
|
2196
2173
|
},
|
|
2197
2174
|
isSync: true,
|
|
2198
|
-
|
|
2175
|
+
hasFS: true,
|
|
2199
2176
|
esbuild: node_exports
|
|
2200
2177
|
});
|
|
2201
2178
|
callback(service);
|
|
2202
|
-
let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.
|
|
2179
|
+
let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.17.0"}`), {
|
|
2203
2180
|
cwd: defaultWD,
|
|
2204
2181
|
windowsHide: true,
|
|
2205
2182
|
input: stdin,
|
|
@@ -2219,7 +2196,7 @@ var workerThreadService = null;
|
|
|
2219
2196
|
var startWorkerThreadService = (worker_threads2) => {
|
|
2220
2197
|
let { port1: mainPort, port2: workerPort } = new worker_threads2.MessageChannel();
|
|
2221
2198
|
let worker = new worker_threads2.Worker(__filename, {
|
|
2222
|
-
workerData: { workerPort, defaultWD, esbuildVersion: "0.
|
|
2199
|
+
workerData: { workerPort, defaultWD, esbuildVersion: "0.17.0" },
|
|
2223
2200
|
transferList: [workerPort],
|
|
2224
2201
|
// From node's documentation: https://nodejs.org/api/worker_threads.html
|
|
2225
2202
|
//
|
|
@@ -2245,14 +2222,8 @@ error: ${text}`);
|
|
|
2245
2222
|
if (!options)
|
|
2246
2223
|
return;
|
|
2247
2224
|
let plugins = options.plugins;
|
|
2248
|
-
let incremental = options.incremental;
|
|
2249
|
-
let watch = options.watch;
|
|
2250
2225
|
if (plugins && plugins.length > 0)
|
|
2251
2226
|
throw fakeBuildError(`Cannot use plugins in synchronous API calls`);
|
|
2252
|
-
if (incremental)
|
|
2253
|
-
throw fakeBuildError(`Cannot use "incremental" with a synchronous build`);
|
|
2254
|
-
if (watch)
|
|
2255
|
-
throw fakeBuildError(`Cannot use "watch" with a synchronous build`);
|
|
2256
2227
|
};
|
|
2257
2228
|
let applyProperties = (object, properties) => {
|
|
2258
2229
|
for (let key in properties) {
|
|
@@ -2357,10 +2328,10 @@ var node_default = node_exports;
|
|
|
2357
2328
|
analyzeMetafileSync,
|
|
2358
2329
|
build,
|
|
2359
2330
|
buildSync,
|
|
2331
|
+
context,
|
|
2360
2332
|
formatMessages,
|
|
2361
2333
|
formatMessagesSync,
|
|
2362
2334
|
initialize,
|
|
2363
|
-
serve,
|
|
2364
2335
|
transform,
|
|
2365
2336
|
transformSync,
|
|
2366
2337
|
version
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "esbuild",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "An extremely fast JavaScript and CSS bundler and minifier.",
|
|
5
5
|
"repository": "https://github.com/evanw/esbuild",
|
|
6
6
|
"scripts": {
|
|
@@ -15,28 +15,28 @@
|
|
|
15
15
|
"esbuild": "bin/esbuild"
|
|
16
16
|
},
|
|
17
17
|
"optionalDependencies": {
|
|
18
|
-
"@esbuild/android-arm": "0.
|
|
19
|
-
"@esbuild/android-arm64": "0.
|
|
20
|
-
"@esbuild/android-x64": "0.
|
|
21
|
-
"@esbuild/darwin-arm64": "0.
|
|
22
|
-
"@esbuild/darwin-x64": "0.
|
|
23
|
-
"@esbuild/freebsd-arm64": "0.
|
|
24
|
-
"@esbuild/freebsd-x64": "0.
|
|
25
|
-
"@esbuild/linux-arm": "0.
|
|
26
|
-
"@esbuild/linux-arm64": "0.
|
|
27
|
-
"@esbuild/linux-ia32": "0.
|
|
28
|
-
"@esbuild/linux-loong64": "0.
|
|
29
|
-
"@esbuild/linux-mips64el": "0.
|
|
30
|
-
"@esbuild/linux-ppc64": "0.
|
|
31
|
-
"@esbuild/linux-riscv64": "0.
|
|
32
|
-
"@esbuild/linux-s390x": "0.
|
|
33
|
-
"@esbuild/linux-x64": "0.
|
|
34
|
-
"@esbuild/netbsd-x64": "0.
|
|
35
|
-
"@esbuild/openbsd-x64": "0.
|
|
36
|
-
"@esbuild/sunos-x64": "0.
|
|
37
|
-
"@esbuild/win32-arm64": "0.
|
|
38
|
-
"@esbuild/win32-ia32": "0.
|
|
39
|
-
"@esbuild/win32-x64": "0.
|
|
18
|
+
"@esbuild/android-arm": "0.17.0",
|
|
19
|
+
"@esbuild/android-arm64": "0.17.0",
|
|
20
|
+
"@esbuild/android-x64": "0.17.0",
|
|
21
|
+
"@esbuild/darwin-arm64": "0.17.0",
|
|
22
|
+
"@esbuild/darwin-x64": "0.17.0",
|
|
23
|
+
"@esbuild/freebsd-arm64": "0.17.0",
|
|
24
|
+
"@esbuild/freebsd-x64": "0.17.0",
|
|
25
|
+
"@esbuild/linux-arm": "0.17.0",
|
|
26
|
+
"@esbuild/linux-arm64": "0.17.0",
|
|
27
|
+
"@esbuild/linux-ia32": "0.17.0",
|
|
28
|
+
"@esbuild/linux-loong64": "0.17.0",
|
|
29
|
+
"@esbuild/linux-mips64el": "0.17.0",
|
|
30
|
+
"@esbuild/linux-ppc64": "0.17.0",
|
|
31
|
+
"@esbuild/linux-riscv64": "0.17.0",
|
|
32
|
+
"@esbuild/linux-s390x": "0.17.0",
|
|
33
|
+
"@esbuild/linux-x64": "0.17.0",
|
|
34
|
+
"@esbuild/netbsd-x64": "0.17.0",
|
|
35
|
+
"@esbuild/openbsd-x64": "0.17.0",
|
|
36
|
+
"@esbuild/sunos-x64": "0.17.0",
|
|
37
|
+
"@esbuild/win32-arm64": "0.17.0",
|
|
38
|
+
"@esbuild/win32-ia32": "0.17.0",
|
|
39
|
+
"@esbuild/win32-x64": "0.17.0"
|
|
40
40
|
},
|
|
41
41
|
"license": "MIT"
|
|
42
42
|
}
|