Skip to content

Commit

Permalink
fix(server): use cjs format hmr-client to fix hmr issue (#4719)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan authored Sep 25, 2023
1 parent 9c49cf3 commit 3dcad90
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
7 changes: 7 additions & 0 deletions .changeset/few-knives-jam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@modern-js/server': patch
---

fix(server): use cjs format hmr-client to fix hmr issue

fix(server): 使用 cjs 格式的 hmr-client 来修复 hmr 问题
3 changes: 1 addition & 2 deletions packages/server/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@
"./hmr-client": {
"node": {
"jsnext:source": "./src/dev-tools/dev-middleware/hmr-client/index.ts",
"import": "./dist/esm/dev-tools/dev-middleware/hmr-client/index.js",
"require": "./dist/cjs/dev-tools/dev-middleware/hmr-client/index.js"
},
"default": "./dist/esm/dev-tools/dev-middleware/hmr-client/index.js"
"default": "./dist/cjs/dev-tools/dev-middleware/hmr-client/index.js"
}
},
"scripts": {
Expand Down
6 changes: 1 addition & 5 deletions packages/server/server/src/dev-tools/dev-middleware/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { sep } from 'path';
import { Server } from 'http';
import { EventEmitter } from 'events';
import {
Expand Down Expand Up @@ -28,10 +27,7 @@ function getHMRClientPath(client: DevServerOptions['client']) {
)}?${host}${path}${port}${protocol}`;

// replace cjs with esm because we want to use the es5 version
return clientEntry.replace(
`${sep}cjs${sep}dev-tools`,
`${sep}esm${sep}dev-tools`,
);
return clientEntry;
}

export default class DevMiddleware extends EventEmitter {
Expand Down

0 comments on commit 3dcad90

Please sign in to comment.