Skip to content

Commit ae697dd

Browse files
committed
refactor: use self import
1 parent f557503 commit ae697dd

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

packages/common/refresh-utils.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,18 @@ const inWebWorker = typeof WorkerGlobalScope !== 'undefined' && self instanceof
8080

8181
newCode = `${sharedHead}${newCode}
8282
83+
import * as __vite_react_currentExports from ${JSON.stringify(id)};
8384
if (import.meta.hot && !inWebWorker) {
84-
// NOTE: import(import.meta.url) does not work in full-bundle mode
85-
import.meta.hot.getExports().then((currentExports) => {
86-
RefreshRuntime.registerExportsForReactRefresh(${JSON.stringify(
85+
const currentExports = __vite_react_currentExports
86+
RefreshRuntime.registerExportsForReactRefresh(${JSON.stringify(
87+
id,
88+
)}, currentExports);
89+
import.meta.hot.accept((nextExports) => {
90+
if (!nextExports) return;
91+
const invalidateMessage = RefreshRuntime.validateRefreshBoundaryAndEnqueueUpdate(${JSON.stringify(
8792
id,
88-
)}, currentExports);
89-
import.meta.hot.accept((nextExports) => {
90-
if (!nextExports) return;
91-
const invalidateMessage = RefreshRuntime.validateRefreshBoundaryAndEnqueueUpdate(${JSON.stringify(
92-
id,
93-
)}, currentExports, nextExports);
94-
if (invalidateMessage) import.meta.hot.invalidate(invalidateMessage);
95-
});
93+
)}, currentExports, nextExports);
94+
if (invalidateMessage) import.meta.hot.invalidate(invalidateMessage);
9695
});
9796
}
9897
`

0 commit comments

Comments
 (0)