Skip to content

Commit c1ee4f7

Browse files
mayurarora0903Mayur Arora
andauthored
Avoid accessing globals at module initialization time. (#129)
* Avoid accessing global at module initialization time. This to allow creation of a snapshot-able bundle in certain JS environments. --------- Co-authored-by: Mayur Arora <[email protected]>
1 parent 83446e7 commit c1ee4f7

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

.changeset/hungry-dingos-hope.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"react-loosely-lazy": patch
3+
---
4+
5+
Avoid accessing global at module initialization time.

packages/core/react-loosely-lazy/src/lazy/components/client.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import { ProfilerContext } from '../../profiler';
1818
import type { Status } from './types';
1919
import { useSubscription } from './utils';
2020

21-
const { requestIdleCallback = setTimeout } = window;
22-
2321
export function createComponentClient<C extends ComponentType<any>>({
2422
defer,
2523
deferred,
@@ -31,6 +29,7 @@ export function createComponentClient<C extends ComponentType<any>>({
3129
dataLazyId: string;
3230
moduleId: string;
3331
}) {
32+
const { requestIdleCallback = setTimeout } = window;
3433
const ResolvedLazy = lazy(() => deferred.promise);
3534

3635
return (props: ComponentProps<C>) => {

0 commit comments

Comments
 (0)