Skip to content

Commit

Permalink
refactor: move overlay option to client (#2888)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: the `overlay` option was moved into the `client` option
  • Loading branch information
hiroppy committed Dec 1, 2020
1 parent cee170c commit 763cde1
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 65 deletions.
4 changes: 2 additions & 2 deletions lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,8 @@ class Server {
this.sockWrite([connection], 'progress', this.options.client.progress);
}

if (this.options.clientOverlay) {
this.sockWrite([connection], 'overlay', this.options.clientOverlay);
if (this.options.client.overlay) {
this.sockWrite([connection], 'overlay', this.options.client.overlay);
}

if (!this.stats) {
Expand Down
37 changes: 18 additions & 19 deletions lib/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,24 @@
},
"progress": {
"type": "boolean"
},
"overlay": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "object",
"properties": {
"errors": {
"type": "boolean"
},
"warnings": {
"type": "boolean"
}
}
}
]
}
},
"additionalProperties": false
Expand Down Expand Up @@ -264,24 +282,6 @@
}
]
},
"overlay": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "object",
"properties": {
"errors": {
"type": "boolean"
},
"warnings": {
"type": "boolean"
}
}
}
]
},
"port": {
"anyOf": [
{
Expand Down Expand Up @@ -403,7 +403,6 @@
"onListening": "should be {Function} (https://webpack.js.org/configuration/dev-server/#onlistening)",
"open": "should be {String|Boolean|Object} (https://webpack.js.org/configuration/dev-server/#devserveropen)",
"openPage": "should be {String|Array} (https://webpack.js.org/configuration/dev-server/#devserveropenpage)",
"overlay": "should be {Boolean|Object} (https://webpack.js.org/configuration/dev-server/#devserveroverlay)",
"port": "should be {Number|String|Null} (https://webpack.js.org/configuration/dev-server/#devserverport)",
"proxy": "should be {Object|Array} (https://webpack.js.org/configuration/dev-server/#devserverproxy)",
"public": "should be {String} (https://webpack.js.org/configuration/dev-server/#devserverpublic)",
Expand Down
4 changes: 0 additions & 4 deletions test/Validation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ describe('Validation', () => {
name: 'invalid `injectHot` configuration',
config: { injectHot: 1 },
},
{
name: 'invalid `overlay` configuration',
config: { overlay: { errors: 1 } },
},
{
name: 'invalid `static` configuration',
config: { static: [0] },
Expand Down
7 changes: 1 addition & 6 deletions test/__snapshots__/Validation.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ exports[`Validation validation should fail validation for invalid \`injectHot\`
* configuration.injectHot should be an instance of function."
`;

exports[`Validation validation should fail validation for invalid \`overlay\` configuration 1`] = `
"Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
- configuration.overlay.errors should be a boolean."
`;

exports[`Validation validation should fail validation for invalid \`static\` configuration 1`] = `
"Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
- configuration.static should be one of these:
Expand All @@ -39,5 +34,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?, overlay?, port?, proxy?, public?, setupExitSignals?, static?, stdin?, transportMode?, useLocalIp? }"
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? }"
`;
84 changes: 50 additions & 34 deletions test/options.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,37 @@ describe('options', () => {
progress: false,
},
},
{
client: {
overlay: true,
},
},
{
client: {
overlay: {},
},
},
{
client: {
overlay: {
error: true,
},
},
},
{
client: {
overlay: {
warnings: true,
},
},
},
{
client: {
overlay: {
arbitrary: '',
},
},
},
],
failure: [
'whoops!',
Expand Down Expand Up @@ -237,6 +268,25 @@ describe('options', () => {
progress: '',
},
},
{
client: {
overlay: '',
},
},
{
client: {
overlay: {
errors: '',
},
},
},
{
client: {
overlay: {
warnings: '',
},
},
},
],
},
compress: {
Expand Down Expand Up @@ -327,40 +377,6 @@ describe('options', () => {
success: [''],
failure: [false],
},
overlay: {
success: [
true,
{},
{
overlay: {
errors: true,
},
},
{
overlay: {
warnings: true,
},
},
{
overlay: {
arbitrary: '',
},
},
],
failure: [
'',
{
overlay: {
errors: '',
},
},
{
overlay: {
warnings: '',
},
},
],
},
port: {
success: ['', 0, null],
failure: [false],
Expand Down

0 comments on commit 763cde1

Please sign in to comment.