Skip to content

Commit 2d35287

Browse files
style(utils/addEntries): cleaner variable naming (#1478)
1 parent 8ab9eb6 commit 2d35287

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

lib/utils/addEntries.js

+19-17
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,53 @@
11
'use strict';
22

33
/* eslint-disable
4+
no-shadow,
45
no-param-reassign,
6+
array-bracket-spacing,
57
space-before-function-paren
68
*/
79
const createDomain = require('./createDomain');
810

9-
function addEntries (webpackOptions, devServerOptions, server) {
10-
if (devServerOptions.inline !== false) {
11+
function addEntries (config, options, server) {
12+
if (options.inline !== false) {
1113
// we're stubbing the app in this method as it's static and doesn't require
1214
// a server to be supplied. createDomain requires an app with the
1315
// address() signature.
1416
const app = server || {
1517
address() {
16-
return { port: devServerOptions.port };
18+
return { port: options.port };
1719
}
1820
};
1921

20-
const domain = createDomain(devServerOptions, app);
21-
const devClient = [`${require.resolve('../../client/')}?${domain}`];
22+
const domain = createDomain(options, app);
23+
const entries = [ `${require.resolve('../../client/')}?${domain}` ];
2224

23-
if (devServerOptions.hotOnly) {
24-
devClient.push(require.resolve('webpack/hot/only-dev-server'));
25-
} else if (devServerOptions.hot) {
26-
devClient.push(require.resolve('webpack/hot/dev-server'));
25+
if (options.hotOnly) {
26+
entries.push(require.resolve('webpack/hot/only-dev-server'));
27+
} else if (options.hot) {
28+
entries.push(require.resolve('webpack/hot/dev-server'));
2729
}
2830

29-
const prependDevClient = (entry) => {
31+
const prependEntry = (entry) => {
3032
if (typeof entry === 'function') {
31-
return () => Promise.resolve(entry()).then(prependDevClient);
33+
return () => Promise.resolve(entry()).then(prependEntry);
3234
}
3335

3436
if (typeof entry === 'object' && !Array.isArray(entry)) {
35-
const entryClone = {};
37+
const clone = {};
3638

3739
Object.keys(entry).forEach((key) => {
38-
entryClone[key] = devClient.concat(entry[key]);
40+
clone[key] = entries.concat(entry[key]);
3941
});
4042

41-
return entryClone;
43+
return clone;
4244
}
4345

44-
return devClient.concat(entry);
46+
return entries.concat(entry);
4547
};
4648

47-
[].concat(webpackOptions).forEach((wpOpt) => {
48-
wpOpt.entry = prependDevClient(wpOpt.entry || './src');
49+
[].concat(config).forEach((config) => {
50+
config.entry = prependEntry(config.entry || './src');
4951
});
5052
}
5153
}

0 commit comments

Comments
 (0)