Skip to content

Commit

Permalink
refactor: move injectClient and injectHot under client property (#3104)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: `injectClient` and `injectHot` was removed in favor `client.needClientEntry` and `client.needHotEntry`
  • Loading branch information
anshumanv authored Mar 26, 2021
1 parent 84dde53 commit ca0b534
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 37 deletions.
42 changes: 20 additions & 22 deletions lib/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,26 @@
}
}
]
},
"needClientEntry": {
"anyOf": [
{
"type": "boolean"
},
{
"instanceof": "Function"
}
]
},
"needHotEntry": {
"anyOf": [
{
"type": "boolean"
},
{
"instanceof": "Function"
}
]
}
},
"additionalProperties": false
Expand Down Expand Up @@ -223,26 +243,6 @@
}
]
},
"injectClient": {
"anyOf": [
{
"type": "boolean"
},
{
"instanceof": "Function"
}
]
},
"injectHot": {
"anyOf": [
{
"type": "boolean"
},
{
"instanceof": "Function"
}
]
},
"liveReload": {
"type": "boolean"
},
Expand Down Expand Up @@ -395,8 +395,6 @@
"hot": "should be {Boolean|String} (https://webpack.js.org/configuration/dev-server/#devserverhot)",
"http2": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverhttp2)",
"https": "should be {Object|Boolean} (https://webpack.js.org/configuration/dev-server/#devserverhttps)",
"injectClient": "should be {Boolean|Function} (https://webpack.js.org/configuration/dev-server/#devserverinjectclient)",
"injectHot": "should be {Boolean|Function} (https://webpack.js.org/configuration/dev-server/#devserverinjecthot)",
"liveReload": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverlivereload)",
"onAfterSetupMiddleware": "should be {Function} (https://webpack.js.org/configuration/dev-server/#devserverafter)",
"onBeforeSetupMiddleware": "should be {Function} (https://webpack.js.org/configuration/dev-server/#devserverbefore)",
Expand Down
9 changes: 3 additions & 6 deletions test/__snapshots__/Validation.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ exports[`Validation validation should fail validation for invalid \`hot\` config

exports[`Validation validation should fail validation for invalid \`injectHot\` configuration 1`] = `
"Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
- configuration.injectHot should be one of these:
boolean | function
Details:
* configuration.injectHot should be a boolean.
* configuration.injectHot should be an instance of function."
- configuration has an unknown property 'injectHot'. These properties are valid:
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? }"
`;
exports[`Validation validation should fail validation for invalid \`static\` configuration 1`] = `
Expand All @@ -34,5 +31,5 @@ exports[`Validation validation should fail validation for invalid \`static\` con
exports[`Validation validation should fail validation for no additional properties 1`] = `
"Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
- configuration has an unknown property 'additional'. These properties are valid:
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? }"
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? }"
`;
29 changes: 20 additions & 9 deletions test/options.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ describe('options', () => {
if (typeof opts.static === 'undefined') {
opts.static = false;
}

server = new Server(compiler, opts);
})
.then(() => {
Expand Down Expand Up @@ -239,6 +238,16 @@ describe('options', () => {
},
},
},
{
client: {
needClientEntry: true,
},
},
{
client: {
needHotEntry: true,
},
},
],
failure: [
'whoops!',
Expand Down Expand Up @@ -288,6 +297,16 @@ describe('options', () => {
},
},
},
{
client: {
needClientEntry: [''],
},
},
{
client: {
needHotEntry: [''],
},
},
],
},
compress: {
Expand Down Expand Up @@ -358,14 +377,6 @@ describe('options', () => {
},
],
},
injectClient: {
success: [true, () => {}],
failure: [''],
},
injectHot: {
success: [true, () => {}],
failure: [''],
},
onListening: {
success: [() => {}],
failure: [''],
Expand Down

0 comments on commit ca0b534

Please sign in to comment.