mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-02 05:03:44 +08:00
Merge pull request #11709 from storybookjs/fix/11602-hmr-not-working
FIX HMR
This commit is contained in:
commit
9d2b53dac4
@ -16,6 +16,7 @@ beforeEach(() => {
|
||||
hot: {
|
||||
data: {},
|
||||
dispose: (cb: (data: any) => void) => cbs.push(cb),
|
||||
accept: jest.fn(),
|
||||
},
|
||||
} as unknown) as NodeModule;
|
||||
});
|
||||
|
@ -230,14 +230,15 @@ export const loadCsf = ({
|
||||
`Invalid module '${m}'. Did you forget to pass \`module\` as the second argument to \`configure\`"?`
|
||||
);
|
||||
}
|
||||
|
||||
if (m && m.hot && m.hot.dispose) {
|
||||
({ previousExports = new Map() } = m.hot.data || {});
|
||||
|
||||
m.hot.dispose((data) => {
|
||||
loaded = false;
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
data.previousExports = previousExports;
|
||||
});
|
||||
m.hot.accept();
|
||||
}
|
||||
if (loaded) {
|
||||
logger.warn('Unexpected loaded state. Did you call `load` twice?');
|
||||
|
Loading…
x
Reference in New Issue
Block a user