Skip to content

Commit e22295a

Browse files
authored
refactor: use spread (#3498)
1 parent 27ed238 commit e22295a

File tree

11 files changed

+156
-230
lines changed

11 files changed

+156
-230
lines changed

examples/api/simple/server.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ const WebpackDevServer = require('../../../lib/Server');
55
const webpackConfig = require('./webpack.config');
66

77
const compiler = Webpack(webpackConfig);
8-
const devServerOptions = Object.assign({}, webpackConfig.devServer, {
9-
open: true,
10-
});
8+
const devServerOptions = { ...webpackConfig.devServer, open: true };
119
const server = new WebpackDevServer(devServerOptions, compiler);
1210

1311
server.listen(8080, '127.0.0.1', () => {

examples/util.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module.exports = {
2323
}
2424
}
2525

26-
const result = Object.assign(defaults, config);
26+
const result = { ...defaults, ...config };
2727
const onBeforeSetupMiddleware = ({ app }) => {
2828
app.get('/.assets/*', (req, res) => {
2929
const filename = path.join(__dirname, '/', req.path);
@@ -87,7 +87,7 @@ module.exports = {
8787
};
8888

8989
if (result.output) {
90-
Object.assign(result.output, output);
90+
result.output = { ...result.output, ...output };
9191
} else {
9292
result.output = output;
9393
}

lib/utils/normalizeOptions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ function normalizeOptions(compiler, options, logger, cacheDir) {
262262
target: options.proxy[context],
263263
};
264264
} else {
265-
proxyOptions = Object.assign({}, options.proxy[context]);
265+
proxyOptions = { ...options.proxy[context] };
266266
proxyOptions.context = correctedContext;
267267
}
268268

test/e2e/hot-and-live-reload.test.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,11 @@ describe('hot and live reload', () => {
202202
);
203203

204204
const compiler = webpack(reloadConfig);
205-
const devServerOptions = Object.assign(
206-
{},
207-
{
208-
host: '0.0.0.0',
209-
port,
210-
},
211-
mode.options
212-
);
205+
const devServerOptions = {
206+
host: '0.0.0.0',
207+
port,
208+
...mode.options,
209+
};
213210
const server = new Server(devServerOptions, compiler);
214211

215212
await new Promise((resolve, reject) => {

test/e2e/logging.test.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,11 @@ describe('logging', () => {
189189
webSocketServer.webSocketServer || 'default'
190190
})`, async () => {
191191
const compiler = webpack({ ...config, ...testCase.webpackOptions });
192-
const devServerOptions = Object.assign(
193-
{},
194-
{
195-
host: '0.0.0.0',
196-
port,
197-
},
198-
testCase.devServerOptions
199-
);
192+
const devServerOptions = {
193+
host: '0.0.0.0',
194+
port,
195+
...testCase.devServerOptions,
196+
};
200197
const server = new Server(devServerOptions, compiler);
201198

202199
await new Promise((resolve, reject) => {

0 commit comments

Comments
 (0)