Skip to content

refactor: do not use webpack directly #3414

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

Merged
merged 1 commit into from
Jun 10, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class Server {
}

setupProgressPlugin() {
const { ProgressPlugin } = require('webpack');
const { ProgressPlugin } = this.compiler.webpack || require('webpack');

new ProgressPlugin((percent, msg, addInfo, pluginName) => {
percent = Math.floor(percent * 100);
Expand Down
10 changes: 4 additions & 6 deletions lib/utils/DevServerPlugin.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
'use strict';

const webpack = require('webpack');
const ipaddr = require('ipaddr.js');
const getSocketClientPath = require('./getSocketClientPath');

// @ts-ignore
const EntryPlugin = webpack.EntryPlugin;

class DevServerPlugin {
/**
* @param {?Object} options - Dev-Server options
Expand Down Expand Up @@ -252,10 +248,12 @@ class DevServerPlugin {
additionalEntries.push(hotEntry);
}

const webpack = compiler.webpack || require('webpack');

// use a hook to add entries if available
if (EntryPlugin) {
if (typeof webpack.EntryPlugin !== 'undefined') {
for (const additionalEntry of additionalEntries) {
new EntryPlugin(compiler.context, additionalEntry, {
new webpack.EntryPlugin(compiler.context, additionalEntry, {
// eslint-disable-next-line no-undefined
name: undefined,
}).apply(compiler);
Expand Down