Skip to content

Commit ca0b534

Browse files
authored
refactor: move injectClient and injectHot under client property (#3104)
BREAKING CHANGE: `injectClient` and `injectHot` was removed in favor `client.needClientEntry` and `client.needHotEntry`
1 parent 84dde53 commit ca0b534

File tree

3 files changed

+43
-37
lines changed

3 files changed

+43
-37
lines changed

lib/options.json

+20-22
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,26 @@
104104
}
105105
}
106106
]
107+
},
108+
"needClientEntry": {
109+
"anyOf": [
110+
{
111+
"type": "boolean"
112+
},
113+
{
114+
"instanceof": "Function"
115+
}
116+
]
117+
},
118+
"needHotEntry": {
119+
"anyOf": [
120+
{
121+
"type": "boolean"
122+
},
123+
{
124+
"instanceof": "Function"
125+
}
126+
]
107127
}
108128
},
109129
"additionalProperties": false
@@ -223,26 +243,6 @@
223243
}
224244
]
225245
},
226-
"injectClient": {
227-
"anyOf": [
228-
{
229-
"type": "boolean"
230-
},
231-
{
232-
"instanceof": "Function"
233-
}
234-
]
235-
},
236-
"injectHot": {
237-
"anyOf": [
238-
{
239-
"type": "boolean"
240-
},
241-
{
242-
"instanceof": "Function"
243-
}
244-
]
245-
},
246246
"liveReload": {
247247
"type": "boolean"
248248
},
@@ -395,8 +395,6 @@
395395
"hot": "should be {Boolean|String} (https://webpack.js.org/configuration/dev-server/#devserverhot)",
396396
"http2": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverhttp2)",
397397
"https": "should be {Object|Boolean} (https://webpack.js.org/configuration/dev-server/#devserverhttps)",
398-
"injectClient": "should be {Boolean|Function} (https://webpack.js.org/configuration/dev-server/#devserverinjectclient)",
399-
"injectHot": "should be {Boolean|Function} (https://webpack.js.org/configuration/dev-server/#devserverinjecthot)",
400398
"liveReload": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverlivereload)",
401399
"onAfterSetupMiddleware": "should be {Function} (https://webpack.js.org/configuration/dev-server/#devserverafter)",
402400
"onBeforeSetupMiddleware": "should be {Function} (https://webpack.js.org/configuration/dev-server/#devserverbefore)",

test/__snapshots__/Validation.test.js.snap

+3-6
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,8 @@ exports[`Validation validation should fail validation for invalid \`hot\` config
1111

1212
exports[`Validation validation should fail validation for invalid \`injectHot\` configuration 1`] = `
1313
"Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
14-
- configuration.injectHot should be one of these:
15-
boolean | function
16-
Details:
17-
* configuration.injectHot should be a boolean.
18-
* configuration.injectHot should be an instance of function."
14+
- configuration has an unknown property 'injectHot'. These properties are valid:
15+
object { bonjour?, client?, compress?, dev?, firewall?, headers?, historyApiFallback?, host?, hot?, http2?, https?, liveReload?, onAfterSetupMiddleware?, onBeforeSetupMiddleware?, onListening?, open?, openPage?, port?, proxy?, public?, setupExitSignals?, static?, stdin?, transportMode?, useLocalIp? }"
1916
`;
2017
2118
exports[`Validation validation should fail validation for invalid \`static\` configuration 1`] = `
@@ -34,5 +31,5 @@ exports[`Validation validation should fail validation for invalid \`static\` con
3431
exports[`Validation validation should fail validation for no additional properties 1`] = `
3532
"Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
3633
- configuration has an unknown property 'additional'. These properties are valid:
37-
object { bonjour?, client?, compress?, dev?, firewall?, headers?, historyApiFallback?, host?, hot?, http2?, https?, injectClient?, injectHot?, liveReload?, onAfterSetupMiddleware?, onBeforeSetupMiddleware?, onListening?, open?, openPage?, port?, proxy?, public?, setupExitSignals?, static?, stdin?, transportMode?, useLocalIp? }"
34+
object { bonjour?, client?, compress?, dev?, firewall?, headers?, historyApiFallback?, host?, hot?, http2?, https?, liveReload?, onAfterSetupMiddleware?, onBeforeSetupMiddleware?, onListening?, open?, openPage?, port?, proxy?, public?, setupExitSignals?, static?, stdin?, transportMode?, useLocalIp? }"
3835
`;

test/options.test.js

+20-9
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ describe('options', () => {
7676
if (typeof opts.static === 'undefined') {
7777
opts.static = false;
7878
}
79-
8079
server = new Server(compiler, opts);
8180
})
8281
.then(() => {
@@ -239,6 +238,16 @@ describe('options', () => {
239238
},
240239
},
241240
},
241+
{
242+
client: {
243+
needClientEntry: true,
244+
},
245+
},
246+
{
247+
client: {
248+
needHotEntry: true,
249+
},
250+
},
242251
],
243252
failure: [
244253
'whoops!',
@@ -288,6 +297,16 @@ describe('options', () => {
288297
},
289298
},
290299
},
300+
{
301+
client: {
302+
needClientEntry: [''],
303+
},
304+
},
305+
{
306+
client: {
307+
needHotEntry: [''],
308+
},
309+
},
291310
],
292311
},
293312
compress: {
@@ -358,14 +377,6 @@ describe('options', () => {
358377
},
359378
],
360379
},
361-
injectClient: {
362-
success: [true, () => {}],
363-
failure: [''],
364-
},
365-
injectHot: {
366-
success: [true, () => {}],
367-
failure: [''],
368-
},
369380
onListening: {
370381
success: [() => {}],
371382
failure: [''],

0 commit comments

Comments
 (0)