zero-com 1.14.0 → 1.14.1
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/lib/common.js +7 -1
- package/package.json +1 -1
package/lib/common.js
CHANGED
|
@@ -229,9 +229,15 @@ const hasHandleCall = (sourceFile) => {
|
|
|
229
229
|
};
|
|
230
230
|
exports.hasHandleCall = hasHandleCall;
|
|
231
231
|
const generateRegistryRequires = (registry) => {
|
|
232
|
-
|
|
232
|
+
const requires = Array.from(registry.keys())
|
|
233
233
|
.map(fp => `require(${JSON.stringify(fp)});`)
|
|
234
234
|
.join('\n');
|
|
235
|
+
// Initialize ZERO_COM_CONTEXT_STORAGE inline so it lives inside the bundle
|
|
236
|
+
// and gets mangled together with all references. Without this, the runtime
|
|
237
|
+
// module may be externalized (loaded via Node.js require) and set the
|
|
238
|
+
// un-mangled name while the bundle references the mangled name.
|
|
239
|
+
const initContextStorage = `if (!globalThis.${exports.ZERO_COM_CONTEXT_STORAGE}) { globalThis.${exports.ZERO_COM_CONTEXT_STORAGE} = new (require('async_hooks').AsyncLocalStorage)(); }`;
|
|
240
|
+
return initContextStorage + '\n' + requires;
|
|
235
241
|
};
|
|
236
242
|
exports.generateRegistryRequires = generateRegistryRequires;
|
|
237
243
|
const collectHandleCallReplacements = (sourceFile) => {
|