@veryfront/ext-bundler-esbuild 0.1.1190 → 0.1.1192
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.
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface EsbuildBuildContextLike<T> {
|
|
2
|
+
rebuild(): Promise<T>;
|
|
3
|
+
cancel(): Promise<void>;
|
|
4
|
+
dispose(): Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Run one active esbuild context build with abort-driven cancellation.
|
|
8
|
+
* Cleanup failures remain observable after success, but never replace the
|
|
9
|
+
* build or abort error that caused cleanup.
|
|
10
|
+
*/
|
|
11
|
+
export declare function rebuildContextWithSignal<T>(context: EsbuildBuildContextLike<T>, signal: AbortSignal): Promise<T>;
|
|
12
|
+
//# sourceMappingURL=context-build-lifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-build-lifecycle.d.ts","sourceRoot":"","sources":["../src/context-build-lifecycle.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,uBAAuB,CAAC,CAAC;IACxC,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;IACtB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED;;;;GAIG;AACH,wBAAsB,wBAAwB,CAAC,CAAC,EAC9C,OAAO,EAAE,uBAAuB,CAAC,CAAC,CAAC,EACnC,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,CAAC,CAAC,CA0CZ"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run one active esbuild context build with abort-driven cancellation.
|
|
3
|
+
* Cleanup failures remain observable after success, but never replace the
|
|
4
|
+
* build or abort error that caused cleanup.
|
|
5
|
+
*/
|
|
6
|
+
export async function rebuildContextWithSignal(context, signal) {
|
|
7
|
+
let cancellation;
|
|
8
|
+
let primaryError;
|
|
9
|
+
let cleanupError;
|
|
10
|
+
let result;
|
|
11
|
+
const cancel = () => {
|
|
12
|
+
if (cancellation)
|
|
13
|
+
return;
|
|
14
|
+
cancellation = Promise.resolve().then(() => context.cancel());
|
|
15
|
+
// Observe immediately; the primary flow awaits it during cleanup.
|
|
16
|
+
void cancellation.catch(() => undefined);
|
|
17
|
+
};
|
|
18
|
+
signal.addEventListener("abort", cancel, { once: true });
|
|
19
|
+
if (signal.aborted)
|
|
20
|
+
cancel();
|
|
21
|
+
try {
|
|
22
|
+
signal.throwIfAborted();
|
|
23
|
+
try {
|
|
24
|
+
result = await context.rebuild();
|
|
25
|
+
signal.throwIfAborted();
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
signal.throwIfAborted();
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
primaryError = error;
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
finally {
|
|
37
|
+
signal.removeEventListener("abort", cancel);
|
|
38
|
+
try {
|
|
39
|
+
await cancellation;
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
cleanupError = error;
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
await context.dispose();
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
cleanupError ??= error;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (primaryError === undefined && cleanupError !== undefined)
|
|
52
|
+
throw cleanupError;
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"esbuild-bundler.d.ts","sourceRoot":"","sources":["../src/esbuild-bundler.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EAEb,OAAO,EACP,YAAY,EAGZ,gBAAgB,EAChB,eAAe,EAChB,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"esbuild-bundler.d.ts","sourceRoot":"","sources":["../src/esbuild-bundler.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EAEb,OAAO,EACP,YAAY,EAGZ,gBAAgB,EAChB,eAAe,EAChB,MAAM,8BAA8B,CAAC;AA0TtC;;;;;GAKG;AACH,qBAAa,cAAe,YAAW,OAAO;IACtC,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IAsCrD,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC;IAa9D,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IAqCtD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAiF5B"}
|
package/esm/esbuild-bundler.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* @module extensions/ext-bundler-esbuild/esbuild-bundler
|
|
11
11
|
*/
|
|
12
12
|
import * as dntShim from "./_dnt.shims.js";
|
|
13
|
+
import { rebuildContextWithSignal } from "./context-build-lifecycle.js";
|
|
13
14
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
14
15
|
import { createRequire } from "node:module";
|
|
15
16
|
import { ensureEsbuildBinary } from "./binary.js";
|
|
@@ -249,7 +250,8 @@ function toOutput(f) {
|
|
|
249
250
|
};
|
|
250
251
|
}
|
|
251
252
|
function mapOptions(options, scope) {
|
|
252
|
-
|
|
253
|
+
// `signal` belongs to the framework contract, not esbuild's BuildOptions.
|
|
254
|
+
const { plugins, signal: _signal, ...rest } = options;
|
|
253
255
|
const mapped = { ...rest };
|
|
254
256
|
const pluginDisposals = createPluginDisposalBarrier(scope);
|
|
255
257
|
if (plugins && plugins.length > 0) {
|
|
@@ -272,8 +274,24 @@ export class EsbuildBundler {
|
|
|
272
274
|
return runBundlerOperation(async (scope) => {
|
|
273
275
|
const esbuild = await getEsbuild();
|
|
274
276
|
const mapped = mapOptions(options, scope);
|
|
277
|
+
const signal = options.signal;
|
|
275
278
|
try {
|
|
276
|
-
|
|
279
|
+
signal?.throwIfAborted();
|
|
280
|
+
let result;
|
|
281
|
+
try {
|
|
282
|
+
if (signal) {
|
|
283
|
+
const buildContext = await invokeEsbuild(() => esbuild.context(mapped.options));
|
|
284
|
+
result = await rebuildContextWithSignal(buildContext, signal);
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
result = await invokeEsbuild(() => esbuild.build(mapped.options));
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
catch (error) {
|
|
291
|
+
signal?.throwIfAborted();
|
|
292
|
+
throw error;
|
|
293
|
+
}
|
|
294
|
+
signal?.throwIfAborted();
|
|
277
295
|
return {
|
|
278
296
|
outputFiles: (result.outputFiles ?? []).map(toOutput),
|
|
279
297
|
warnings: toMessages(result.warnings),
|
|
@@ -316,6 +334,9 @@ export class EsbuildBundler {
|
|
|
316
334
|
metafile: result.metafile,
|
|
317
335
|
};
|
|
318
336
|
}, contextScope),
|
|
337
|
+
cancel: () => runBundlerOperation(async () => {
|
|
338
|
+
await ctx.cancel();
|
|
339
|
+
}, contextScope),
|
|
319
340
|
dispose: () => runBundlerOperation(async () => {
|
|
320
341
|
try {
|
|
321
342
|
await ctx.dispose();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veryfront/ext-bundler-esbuild",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1192",
|
|
4
4
|
"description": "Veryfront first-party extension package for ext-bundler-esbuild",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"veryfront",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"esbuild": "0.28.1"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"veryfront": "^0.1.
|
|
53
|
+
"veryfront": "^0.1.1192"
|
|
54
54
|
},
|
|
55
55
|
"type": "module",
|
|
56
56
|
"types": "./esm/index.d.ts",
|