@veryfront/ext-bundler-esbuild 0.1.1234 → 0.1.1236
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/esm/_dnt.polyfills.d.ts
CHANGED
|
@@ -97,5 +97,10 @@ interface ImportMetaPonyfill extends ImportMetaPonyfillCommonjs, ImportMetaPonyf
|
|
|
97
97
|
export declare let import_meta_ponyfill_commonjs: ImportMetaPonyfillCommonjs;
|
|
98
98
|
export declare let import_meta_ponyfill_esmodule: ImportMetaPonyfillEsmodule;
|
|
99
99
|
export declare let import_meta_ponyfill: ImportMetaPonyfill;
|
|
100
|
+
declare global {
|
|
101
|
+
interface Error {
|
|
102
|
+
cause?: unknown;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
100
105
|
export {};
|
|
101
106
|
//# sourceMappingURL=_dnt.polyfills.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_dnt.polyfills.d.ts","sourceRoot":"","sources":["../src/_dnt.polyfills.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAgC,KAAK,GAAG,EAAE,MAAM,UAAU,CAAC;AAGlE,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,UAAU;QAClB;;;;;;;;;;;;;;WAcG;QACH,GAAG,EAAE,MAAM,CAAC;QACZ;;;;;;;;;;;;WAYG;QACH,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,GAAG,GAAG,SAAS,GAAG,MAAM,CAAC;QACtE;;;;;;;;WAQG;QACH,IAAI,EAAE,OAAO,CAAC;QAEd;;;;;;;;;;;;WAYG;QACH,QAAQ,EAAE,MAAM,CAAC;QAEjB;;;;;;;;;;;;WAYG;QACH,OAAO,EAAE,MAAM,CAAC;KACjB;CACF;AAED,KAAK,WAAW,GAAG,UAAU,CAAC,OAA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AACnD,UAAU,0BAA0B;IAClC,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC;CACxD;AACD,UAAU,0BAA0B;IAClC,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,CAAC;CACtC;AACD,UAAU,kBACR,SAAQ,0BAA0B,EAAE,0BAA0B;CAC/D;AAiBD,eAAO,IAAI,6BAA6B,EA2BnC,0BAA0B,CAAC;AAMhC,eAAO,IAAI,6BAA6B,EA4DnC,0BAA0B,CAAC;AAMhC,eAAO,IAAI,oBAAoB,EAoB1B,kBAAkB,CAAC;AACxB,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK;QACb,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB;CACF;AAED,OAAO,EAAE,CAAC"}
|
package/esm/esbuild-bundler.d.ts
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import type { BuildContext, BundleOptions, Bundler, BundleResult, TransformOptions, TransformResult } from "veryfront/extensions/bundler";
|
|
2
|
+
import type { ChildProcess } from "node:child_process";
|
|
3
|
+
/**
|
|
4
|
+
* Keep lifecycle tracking tolerant of Node-compatible child-process shims.
|
|
5
|
+
*
|
|
6
|
+
* Native Node represents an active child with `null` exit fields. Some
|
|
7
|
+
* compatible runtimes leave those fields undefined until the child exits.
|
|
8
|
+
*/
|
|
9
|
+
/** The ownership latch is module-wide; tests must clear it between cases. */
|
|
10
|
+
export declare function __resetOwnershipErrorForTests(): void;
|
|
11
|
+
/** Exercise the latch without starting a real esbuild service. */
|
|
12
|
+
export declare function __recordOwnershipErrorForTests(cause?: unknown): Error;
|
|
13
|
+
export declare function isLiveEsbuildServiceProcess(child: Pick<ChildProcess, "killed" | "exitCode" | "signalCode">): boolean;
|
|
2
14
|
/**
|
|
3
15
|
* esbuild-backed {@link Bundler} implementation.
|
|
4
16
|
*
|
|
@@ -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;AAGtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAgPvD;;;;;GAKG;AACH,6EAA6E;AAC7E,wBAAgB,6BAA6B,IAAI,IAAI,CAEpD;AAED,kEAAkE;AAClE,wBAAgB,8BAA8B,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,KAAK,CAErE;AAED,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,QAAQ,GAAG,UAAU,GAAG,YAAY,CAAC,GAC9D,OAAO,CAIT;AA6HD;;;;;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
|
@@ -27,10 +27,53 @@ let activeOperationCount = 0;
|
|
|
27
27
|
let activeOperationsIdle = Promise.resolve();
|
|
28
28
|
let resolveActiveOperationsIdle = null;
|
|
29
29
|
const operationScopes = new AsyncLocalStorage();
|
|
30
|
+
const OWNERSHIP_ERROR_MESSAGE = "[ext-bundler-esbuild] Cannot own an esbuild service started outside the module-wide adapter; restart the process and use only the Bundler contract";
|
|
31
|
+
const MAX_CAUSE_DETAIL_LENGTH = 200;
|
|
32
|
+
/** Absolute POSIX and Windows paths, reduced to a basename below. */
|
|
33
|
+
const ABSOLUTE_PATH_PATTERN = /(?:[A-Za-z]:)?(?:\/|\\\\)[^\s"']*/g;
|
|
34
|
+
/**
|
|
35
|
+
* Reduce a cause to a single redacted line.
|
|
36
|
+
*
|
|
37
|
+
* The message is logged, so it must not carry a machine's filesystem layout:
|
|
38
|
+
* a compiled runtime resolves esbuild under a temp directory, and spawn errors
|
|
39
|
+
* quote that path verbatim. Keeping only the basename preserves what the reader
|
|
40
|
+
* needs -- which binary or module failed -- without the surrounding layout. The
|
|
41
|
+
* first line only, so a stack never reaches the message, and bounded so a large
|
|
42
|
+
* esbuild diagnostic cannot dominate the log line.
|
|
43
|
+
*/
|
|
44
|
+
function describeCause(cause) {
|
|
45
|
+
if (cause === undefined)
|
|
46
|
+
return "";
|
|
47
|
+
const raw = cause instanceof Error ? cause.message : String(cause);
|
|
48
|
+
const firstLine = raw.split("\n", 1)[0] ?? "";
|
|
49
|
+
const withoutPaths = firstLine.replace(ABSOLUTE_PATH_PATTERN, (match) => {
|
|
50
|
+
const parts = match.split(/[\/\\]/).filter(Boolean);
|
|
51
|
+
return parts.length > 0 ? parts[parts.length - 1] : match;
|
|
52
|
+
});
|
|
53
|
+
const detail = withoutPaths.trim().slice(0, MAX_CAUSE_DETAIL_LENGTH);
|
|
54
|
+
return detail ? ` (underlying failure: ${detail})` : "";
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Latch the ownership failure, keeping whatever really went wrong.
|
|
58
|
+
*
|
|
59
|
+
* The latch is permanent, so the first call decides the error every later
|
|
60
|
+
* operation sees. That call is often made before the operation settles, when no
|
|
61
|
+
* cause is known yet; adopting the cause afterwards is what keeps the real
|
|
62
|
+
* failure visible instead of reporting a lifecycle problem that may not be the
|
|
63
|
+
* actual one. The cause is folded into the message because callers log
|
|
64
|
+
* `error.message` and would otherwise never print the chain.
|
|
65
|
+
*/
|
|
30
66
|
function recordOwnershipError(cause) {
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
67
|
+
const existing = esbuildOwnershipError;
|
|
68
|
+
if (!existing) {
|
|
69
|
+
esbuildOwnershipError = new Error(`${OWNERSHIP_ERROR_MESSAGE}${describeCause(cause)}`, cause === undefined ? undefined : { cause });
|
|
70
|
+
return esbuildOwnershipError;
|
|
71
|
+
}
|
|
72
|
+
if (cause !== undefined && existing.cause === undefined) {
|
|
73
|
+
existing.cause = cause;
|
|
74
|
+
existing.message = `${OWNERSHIP_ERROR_MESSAGE}${describeCause(cause)}`;
|
|
75
|
+
}
|
|
76
|
+
return existing;
|
|
34
77
|
}
|
|
35
78
|
async function getEsbuild() {
|
|
36
79
|
await ensureEsbuildBinary();
|
|
@@ -157,10 +200,27 @@ function isEsbuildServiceSpawn(spawnArgs) {
|
|
|
157
200
|
args.some((arg) => typeof arg === "string" && arg.startsWith("--service=")) &&
|
|
158
201
|
args.includes("--ping");
|
|
159
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* Keep lifecycle tracking tolerant of Node-compatible child-process shims.
|
|
205
|
+
*
|
|
206
|
+
* Native Node represents an active child with `null` exit fields. Some
|
|
207
|
+
* compatible runtimes leave those fields undefined until the child exits.
|
|
208
|
+
*/
|
|
209
|
+
/** The ownership latch is module-wide; tests must clear it between cases. */
|
|
210
|
+
export function __resetOwnershipErrorForTests() {
|
|
211
|
+
esbuildOwnershipError = null;
|
|
212
|
+
}
|
|
213
|
+
/** Exercise the latch without starting a real esbuild service. */
|
|
214
|
+
export function __recordOwnershipErrorForTests(cause) {
|
|
215
|
+
return recordOwnershipError(cause);
|
|
216
|
+
}
|
|
217
|
+
export function isLiveEsbuildServiceProcess(child) {
|
|
218
|
+
return !child.killed &&
|
|
219
|
+
(child.exitCode === null || child.exitCode === undefined) &&
|
|
220
|
+
(child.signalCode === null || child.signalCode === undefined);
|
|
221
|
+
}
|
|
160
222
|
function isLiveService(service) {
|
|
161
|
-
return
|
|
162
|
-
service.child.exitCode === null &&
|
|
163
|
-
service.child.signalCode === null;
|
|
223
|
+
return isLiveEsbuildServiceProcess(service.child);
|
|
164
224
|
}
|
|
165
225
|
function invokeEsbuild(operation) {
|
|
166
226
|
const originalSpawn = childProcess.spawn;
|
|
@@ -202,9 +262,14 @@ function invokeEsbuild(operation) {
|
|
|
202
262
|
}
|
|
203
263
|
const ownedService = capturedService ?? esbuildService;
|
|
204
264
|
if (!ownedService || !isLiveService(ownedService)) {
|
|
205
|
-
|
|
265
|
+
// Latch synchronously so a concurrent operation cannot pass the admission
|
|
266
|
+
// check in runBundlerOperation and drive esbuild while ownership is already
|
|
267
|
+
// known to be invalid. The rejection handler still supplies the cause: the
|
|
268
|
+
// latch is created without one here, and recordOwnershipError adopts the
|
|
269
|
+
// first cause offered afterwards.
|
|
270
|
+
recordOwnershipError();
|
|
206
271
|
return result.then(() => {
|
|
207
|
-
throw
|
|
272
|
+
throw recordOwnershipError();
|
|
208
273
|
}, (cause) => {
|
|
209
274
|
throw recordOwnershipError(cause);
|
|
210
275
|
});
|
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.1236",
|
|
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.1236"
|
|
54
54
|
},
|
|
55
55
|
"type": "module",
|
|
56
56
|
"types": "./esm/index.d.ts",
|