zero-com 1.9.2 → 1.10.2

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/runtime.js +7 -3
  2. package/package.json +1 -1
package/lib/runtime.js CHANGED
@@ -8,9 +8,13 @@ exports.func = func;
8
8
  function getContextStorage() {
9
9
  if (!globalThis.ZERO_COM_CONTEXT_STORAGE) {
10
10
  try {
11
- // Dynamic import to avoid bundling async_hooks for browser
12
- const { AsyncLocalStorage } = require('async_hooks');
13
- globalThis.ZERO_COM_CONTEXT_STORAGE = new AsyncLocalStorage();
11
+ // Dynamic require to avoid bundling async_hooks for browser.
12
+ // Falls back to process.getBuiltinModule() for ESM contexts (e.g. Vite SSR)
13
+ // where require() is not available.
14
+ const mod = typeof require === 'function'
15
+ ? require('async_hooks')
16
+ : process.getBuiltinModule('node:async_hooks');
17
+ globalThis.ZERO_COM_CONTEXT_STORAGE = new mod.AsyncLocalStorage();
14
18
  }
15
19
  catch (_a) {
16
20
  // Browser environment - context storage not available
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zero-com",
3
- "version": "1.9.2",
3
+ "version": "1.10.2",
4
4
  "main": "index.js",
5
5
  "repository": "https://github.com/yosbelms/zero-com",
6
6
  "keywords": [