Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(hmr): accept hot updates for modules above page templates #29752

Merged
merged 10 commits into from
Feb 27, 2021
Next Next commit
fix(hmr): accept hot updates for modules above page templates
  • Loading branch information
pieh committed Feb 26, 2021
commit 6184a52fbcb971687aa6f7f4d4dbb1d10f996dff
10 changes: 10 additions & 0 deletions packages/gatsby/cache-dir/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,16 @@ apiRunnerAsync(`onClientEntry`).then(() => {
)
}
})

module.hot.accept([`./root`, `./api-runner-browser`], () => {
// because `./root` for some reason is imported with commonjs
// we need to re-require it - https://webpack.js.org/api/hot-module-replacement/#accept
// > When using CommonJS you need to update dependencies manually by using require()
// > in the callback.Omitting the callback doesn't make sense here.

const NewRoot = preferDefault(require(`./root`))
renderer(<NewRoot />, rootElement)
})
})
})
})