Skip to content

Commit

Permalink
fix(core): hmr issue on dev (#5006)
Browse files Browse the repository at this point in the history
I suspect HMR does not working properly on dev because we have multiple entries.
One relative issue: webpack/webpack-dev-server#2792

I think we do not need multiple entries for polyfills & plugins after all. They could be in the same chunk, and could be later optimized through splitChunks option.

`ses.ts` is changed to `ses-lockdown.ts` because `ses.ts` does not pass circular dependency check by madge. I haven't looked through the real root cause though. See pahen/madge#355
  • Loading branch information
pengx17 committed Nov 21, 2023
1 parent 6152557 commit f33c49b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 28 deletions.
31 changes: 4 additions & 27 deletions packages/frontend/core/.webpack/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,16 @@ export default async function (cli_env: any, _: any) {
const config = createConfiguration(flags, runtimeConfig);
return merge(config, {
entry: {
'polyfill/intl-segmenter': {
import: resolve(rootPath, 'src/polyfill/intl-segmenter.ts'),
},
'polyfill/ses': {
import: resolve(rootPath, 'src/polyfill/ses.ts'),
},
plugin: {
dependOn: ['polyfill/intl-segmenter', 'polyfill/ses'],
import: resolve(rootPath, 'src/bootstrap/register-plugins.ts'),
},
app: {
chunkLoading: 'import',
dependOn: ['polyfill/intl-segmenter', 'polyfill/ses', 'plugin'],
import: resolve(rootPath, 'src/index.tsx'),
},
'_plugin/index.test': {
chunkLoading: 'import',
dependOn: ['polyfill/intl-segmenter', 'polyfill/ses', 'plugin'],
import: resolve(rootPath, 'src/_plugin/index.test.tsx'),
},
app: resolve(rootPath, 'src/index.tsx'),
'_plugin/index.test': resolve(rootPath, 'src/_plugin/index.test.tsx'),
},
plugins: [
new HTMLPlugin({
template: join(rootPath, '.webpack', 'template.html'),
inject: 'body',
scriptLoading: 'module',
minify: false,
chunks: ['app', 'plugin', 'polyfill/intl-segmenter', 'polyfill/ses'],
chunks: ['app'],
filename: 'index.html',
templateParameters: {
GIT_SHORT_SHA: gitShortHash(),
Expand All @@ -59,12 +41,7 @@ export default async function (cli_env: any, _: any) {
scriptLoading: 'module',
minify: false,
publicPath: getPublicPath(flags),
chunks: [
'_plugin/index.test',
'plugin',
'polyfill/intl-segmenter',
'polyfill/ses',
],
chunks: ['_plugin/index.test'],
filename: '_plugin/index.html',
templateParameters: {
GIT_SHORT_SHA: gitShortHash(),
Expand Down
3 changes: 3 additions & 0 deletions packages/frontend/core/src/_plugin/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import '../polyfill/ses-lockdown';
import '../polyfill/intl-segmenter';

import { assertExists } from '@blocksuite/global/utils';
import {
getCurrentStore,
Expand Down
7 changes: 6 additions & 1 deletion packages/frontend/core/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import './polyfill/ses-lockdown';
import './polyfill/intl-segmenter';

import { WorkspaceFallback } from '@affine/component/workspace';
import { assertExists } from '@blocksuite/global/utils';
import { getCurrentStore } from '@toeverything/infra/atom';
Expand Down Expand Up @@ -36,4 +39,6 @@ async function main() {
);
}

await main();
main().catch(err => {
console.error('Failed to bootstrap app', err);
});
File renamed without changes.

0 comments on commit f33c49b

Please sign in to comment.