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.
- package/lib/runtime.js +7 -3
- 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
|
|
12
|
-
|
|
13
|
-
|
|
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
|