Skip to content

Commit 103012c

Browse files
authored
refactor: remove alias hijacking (#23)
1 parent 57f4d94 commit 103012c

File tree

2 files changed

+10
-66
lines changed

2 files changed

+10
-66
lines changed

src/alias.ts

-51
This file was deleted.

src/server.ts

+10-15
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import WebpackDevServer from "webpack-dev-server";
1515
// @ts-ignore 'package.json' is not under 'rootDir'
1616
import { version } from "../package.json";
1717

18-
import { addResolveAlias, removeResolveAlias } from "./alias";
1918
import type { DevServer, ResolvedDevServer } from "./config";
2019
import { applyDevServerPatch } from "./patch";
2120

@@ -102,20 +101,16 @@ export class RspackDevServer extends WebpackDevServer {
102101
await super.initialize();
103102
}
104103

105-
// @ts-ignore
106-
private override addAdditionalEntries(compiler: Compiler) {
107-
addResolveAlias("webpack-dev-server", {
108-
"../client/index.js": require.resolve("@rspack/dev-server/client/index"),
109-
"webpack/hot/only-dev-server": require.resolve(
110-
"@rspack/core/hot/only-dev-server",
111-
),
112-
"webpack/hot/dev-server": require.resolve("@rspack/core/hot/dev-server"),
113-
});
114-
try {
115-
// @ts-expect-error
116-
super.addAdditionalEntries(compiler);
117-
} finally {
118-
removeResolveAlias("webpack-dev-server");
104+
getClientEntry(): string {
105+
return require.resolve("@rspack/dev-server/client/index");
106+
}
107+
108+
getClientHotEntry(): string | undefined {
109+
if (this.options.hot === "only") {
110+
return require.resolve("@rspack/core/hot/only-dev-server");
111+
}
112+
if (this.options.hot) {
113+
return require.resolve("@rspack/core/hot/dev-server");
119114
}
120115
}
121116
}

0 commit comments

Comments
 (0)