@ms-cloudpack/esm-stub-utilities 0.13.13 → 0.13.14
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeESMStubsInWorker.d.ts","sourceRoot":"","sources":["../src/writeESMStubsInWorker.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAI1E;;GAEG;AAGH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,oBAAoB,GAAG;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GACtD,OAAO,CAAC,mBAAmB,CAAC,
|
|
1
|
+
{"version":3,"file":"writeESMStubsInWorker.d.ts","sourceRoot":"","sources":["../src/writeESMStubsInWorker.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAI1E;;GAEG;AAGH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,oBAAoB,GAAG;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GACtD,OAAO,CAAC,mBAAmB,CAAC,CA6C9B;AAED,wBAAsB,qBAAqB,kBAG1C"}
|
|
@@ -6,19 +6,35 @@ let workerPool;
|
|
|
6
6
|
// This is tested in bundler-rollup/src/writeESMStubsInWorker.test.ts so we can
|
|
7
7
|
// use the compiled version of the workerEntry file.
|
|
8
8
|
export async function writeESMStubsInWorker(options) {
|
|
9
|
-
|
|
9
|
+
// Trim the options to only the necessary ones for the worker to reduce what's serialized
|
|
10
|
+
// (a larger BundleOptions object was likely passed in)
|
|
11
|
+
const onlyStubOptions = {
|
|
12
|
+
inputPath: options.inputPath,
|
|
13
|
+
entries: options.entries,
|
|
14
|
+
forceCJS: options.forceCJS,
|
|
15
|
+
};
|
|
10
16
|
workerPool ??= new WorkerPool({
|
|
11
17
|
name: 'ESM stub generation',
|
|
12
18
|
parentPath: import.meta.url,
|
|
13
19
|
entryPath: './worker/workerEntry',
|
|
14
|
-
maxWorkers,
|
|
20
|
+
maxWorkers: options.maxWorkers || 5,
|
|
21
|
+
// Stop inactive workers after 5 minutes. This is intended to prevent one possible cause of
|
|
22
|
+
// OOM crashes if cloudpack start is left running for a long time (though it's much more likely
|
|
23
|
+
// that the issue is caused by servers or file watchers). The timeout is conservative because
|
|
24
|
+
// the fake browser environment has nontrivial startup time, so killing workers too quickly
|
|
25
|
+
// could slow down rebuilds.
|
|
26
|
+
inactiveTimeout: 5 * 60 * 1000,
|
|
27
|
+
// Most stubs seem to stay well under this size, and Node appears to be decent about freeing
|
|
28
|
+
// memory after writeESMStubs finishes, but this will catch anything giant or leaky.
|
|
29
|
+
// (This is only checked after task completion, so a package exceeding it will still be stubbed.)
|
|
30
|
+
maxHeapSize: 500 * 1024 * 1024,
|
|
31
|
+
// console.warn if a stub takes longer than this
|
|
32
|
+
warnAboveTime: process.env.CI ? 4000 : 2000,
|
|
15
33
|
});
|
|
16
|
-
const startTime = Date.now();
|
|
17
|
-
console.info(`Starting ESM stub generation for ${options.inputPath}`);
|
|
18
34
|
try {
|
|
19
35
|
return await workerPool.execute({
|
|
20
36
|
method: 'writeESMStubs',
|
|
21
|
-
args: [
|
|
37
|
+
args: [onlyStubOptions],
|
|
22
38
|
});
|
|
23
39
|
}
|
|
24
40
|
catch (err) {
|
|
@@ -33,9 +49,6 @@ export async function writeESMStubsInWorker(options) {
|
|
|
33
49
|
],
|
|
34
50
|
};
|
|
35
51
|
}
|
|
36
|
-
finally {
|
|
37
|
-
console.info(`Finished ESM stub generation for ${options.inputPath} in ${((Date.now() - startTime) / 1000).toFixed(3)}s`);
|
|
38
|
-
}
|
|
39
52
|
}
|
|
40
53
|
export async function disposeStubWorkerPool() {
|
|
41
54
|
await workerPool?.dispose();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeESMStubsInWorker.js","sourceRoot":"","sources":["../src/writeESMStubsInWorker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAIvD,IAAI,UAAkC,CAAC;AAEvC;;GAEG;AACH,+EAA+E;AAC/E,oDAAoD;AACpD,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,OAAuD;IAEvD,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"writeESMStubsInWorker.js","sourceRoot":"","sources":["../src/writeESMStubsInWorker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAIvD,IAAI,UAAkC,CAAC;AAEvC;;GAEG;AACH,+EAA+E;AAC/E,oDAAoD;AACpD,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,OAAuD;IAEvD,yFAAyF;IACzF,uDAAuD;IACvD,MAAM,eAAe,GAAyB;QAC5C,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,QAAQ,EAAE,OAAO,CAAC,QAAQ;KAC3B,CAAC;IAEF,UAAU,KAAK,IAAI,UAAU,CAAC;QAC5B,IAAI,EAAE,qBAAqB;QAC3B,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG;QAC3B,SAAS,EAAE,sBAAsB;QACjC,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,CAAC;QACnC,2FAA2F;QAC3F,+FAA+F;QAC/F,6FAA6F;QAC7F,2FAA2F;QAC3F,4BAA4B;QAC5B,eAAe,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI;QAC9B,4FAA4F;QAC5F,oFAAoF;QACpF,iGAAiG;QACjG,WAAW,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI;QAC9B,gDAAgD;QAChD,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI;KAC5C,CAAC,CAAC;IAEH,IAAI,CAAC;QACH,OAAO,MAAM,UAAU,CAAC,OAAO,CAAsB;YACnD,MAAM,EAAE,eAAe;YACvB,IAAI,EAAE,CAAC,eAAe,CAAC;SACxB,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO;YACL,UAAU,EAAE,EAAE;YACd,MAAM,EAAE;gBACN;oBACE,MAAM,EAAE,qBAAqB;oBAC7B,mEAAmE;oBACnE,IAAI,EAAG,GAAa,EAAE,KAAK,IAAK,GAAa,EAAE,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC;iBACtE;aACF;SACF,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,qBAAqB;IACzC,MAAM,UAAU,EAAE,OAAO,EAAE,CAAC;IAC5B,UAAU,GAAG,SAAS,CAAC;AACzB,CAAC","sourcesContent":["import { WorkerPool } from '@ms-cloudpack/worker-pool';\nimport type { WriteESMStubsOptions } from './types/WriteESMStubsOptions.js';\nimport type { WriteESMStubsResult } from './types/WriteESMStubsResult.js';\n\nlet workerPool: WorkerPool | undefined;\n\n/**\n * Write ESM stubs using a worker pool.\n */\n// This is tested in bundler-rollup/src/writeESMStubsInWorker.test.ts so we can\n// use the compiled version of the workerEntry file.\nexport async function writeESMStubsInWorker(\n options: WriteESMStubsOptions & { maxWorkers?: number },\n): Promise<WriteESMStubsResult> {\n // Trim the options to only the necessary ones for the worker to reduce what's serialized\n // (a larger BundleOptions object was likely passed in)\n const onlyStubOptions: WriteESMStubsOptions = {\n inputPath: options.inputPath,\n entries: options.entries,\n forceCJS: options.forceCJS,\n };\n\n workerPool ??= new WorkerPool({\n name: 'ESM stub generation',\n parentPath: import.meta.url,\n entryPath: './worker/workerEntry',\n maxWorkers: options.maxWorkers || 5,\n // Stop inactive workers after 5 minutes. This is intended to prevent one possible cause of\n // OOM crashes if cloudpack start is left running for a long time (though it's much more likely\n // that the issue is caused by servers or file watchers). The timeout is conservative because\n // the fake browser environment has nontrivial startup time, so killing workers too quickly\n // could slow down rebuilds.\n inactiveTimeout: 5 * 60 * 1000,\n // Most stubs seem to stay well under this size, and Node appears to be decent about freeing\n // memory after writeESMStubs finishes, but this will catch anything giant or leaky.\n // (This is only checked after task completion, so a package exceeding it will still be stubbed.)\n maxHeapSize: 500 * 1024 * 1024,\n // console.warn if a stub takes longer than this\n warnAboveTime: process.env.CI ? 4000 : 2000,\n });\n\n try {\n return await workerPool.execute<WriteESMStubsResult>({\n method: 'writeESMStubs',\n args: [onlyStubOptions],\n });\n } catch (err) {\n return {\n newEntries: {},\n errors: [\n {\n source: 'ESM stub generation',\n // note: err won't be an instance of Error because of serialization\n text: (err as Error)?.stack || (err as Error)?.message || String(err),\n },\n ],\n };\n }\n}\n\nexport async function disposeStubWorkerPool() {\n await workerPool?.dispose();\n workerPool = undefined;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/esm-stub-utilities",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.14",
|
|
4
4
|
"description": "Generates ESM stubs for CommonJS entry files.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@ms-cloudpack/common-types": "^0.23.3",
|
|
18
18
|
"@ms-cloudpack/json-utilities": "^0.1.8",
|
|
19
|
-
"@ms-cloudpack/package-utilities": "^10.2.
|
|
19
|
+
"@ms-cloudpack/package-utilities": "^10.2.10",
|
|
20
20
|
"@ms-cloudpack/path-string-parsing": "^1.2.4",
|
|
21
|
-
"@ms-cloudpack/worker-pool": "^0.
|
|
21
|
+
"@ms-cloudpack/worker-pool": "^0.3.0",
|
|
22
22
|
"jsdom": "^24.0.0",
|
|
23
23
|
"jsdom-global": "^3.0.2",
|
|
24
24
|
"regenerator-runtime": "^0.14.1"
|