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: enable hmr to avoid reload #6004

Merged
merged 6 commits into from
Mar 3, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/curly-windows-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@ice/webpack-config': patch
'@ice/bundles': patch
'@ice/app': patch
---

fix: enable hmr to avoid reload
4 changes: 2 additions & 2 deletions packages/bundles/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"trusted-cert": "1.1.3",
"webpack": "5.75.0",
"webpack-bundle-analyzer": "4.5.0",
"webpack-dev-server": "4.10.0",
"webpack-dev-server": "4.11.1",
"unplugin": "0.9.5",
"bonjour-service": "^1.0.13",
"colorette": "^2.0.10",
Expand All @@ -91,7 +91,7 @@
"webpack-dev-middleware": "^5.3.1",
"ws": "^8.4.2",
"globby": "13.1.2",
"@pmmmwh/react-refresh-webpack-plugin": "0.5.7",
"@pmmmwh/react-refresh-webpack-plugin": "0.5.10",
"loader-utils": "^2.0.0",
"source-map": "0.8.0-beta.0",
"find-up": "5.0.0",
Expand Down
4 changes: 4 additions & 0 deletions packages/ice/templates/core/entry.client.tsx.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,7 @@ const render = (customOptions = {}) => {
};

<%- entryCode %>

if (import.meta.webpackHot) {
import.meta.webpackHot.accept();
}
3 changes: 2 additions & 1 deletion packages/webpack-config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ export function getWebpackConfig(options: GetWebpackConfigOptions): Configuratio
...plugins,
...compilerWebpackPlugins,
// @ts-ignore
new EnvReplacementPlugin(),
dev && new EnvReplacementPlugin(),
dev && fastRefresh && new ReactRefreshWebpackPlugin({
exclude: [/node_modules/, /bundles[\\\\/]compiled/],
// use webpack-dev-server overlay instead
Expand Down Expand Up @@ -360,6 +360,7 @@ export function getWebpackConfig(options: GetWebpackConfigOptions): Configuratio
}),
].filter(Boolean),
devServer: merge({
liveReload: false,
allowedHosts: 'all',
headers: {
'Access-Control-Allow-Origin': '*',
Expand Down
2 changes: 2 additions & 0 deletions packages/webpack-config/src/unPlugins/compilation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ function getJsxTransformOptions({
rootDir,
}: GetJsxTransformOptions) {
const reactTransformConfig: ReactConfig = {
// Swc won't enable fast refresh when development is false in the latest version.
development: mode === 'development',
refresh: fastRefresh,
runtime: 'automatic',
importSource: '@ice/runtime', // The exact import source is '@ice/runtime/jsx-runtime'
Expand Down
108 changes: 17 additions & 91 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.