Skip to content

Commit 2b53b00

Browse files
refactor: do not use webpack directly (#3414)
1 parent 1b0f514 commit 2b53b00

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

lib/Server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class Server {
8686
}
8787

8888
setupProgressPlugin() {
89-
const { ProgressPlugin } = require('webpack');
89+
const { ProgressPlugin } = this.compiler.webpack || require('webpack');
9090

9191
new ProgressPlugin((percent, msg, addInfo, pluginName) => {
9292
percent = Math.floor(percent * 100);

lib/utils/DevServerPlugin.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
'use strict';
22

3-
const webpack = require('webpack');
43
const ipaddr = require('ipaddr.js');
54
const getSocketClientPath = require('./getSocketClientPath');
65

7-
// @ts-ignore
8-
const EntryPlugin = webpack.EntryPlugin;
9-
106
class DevServerPlugin {
117
/**
128
* @param {?Object} options - Dev-Server options
@@ -252,10 +248,12 @@ class DevServerPlugin {
252248
additionalEntries.push(hotEntry);
253249
}
254250

251+
const webpack = compiler.webpack || require('webpack');
252+
255253
// use a hook to add entries if available
256-
if (EntryPlugin) {
254+
if (typeof webpack.EntryPlugin !== 'undefined') {
257255
for (const additionalEntry of additionalEntries) {
258-
new EntryPlugin(compiler.context, additionalEntry, {
256+
new webpack.EntryPlugin(compiler.context, additionalEntry, {
259257
// eslint-disable-next-line no-undefined
260258
name: undefined,
261259
}).apply(compiler);

0 commit comments

Comments
 (0)