Simple HMR (previous setup does not work)

This commit is contained in:
Jason Miller
2020-08-12 18:18:49 -04:00
parent f2dcd6e246
commit 1da9e9d7db
2 changed files with 5 additions and 8 deletions

View File

@@ -12,5 +12,6 @@
<link rel="manifest" href="/manifest.json">
</head>
<body>
<script src="./index.ts"></script>
</body>
</html>

View File

@@ -14,12 +14,8 @@ if (process.env.NODE_ENV !== 'production') {
// Enable support for React DevTools and some helpful console warnings:
require('preact/debug');
// When an update to any module is received, re-import the app and trigger a full re-render:
module.hot.accept('./components/App', () => {
// The linter doesn't like the capital A in App. It is wrong.
// tslint:disable-next-line variable-name
import('./components/App').then(({ default: App }) => {
root = render(<App />, document.body, root);
});
});
// Full HMR may not be working due to https://github.com/parcel-bundler/parcel/issues/5016
if (module.hot) {
module.hot.accept();
}
}