Skip to content

Commit c41a47c

Browse files
alexander-akaitsnitin315
authored andcommitted
fix: empty entries
1 parent 599b63e commit c41a47c

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

lib/utils/DevServerPlugin.js

+23-21
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class DevServerPlugin {
3737
: '';
3838
/** @type {string} */
3939
let path = '';
40+
4041
// only add the path if it is not default
4142
if (
4243
options.client &&
@@ -45,11 +46,13 @@ class DevServerPlugin {
4546
) {
4647
path = `&path=${options.client.path}`;
4748
}
49+
4850
/** @type {string} */
4951
const port =
5052
options.client && options.client.port
5153
? `&port=${options.client.port}`
5254
: '';
55+
5356
/** @type {string} */
5457
const clientEntry = `${require.resolve(
5558
'../../client/default/'
@@ -119,14 +122,22 @@ class DevServerPlugin {
119122
*/
120123
// eslint-disable-next-line no-shadow
121124
const checkInject = (option, _config, defaultValue) => {
122-
if (typeof option === 'boolean') return option;
123-
if (typeof option === 'function') return option(_config);
125+
if (typeof option === 'boolean') {
126+
return option;
127+
}
128+
129+
if (typeof option === 'function') {
130+
return option(_config);
131+
}
132+
124133
return defaultValue;
125134
};
126135

127136
const compilerOptions = compiler.options;
137+
128138
compilerOptions.plugins = compilerOptions.plugins || [];
129-
/** @type {Boolean} */
139+
140+
/** @type {boolean} */
130141
const isWebTarget = compilerOptions.externalsPresets
131142
? compilerOptions.externalsPresets.web
132143
: [
@@ -138,6 +149,7 @@ class DevServerPlugin {
138149
undefined,
139150
null,
140151
].includes(compilerOptions.target);
152+
141153
/** @type {Entry} */
142154
const additionalEntries = checkInject(
143155
options.injectClient,
@@ -153,24 +165,12 @@ class DevServerPlugin {
153165

154166
// use a hook to add entries if available
155167
if (EntryPlugin) {
156-
compiler.hooks.make.tapPromise('DevServerPlugin', (compilation) =>
157-
Promise.all(
158-
additionalEntries.map(
159-
(entry) =>
160-
new Promise((resolve, reject) => {
161-
compilation.addEntry(
162-
compiler.context,
163-
EntryPlugin.createDependency(entry, {}),
164-
{}, // global entry
165-
(err) => {
166-
if (err) return reject(err);
167-
resolve();
168-
}
169-
);
170-
})
171-
)
172-
)
173-
);
168+
for (const additionalEntry of additionalEntries) {
169+
new EntryPlugin(compiler.context, additionalEntry, {
170+
// eslint-disable-next-line no-undefined
171+
name: undefined,
172+
}).apply(compiler);
173+
}
174174
} else {
175175
compilerOptions.entry = prependEntry(
176176
compilerOptions.entry || './src',
@@ -185,6 +185,7 @@ class DevServerPlugin {
185185
const providePlugin = new webpack.ProvidePlugin({
186186
__webpack_dev_server_client__: getSocketClientPath(options),
187187
});
188+
188189
providePlugin.apply(compiler);
189190

190191
if (
@@ -195,6 +196,7 @@ class DevServerPlugin {
195196
) {
196197
// apply the HMR plugin, if it didn't exist before.
197198
const plugin = new webpack.HotModuleReplacementPlugin();
199+
198200
plugin.apply(compiler);
199201
}
200202
}

lib/utils/updateCompiler.js

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const DevServerPlugin = require('./DevServerPlugin');
44

55
function updateCompiler(compiler, options) {
66
const compilers = compiler.compilers || [compiler];
7+
78
// eslint-disable-next-line no-shadow
89
compilers.forEach((compiler) => {
910
new DevServerPlugin(options).apply(compiler);

0 commit comments

Comments
 (0)