Skip to content

Commit 8db7e58

Browse files
committed
fix: Bun ESM compatibility for BASE_GLOBALS
1 parent b563e04 commit 8db7e58

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/cache.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,21 @@ export const DEFAULT_TTL = 0; // 0 = no expiration
6666
* @internal
6767
*/
6868
const BASE_GLOBALS: Record<string, unknown> = {
69-
require,
70-
module,
71-
exports,
69+
require: typeof require !== 'undefined' ? require : undefined,
70+
module: typeof module !== 'undefined' ? module : undefined,
71+
exports: typeof exports !== 'undefined' ? exports : undefined,
7272
console,
73-
Buffer,
74-
process,
73+
Buffer: typeof Buffer !== 'undefined' ? Buffer : undefined,
74+
process: typeof process !== 'undefined' ? process : undefined,
7575
setTimeout,
7676
setInterval,
77-
setImmediate,
77+
setImmediate: typeof setImmediate !== 'undefined' ? setImmediate : undefined,
7878
clearTimeout,
7979
clearInterval,
80-
clearImmediate,
80+
clearImmediate: typeof clearImmediate !== 'undefined' ? clearImmediate : undefined,
8181
queueMicrotask,
82-
__dirname,
83-
__filename,
82+
__dirname: typeof __dirname !== 'undefined' ? __dirname : undefined,
83+
__filename: typeof __filename !== 'undefined' ? __filename : undefined,
8484
// Global constructors
8585
Array,
8686
Object,

0 commit comments

Comments
 (0)