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.
Files changed (2) hide show
  1. package/lib/common.js +7 -1
  2. 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
- return Array.from(registry.keys())
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) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zero-com",
3
- "version": "1.14.0",
3
+ "version": "1.14.1",
4
4
  "main": "index.js",
5
5
  "browser": {
6
6
  "./lib/async-local-storage.js": "./lib/async-local-storage.browser.js"