Skip to content

Commit 9b99716

Browse files
committed
fix: output more information on errors
1 parent 50b2b86 commit 9b99716

5 files changed

+56
-15
lines changed

package-lock.json

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"memfs": "^3.2.2",
4646
"mime-types": "^2.1.31",
4747
"range-parser": "^1.2.1",
48-
"schema-utils": "^3.0.0"
48+
"schema-utils": "^3.1.0"
4949
},
5050
"devDependencies": {
5151
"@babel/cli": "^7.14.5",

src/options.json

+11-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
"properties": {
44
"mimeTypes": {
55
"description": "Allows a user to register custom mime types or extension mappings.",
6+
"link": "https://github.com/webpack/webpack-dev-middleware#mimetypes",
67
"type": "object"
78
},
89
"writeToDisk": {
910
"description": "Allows to write generated files on disk.",
11+
"link": "https://github.com/webpack/webpack-dev-middleware#writetodisk",
1012
"anyOf": [
1113
{
1214
"type": "boolean"
@@ -18,6 +20,7 @@
1820
},
1921
"methods": {
2022
"description": "Allows to pass the list of HTTP request methods accepted by the middleware.",
23+
"link": "https://github.com/webpack/webpack-dev-middleware#methods",
2124
"type": "array",
2225
"items": {
2326
"type": "string",
@@ -32,10 +35,13 @@
3235
{
3336
"instanceof": "Function"
3437
}
35-
]
38+
],
39+
"description": "Allows to pass custom HTTP headers on each request",
40+
"link": "https://github.com/webpack/webpack-dev-middleware#headers"
3641
},
3742
"publicPath": {
3843
"description": "The `publicPath` specifies the public URL address of the output files when referenced in a browser.",
44+
"link": "https://github.com/webpack/webpack-dev-middleware#publicpath",
3945
"anyOf": [
4046
{
4147
"enum": ["auto"]
@@ -50,6 +56,7 @@
5056
},
5157
"stats": {
5258
"description": "Stats options object or preset name.",
59+
"link": "https://github.com/webpack/webpack-dev-middleware#stats",
5360
"anyOf": [
5461
{
5562
"enum": [
@@ -74,14 +81,17 @@
7481
},
7582
"serverSideRender": {
7683
"description": "Instructs the module to enable or disable the server-side rendering mode.",
84+
"link": "https://github.com/webpack/webpack-dev-middleware#serversiderender",
7785
"type": "boolean"
7886
},
7987
"outputFileSystem": {
8088
"description": "Set the default file system which will be used by webpack as primary destination of generated files.",
89+
"link": "https://github.com/webpack/webpack-dev-middleware#outputfilesystem",
8190
"type": "object"
8291
},
8392
"index": {
8493
"description": "Allows to serve an index of the directory.",
94+
"link": "https://github.com/webpack/webpack-dev-middleware#index",
8595
"anyOf": [
8696
{
8797
"type": "boolean"

test/__snapshots__/validation-options.test.js.snap.webpack4

+21-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ exports[`validation should throw an error on the "headers" option with "1" value
44
"Invalid options object. Dev Middleware has been initialized using an options object that does not match the API schema.
55
- options.headers should be one of these:
66
object { … } | function
7+
-> Allows to pass custom HTTP headers on each request
8+
-> Read more at https://github.com/webpack/webpack-dev-middleware#headers
79
Details:
810
* options.headers should be an object:
911
object { … }
@@ -14,6 +16,8 @@ exports[`validation should throw an error on the "headers" option with "true" va
1416
"Invalid options object. Dev Middleware has been initialized using an options object that does not match the API schema.
1517
- options.headers should be one of these:
1618
object { … } | function
19+
-> Allows to pass custom HTTP headers on each request
20+
-> Read more at https://github.com/webpack/webpack-dev-middleware#headers
1721
Details:
1822
* options.headers should be an object:
1923
object { … }
@@ -25,6 +29,7 @@ exports[`validation should throw an error on the "index" option with "{}" value
2529
- options.index should be one of these:
2630
boolean | string
2731
-> Allows to serve an index of the directory.
32+
-> Read more at https://github.com/webpack/webpack-dev-middleware#index
2833
Details:
2934
* options.index should be a boolean.
3035
* options.index should be a string."
@@ -35,6 +40,7 @@ exports[`validation should throw an error on the "index" option with "0" value 1
3540
- options.index should be one of these:
3641
boolean | string
3742
-> Allows to serve an index of the directory.
43+
-> Read more at https://github.com/webpack/webpack-dev-middleware#index
3844
Details:
3945
* options.index should be a boolean.
4046
* options.index should be a string."
@@ -44,35 +50,40 @@ exports[`validation should throw an error on the "methods" option with "{}" valu
4450
"Invalid options object. Dev Middleware has been initialized using an options object that does not match the API schema.
4551
- options.methods should be an array:
4652
[string, ...]
47-
-> Allows to pass the list of HTTP request methods accepted by the middleware."
53+
-> Allows to pass the list of HTTP request methods accepted by the middleware.
54+
-> Read more at https://github.com/webpack/webpack-dev-middleware#methods"
4855
`;
4956

5057
exports[`validation should throw an error on the "methods" option with "true" value 1`] = `
5158
"Invalid options object. Dev Middleware has been initialized using an options object that does not match the API schema.
5259
- options.methods should be an array:
5360
[string, ...]
54-
-> Allows to pass the list of HTTP request methods accepted by the middleware."
61+
-> Allows to pass the list of HTTP request methods accepted by the middleware.
62+
-> Read more at https://github.com/webpack/webpack-dev-middleware#methods"
5563
`;
5664

5765
exports[`validation should throw an error on the "mimeTypes" option with "foo" value 1`] = `
5866
"Invalid options object. Dev Middleware has been initialized using an options object that does not match the API schema.
5967
- options.mimeTypes should be an object:
6068
object { … }
61-
-> Allows a user to register custom mime types or extension mappings."
69+
-> Allows a user to register custom mime types or extension mappings.
70+
-> Read more at https://github.com/webpack/webpack-dev-middleware#mimetypes"
6271
`;
6372

6473
exports[`validation should throw an error on the "outputFileSystem" option with "false" value 1`] = `
6574
"Invalid options object. Dev Middleware has been initialized using an options object that does not match the API schema.
6675
- options.outputFileSystem should be an object:
6776
object { … }
68-
-> Set the default file system which will be used by webpack as primary destination of generated files."
77+
-> Set the default file system which will be used by webpack as primary destination of generated files.
78+
-> Read more at https://github.com/webpack/webpack-dev-middleware#outputfilesystem"
6979
`;
7080

7181
exports[`validation should throw an error on the "publicPath" option with "false" value 1`] = `
7282
"Invalid options object. Dev Middleware has been initialized using an options object that does not match the API schema.
7383
- options.publicPath should be one of these:
7484
\\"auto\\" | string | function
7585
-> The \`publicPath\` specifies the public URL address of the output files when referenced in a browser.
86+
-> Read more at https://github.com/webpack/webpack-dev-middleware#publicpath
7687
Details:
7788
* options.publicPath should be \\"auto\\".
7889
* options.publicPath should be a string.
@@ -82,20 +93,23 @@ exports[`validation should throw an error on the "publicPath" option with "false
8293
exports[`validation should throw an error on the "serverSideRender" option with "0" value 1`] = `
8394
"Invalid options object. Dev Middleware has been initialized using an options object that does not match the API schema.
8495
- options.serverSideRender should be a boolean.
85-
-> Instructs the module to enable or disable the server-side rendering mode."
96+
-> Instructs the module to enable or disable the server-side rendering mode.
97+
-> Read more at https://github.com/webpack/webpack-dev-middleware#serversiderender"
8698
`;
8799

88100
exports[`validation should throw an error on the "serverSideRender" option with "foo" value 1`] = `
89101
"Invalid options object. Dev Middleware has been initialized using an options object that does not match the API schema.
90102
- options.serverSideRender should be a boolean.
91-
-> Instructs the module to enable or disable the server-side rendering mode."
103+
-> Instructs the module to enable or disable the server-side rendering mode.
104+
-> Read more at https://github.com/webpack/webpack-dev-middleware#serversiderender"
92105
`;
93106

94107
exports[`validation should throw an error on the "stats" option with "0" value 1`] = `
95108
"Invalid options object. Dev Middleware has been initialized using an options object that does not match the API schema.
96109
- options.stats should be one of these:
97110
\\"none\\" | \\"summary\\" | \\"errors-only\\" | \\"errors-warnings\\" | \\"minimal\\" | \\"normal\\" | \\"detailed\\" | \\"verbose\\" | boolean | object { … }
98111
-> Stats options object or preset name.
112+
-> Read more at https://github.com/webpack/webpack-dev-middleware#stats
99113
Details:
100114
* options.stats should be one of these:
101115
\\"none\\" | \\"summary\\" | \\"errors-only\\" | \\"errors-warnings\\" | \\"minimal\\" | \\"normal\\" | \\"detailed\\" | \\"verbose\\"
@@ -109,6 +123,7 @@ exports[`validation should throw an error on the "writeToDisk" option with "{}"
109123
- options.writeToDisk should be one of these:
110124
boolean | function
111125
-> Allows to write generated files on disk.
126+
-> Read more at https://github.com/webpack/webpack-dev-middleware#writetodisk
112127
Details:
113128
* options.writeToDisk should be a boolean.
114129
* options.writeToDisk should be an instance of function."

test/__snapshots__/validation-options.test.js.snap.webpack5

+21-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ exports[`validation should throw an error on the "headers" option with "1" value
44
"Invalid options object. Dev Middleware has been initialized using an options object that does not match the API schema.
55
- options.headers should be one of these:
66
object { … } | function
7+
-> Allows to pass custom HTTP headers on each request
8+
-> Read more at https://github.com/webpack/webpack-dev-middleware#headers
79
Details:
810
* options.headers should be an object:
911
object { … }
@@ -14,6 +16,8 @@ exports[`validation should throw an error on the "headers" option with "true" va
1416
"Invalid options object. Dev Middleware has been initialized using an options object that does not match the API schema.
1517
- options.headers should be one of these:
1618
object { … } | function
19+
-> Allows to pass custom HTTP headers on each request
20+
-> Read more at https://github.com/webpack/webpack-dev-middleware#headers
1721
Details:
1822
* options.headers should be an object:
1923
object { … }
@@ -25,6 +29,7 @@ exports[`validation should throw an error on the "index" option with "{}" value
2529
- options.index should be one of these:
2630
boolean | string
2731
-> Allows to serve an index of the directory.
32+
-> Read more at https://github.com/webpack/webpack-dev-middleware#index
2833
Details:
2934
* options.index should be a boolean.
3035
* options.index should be a string."
@@ -35,6 +40,7 @@ exports[`validation should throw an error on the "index" option with "0" value 1
3540
- options.index should be one of these:
3641
boolean | string
3742
-> Allows to serve an index of the directory.
43+
-> Read more at https://github.com/webpack/webpack-dev-middleware#index
3844
Details:
3945
* options.index should be a boolean.
4046
* options.index should be a string."
@@ -44,35 +50,40 @@ exports[`validation should throw an error on the "methods" option with "{}" valu
4450
"Invalid options object. Dev Middleware has been initialized using an options object that does not match the API schema.
4551
- options.methods should be an array:
4652
[string, ...]
47-
-> Allows to pass the list of HTTP request methods accepted by the middleware."
53+
-> Allows to pass the list of HTTP request methods accepted by the middleware.
54+
-> Read more at https://github.com/webpack/webpack-dev-middleware#methods"
4855
`;
4956

5057
exports[`validation should throw an error on the "methods" option with "true" value 1`] = `
5158
"Invalid options object. Dev Middleware has been initialized using an options object that does not match the API schema.
5259
- options.methods should be an array:
5360
[string, ...]
54-
-> Allows to pass the list of HTTP request methods accepted by the middleware."
61+
-> Allows to pass the list of HTTP request methods accepted by the middleware.
62+
-> Read more at https://github.com/webpack/webpack-dev-middleware#methods"
5563
`;
5664

5765
exports[`validation should throw an error on the "mimeTypes" option with "foo" value 1`] = `
5866
"Invalid options object. Dev Middleware has been initialized using an options object that does not match the API schema.
5967
- options.mimeTypes should be an object:
6068
object { … }
61-
-> Allows a user to register custom mime types or extension mappings."
69+
-> Allows a user to register custom mime types or extension mappings.
70+
-> Read more at https://github.com/webpack/webpack-dev-middleware#mimetypes"
6271
`;
6372

6473
exports[`validation should throw an error on the "outputFileSystem" option with "false" value 1`] = `
6574
"Invalid options object. Dev Middleware has been initialized using an options object that does not match the API schema.
6675
- options.outputFileSystem should be an object:
6776
object { … }
68-
-> Set the default file system which will be used by webpack as primary destination of generated files."
77+
-> Set the default file system which will be used by webpack as primary destination of generated files.
78+
-> Read more at https://github.com/webpack/webpack-dev-middleware#outputfilesystem"
6979
`;
7080

7181
exports[`validation should throw an error on the "publicPath" option with "false" value 1`] = `
7282
"Invalid options object. Dev Middleware has been initialized using an options object that does not match the API schema.
7383
- options.publicPath should be one of these:
7484
\\"auto\\" | string | function
7585
-> The \`publicPath\` specifies the public URL address of the output files when referenced in a browser.
86+
-> Read more at https://github.com/webpack/webpack-dev-middleware#publicpath
7687
Details:
7788
* options.publicPath should be \\"auto\\".
7889
* options.publicPath should be a string.
@@ -82,20 +93,23 @@ exports[`validation should throw an error on the "publicPath" option with "false
8293
exports[`validation should throw an error on the "serverSideRender" option with "0" value 1`] = `
8394
"Invalid options object. Dev Middleware has been initialized using an options object that does not match the API schema.
8495
- options.serverSideRender should be a boolean.
85-
-> Instructs the module to enable or disable the server-side rendering mode."
96+
-> Instructs the module to enable or disable the server-side rendering mode.
97+
-> Read more at https://github.com/webpack/webpack-dev-middleware#serversiderender"
8698
`;
8799

88100
exports[`validation should throw an error on the "serverSideRender" option with "foo" value 1`] = `
89101
"Invalid options object. Dev Middleware has been initialized using an options object that does not match the API schema.
90102
- options.serverSideRender should be a boolean.
91-
-> Instructs the module to enable or disable the server-side rendering mode."
103+
-> Instructs the module to enable or disable the server-side rendering mode.
104+
-> Read more at https://github.com/webpack/webpack-dev-middleware#serversiderender"
92105
`;
93106

94107
exports[`validation should throw an error on the "stats" option with "0" value 1`] = `
95108
"Invalid options object. Dev Middleware has been initialized using an options object that does not match the API schema.
96109
- options.stats should be one of these:
97110
\\"none\\" | \\"summary\\" | \\"errors-only\\" | \\"errors-warnings\\" | \\"minimal\\" | \\"normal\\" | \\"detailed\\" | \\"verbose\\" | boolean | object { … }
98111
-> Stats options object or preset name.
112+
-> Read more at https://github.com/webpack/webpack-dev-middleware#stats
99113
Details:
100114
* options.stats should be one of these:
101115
\\"none\\" | \\"summary\\" | \\"errors-only\\" | \\"errors-warnings\\" | \\"minimal\\" | \\"normal\\" | \\"detailed\\" | \\"verbose\\"
@@ -109,6 +123,7 @@ exports[`validation should throw an error on the "writeToDisk" option with "{}"
109123
- options.writeToDisk should be one of these:
110124
boolean | function
111125
-> Allows to write generated files on disk.
126+
-> Read more at https://github.com/webpack/webpack-dev-middleware#writetodisk
112127
Details:
113128
* options.writeToDisk should be a boolean.
114129
* options.writeToDisk should be an instance of function."

0 commit comments

Comments
 (0)