webpack-dev-server 2.4.2 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -20
- package/README.md +86 -86
- package/bin/webpack-dev-server.js +45 -4
- package/client/index.bundle.js +1 -1
- package/client/index.js +188 -181
- package/client/live.bundle.js +3 -3
- package/client/live.html +1 -1
- package/client/live.js +119 -119
- package/client/overlay.js +126 -126
- package/client/page.pug +7 -7
- package/client/socket.js +41 -41
- package/client/sockjs.bundle.js +1 -1
- package/client/sockjs.js +1 -1
- package/client/style.css +58 -58
- package/client/web_modules/jquery/index.js +1 -1
- package/client/web_modules/jquery/jquery-1.8.1.js +9301 -9301
- package/client/webpack.config.js +19 -19
- package/client/webpack.sockjs.config.js +6 -6
- package/lib/OptionsValidationError.js +159 -159
- package/lib/Server.js +599 -509
- package/lib/optionsSchema.json +312 -289
- package/lib/util/addDevServerEntrypoints.js +26 -26
- package/lib/util/createDomain.js +14 -13
- package/package.json +6 -2
- package/ssl/.gitkeep +0 -0
- package/ssl/server.pem +0 -46
package/client/webpack.config.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
module: {
|
|
3
|
-
rules: [
|
|
4
|
-
{
|
|
5
|
-
test: /\.pug$/,
|
|
6
|
-
use: [
|
|
7
|
-
"pug-loader?self",
|
|
8
|
-
]
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
test: /\.css$/,
|
|
12
|
-
use: [
|
|
13
|
-
"style-loader",
|
|
14
|
-
"css-loader"
|
|
15
|
-
],
|
|
16
|
-
}
|
|
17
|
-
]
|
|
18
|
-
}
|
|
19
|
-
};
|
|
1
|
+
module.exports = {
|
|
2
|
+
module: {
|
|
3
|
+
rules: [
|
|
4
|
+
{
|
|
5
|
+
test: /\.pug$/,
|
|
6
|
+
use: [
|
|
7
|
+
"pug-loader?self",
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
test: /\.css$/,
|
|
12
|
+
use: [
|
|
13
|
+
"style-loader",
|
|
14
|
+
"css-loader"
|
|
15
|
+
],
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
output: {
|
|
3
|
-
library: "SockJS",
|
|
4
|
-
libraryTarget: "umd"
|
|
5
|
-
}
|
|
6
|
-
}
|
|
1
|
+
module.exports = {
|
|
2
|
+
output: {
|
|
3
|
+
library: "SockJS",
|
|
4
|
+
libraryTarget: "umd"
|
|
5
|
+
}
|
|
6
|
+
}
|
|
@@ -1,159 +1,159 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const optionsSchema = require("./optionsSchema.json");
|
|
4
|
-
|
|
5
|
-
const getSchemaPart = (path, parents, additionalPath) => {
|
|
6
|
-
parents = parents || 0;
|
|
7
|
-
path = path.split("/");
|
|
8
|
-
path = path.slice(0, path.length - parents);
|
|
9
|
-
if(additionalPath) {
|
|
10
|
-
additionalPath = additionalPath.split("/");
|
|
11
|
-
path = path.concat(additionalPath);
|
|
12
|
-
}
|
|
13
|
-
let schemaPart = optionsSchema;
|
|
14
|
-
for(let i = 1; i < path.length; i++) {
|
|
15
|
-
const inner = schemaPart[path[i]];
|
|
16
|
-
if(inner)
|
|
17
|
-
schemaPart = inner;
|
|
18
|
-
}
|
|
19
|
-
return schemaPart;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const getSchemaPartText = (schemaPart, additionalPath) => {
|
|
23
|
-
if(additionalPath) {
|
|
24
|
-
for(let i = 0; i < additionalPath.length; i++) {
|
|
25
|
-
const inner = schemaPart[additionalPath[i]];
|
|
26
|
-
if(inner)
|
|
27
|
-
schemaPart = inner;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
while(schemaPart.$ref) schemaPart = getSchemaPart(schemaPart.$ref);
|
|
31
|
-
let schemaText = OptionsValidationError.formatSchema(schemaPart);
|
|
32
|
-
if(schemaPart.description)
|
|
33
|
-
schemaText += `\n${schemaPart.description}`;
|
|
34
|
-
return schemaText;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const indent = (str, prefix, firstLine) => {
|
|
38
|
-
if(firstLine) {
|
|
39
|
-
return prefix + str.replace(/\n(?!$)/g, "\n" + prefix);
|
|
40
|
-
} else {
|
|
41
|
-
return str.replace(/\n(?!$)/g, `\n${prefix}`);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
class OptionsValidationError extends Error {
|
|
46
|
-
|
|
47
|
-
constructor(validationErrors) {
|
|
48
|
-
super();
|
|
49
|
-
|
|
50
|
-
if(Error.hasOwnProperty("captureStackTrace")) {
|
|
51
|
-
Error.captureStackTrace(this, this.constructor);
|
|
52
|
-
}
|
|
53
|
-
this.name = "WebpackDevServerOptionsValidationError";
|
|
54
|
-
|
|
55
|
-
this.message = "Invalid configuration object. " +
|
|
56
|
-
"webpack-dev-server has been initialised using a configuration object that does not match the API schema.\n" +
|
|
57
|
-
validationErrors.map(err => " - " + indent(OptionsValidationError.formatValidationError(err), " ", false)).join("\n");
|
|
58
|
-
this.validationErrors = validationErrors;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
static formatSchema(schema, prevSchemas) {
|
|
62
|
-
prevSchemas = prevSchemas || [];
|
|
63
|
-
|
|
64
|
-
const formatInnerSchema = (innerSchema, addSelf) => {
|
|
65
|
-
if(!addSelf) return OptionsValidationError.formatSchema(innerSchema, prevSchemas);
|
|
66
|
-
if(prevSchemas.indexOf(innerSchema) >= 0) return "(recursive)";
|
|
67
|
-
return OptionsValidationError.formatSchema(innerSchema, prevSchemas.concat(schema));
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
if(schema.type === "string") {
|
|
71
|
-
if(schema.minLength === 1)
|
|
72
|
-
return "non-empty string";
|
|
73
|
-
else if(schema.minLength > 1)
|
|
74
|
-
return `string (min length ${schema.minLength})`;
|
|
75
|
-
return "string";
|
|
76
|
-
} else if(schema.type === "boolean") {
|
|
77
|
-
return "boolean";
|
|
78
|
-
} else if(schema.type === "number") {
|
|
79
|
-
return "number";
|
|
80
|
-
} else if(schema.type === "object") {
|
|
81
|
-
if(schema.properties) {
|
|
82
|
-
const required = schema.required || [];
|
|
83
|
-
return `object { ${Object.keys(schema.properties).map(property => {
|
|
84
|
-
if(required.indexOf(property) < 0) return property + "?";
|
|
85
|
-
return property;
|
|
86
|
-
}).concat(schema.additionalProperties ? ["..."] : []).join(", ")} }`;
|
|
87
|
-
}
|
|
88
|
-
if(schema.additionalProperties) {
|
|
89
|
-
return `object { <key>: ${formatInnerSchema(schema.additionalProperties)} }`;
|
|
90
|
-
}
|
|
91
|
-
return "object";
|
|
92
|
-
} else if(schema.type === "array") {
|
|
93
|
-
return `[${formatInnerSchema(schema.items)}]`;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
switch(schema.instanceof) {
|
|
97
|
-
case "Function":
|
|
98
|
-
return "function";
|
|
99
|
-
case "RegExp":
|
|
100
|
-
return "RegExp";
|
|
101
|
-
}
|
|
102
|
-
if(schema.$ref) return formatInnerSchema(getSchemaPart(schema.$ref), true);
|
|
103
|
-
if(schema.allOf) return schema.allOf.map(formatInnerSchema).join(" & ");
|
|
104
|
-
if(schema.oneOf) return schema.oneOf.map(formatInnerSchema).join(" | ");
|
|
105
|
-
if(schema.anyOf) return schema.anyOf.map(formatInnerSchema).join(" | ");
|
|
106
|
-
if(schema.enum) return schema.enum.map(item => JSON.stringify(item)).join(" | ");
|
|
107
|
-
return JSON.stringify(schema, 0, 2);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
static formatValidationError(err) {
|
|
111
|
-
const dataPath = `configuration${err.dataPath}`;
|
|
112
|
-
if(err.keyword === "additionalProperties") {
|
|
113
|
-
return `${dataPath} has an unknown property '${err.params.additionalProperty}'. These properties are valid:\n${getSchemaPartText(err.parentSchema)}`;
|
|
114
|
-
} else if(err.keyword === "oneOf" || err.keyword === "anyOf") {
|
|
115
|
-
if(err.children && err.children.length > 0) {
|
|
116
|
-
return `${dataPath} should be one of these:\n${getSchemaPartText(err.parentSchema)}\n` +
|
|
117
|
-
`Details:\n${err.children.map(err => " * " + indent(OptionsValidationError.formatValidationError(err), " ", false)).join("\n")}`;
|
|
118
|
-
}
|
|
119
|
-
return `${dataPath} should be one of these:\n${getSchemaPartText(err.parentSchema)}`;
|
|
120
|
-
|
|
121
|
-
} else if(err.keyword === "enum") {
|
|
122
|
-
if(err.parentSchema && err.parentSchema.enum && err.parentSchema.enum.length === 1) {
|
|
123
|
-
return `${dataPath} should be ${getSchemaPartText(err.parentSchema)}`;
|
|
124
|
-
}
|
|
125
|
-
return `${dataPath} should be one of these:\n${getSchemaPartText(err.parentSchema)}`;
|
|
126
|
-
} else if(err.keyword === "allOf") {
|
|
127
|
-
return `${dataPath} should be:\n${getSchemaPartText(err.parentSchema)}`;
|
|
128
|
-
} else if(err.keyword === "type") {
|
|
129
|
-
switch(err.params.type) {
|
|
130
|
-
case "object":
|
|
131
|
-
return `${dataPath} should be an object.`;
|
|
132
|
-
case "string":
|
|
133
|
-
return `${dataPath} should be a string.`;
|
|
134
|
-
case "boolean":
|
|
135
|
-
return `${dataPath} should be a boolean.`;
|
|
136
|
-
case "number":
|
|
137
|
-
return `${dataPath} should be a number.`;
|
|
138
|
-
case "array":
|
|
139
|
-
return `${dataPath} should be an array:\n${getSchemaPartText(err.parentSchema)}`;
|
|
140
|
-
}
|
|
141
|
-
return `${dataPath} should be ${err.params.type}:\n${getSchemaPartText(err.parentSchema)}`;
|
|
142
|
-
} else if(err.keyword === "instanceof") {
|
|
143
|
-
return `${dataPath} should be an instance of ${getSchemaPartText(err.parentSchema)}.`;
|
|
144
|
-
} else if(err.keyword === "required") {
|
|
145
|
-
const missingProperty = err.params.missingProperty.replace(/^\./, "");
|
|
146
|
-
return `${dataPath} misses the property '${missingProperty}'.\n${getSchemaPartText(err.parentSchema, ["properties", missingProperty])}`;
|
|
147
|
-
} else if(err.keyword === "minLength" || err.keyword === "minItems") {
|
|
148
|
-
if(err.params.limit === 1)
|
|
149
|
-
return `${dataPath} should not be empty.`;
|
|
150
|
-
else
|
|
151
|
-
return `${dataPath} ${err.message}`;
|
|
152
|
-
} else {
|
|
153
|
-
// eslint-disable-line no-fallthrough
|
|
154
|
-
return `${dataPath} ${err.message} (${JSON.stringify(err, 0, 2)}).\n${getSchemaPartText(err.parentSchema)}`;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
module.exports = OptionsValidationError;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const optionsSchema = require("./optionsSchema.json");
|
|
4
|
+
|
|
5
|
+
const getSchemaPart = (path, parents, additionalPath) => {
|
|
6
|
+
parents = parents || 0;
|
|
7
|
+
path = path.split("/");
|
|
8
|
+
path = path.slice(0, path.length - parents);
|
|
9
|
+
if(additionalPath) {
|
|
10
|
+
additionalPath = additionalPath.split("/");
|
|
11
|
+
path = path.concat(additionalPath);
|
|
12
|
+
}
|
|
13
|
+
let schemaPart = optionsSchema;
|
|
14
|
+
for(let i = 1; i < path.length; i++) {
|
|
15
|
+
const inner = schemaPart[path[i]];
|
|
16
|
+
if(inner)
|
|
17
|
+
schemaPart = inner;
|
|
18
|
+
}
|
|
19
|
+
return schemaPart;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const getSchemaPartText = (schemaPart, additionalPath) => {
|
|
23
|
+
if(additionalPath) {
|
|
24
|
+
for(let i = 0; i < additionalPath.length; i++) {
|
|
25
|
+
const inner = schemaPart[additionalPath[i]];
|
|
26
|
+
if(inner)
|
|
27
|
+
schemaPart = inner;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
while(schemaPart.$ref) schemaPart = getSchemaPart(schemaPart.$ref);
|
|
31
|
+
let schemaText = OptionsValidationError.formatSchema(schemaPart);
|
|
32
|
+
if(schemaPart.description)
|
|
33
|
+
schemaText += `\n${schemaPart.description}`;
|
|
34
|
+
return schemaText;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const indent = (str, prefix, firstLine) => {
|
|
38
|
+
if(firstLine) {
|
|
39
|
+
return prefix + str.replace(/\n(?!$)/g, "\n" + prefix);
|
|
40
|
+
} else {
|
|
41
|
+
return str.replace(/\n(?!$)/g, `\n${prefix}`);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
class OptionsValidationError extends Error {
|
|
46
|
+
|
|
47
|
+
constructor(validationErrors) {
|
|
48
|
+
super();
|
|
49
|
+
|
|
50
|
+
if(Error.hasOwnProperty("captureStackTrace")) {
|
|
51
|
+
Error.captureStackTrace(this, this.constructor);
|
|
52
|
+
}
|
|
53
|
+
this.name = "WebpackDevServerOptionsValidationError";
|
|
54
|
+
|
|
55
|
+
this.message = "Invalid configuration object. " +
|
|
56
|
+
"webpack-dev-server has been initialised using a configuration object that does not match the API schema.\n" +
|
|
57
|
+
validationErrors.map(err => " - " + indent(OptionsValidationError.formatValidationError(err), " ", false)).join("\n");
|
|
58
|
+
this.validationErrors = validationErrors;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static formatSchema(schema, prevSchemas) {
|
|
62
|
+
prevSchemas = prevSchemas || [];
|
|
63
|
+
|
|
64
|
+
const formatInnerSchema = (innerSchema, addSelf) => {
|
|
65
|
+
if(!addSelf) return OptionsValidationError.formatSchema(innerSchema, prevSchemas);
|
|
66
|
+
if(prevSchemas.indexOf(innerSchema) >= 0) return "(recursive)";
|
|
67
|
+
return OptionsValidationError.formatSchema(innerSchema, prevSchemas.concat(schema));
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
if(schema.type === "string") {
|
|
71
|
+
if(schema.minLength === 1)
|
|
72
|
+
return "non-empty string";
|
|
73
|
+
else if(schema.minLength > 1)
|
|
74
|
+
return `string (min length ${schema.minLength})`;
|
|
75
|
+
return "string";
|
|
76
|
+
} else if(schema.type === "boolean") {
|
|
77
|
+
return "boolean";
|
|
78
|
+
} else if(schema.type === "number") {
|
|
79
|
+
return "number";
|
|
80
|
+
} else if(schema.type === "object") {
|
|
81
|
+
if(schema.properties) {
|
|
82
|
+
const required = schema.required || [];
|
|
83
|
+
return `object { ${Object.keys(schema.properties).map(property => {
|
|
84
|
+
if(required.indexOf(property) < 0) return property + "?";
|
|
85
|
+
return property;
|
|
86
|
+
}).concat(schema.additionalProperties ? ["..."] : []).join(", ")} }`;
|
|
87
|
+
}
|
|
88
|
+
if(schema.additionalProperties) {
|
|
89
|
+
return `object { <key>: ${formatInnerSchema(schema.additionalProperties)} }`;
|
|
90
|
+
}
|
|
91
|
+
return "object";
|
|
92
|
+
} else if(schema.type === "array") {
|
|
93
|
+
return `[${formatInnerSchema(schema.items)}]`;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
switch(schema.instanceof) {
|
|
97
|
+
case "Function":
|
|
98
|
+
return "function";
|
|
99
|
+
case "RegExp":
|
|
100
|
+
return "RegExp";
|
|
101
|
+
}
|
|
102
|
+
if(schema.$ref) return formatInnerSchema(getSchemaPart(schema.$ref), true);
|
|
103
|
+
if(schema.allOf) return schema.allOf.map(formatInnerSchema).join(" & ");
|
|
104
|
+
if(schema.oneOf) return schema.oneOf.map(formatInnerSchema).join(" | ");
|
|
105
|
+
if(schema.anyOf) return schema.anyOf.map(formatInnerSchema).join(" | ");
|
|
106
|
+
if(schema.enum) return schema.enum.map(item => JSON.stringify(item)).join(" | ");
|
|
107
|
+
return JSON.stringify(schema, 0, 2);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
static formatValidationError(err) {
|
|
111
|
+
const dataPath = `configuration${err.dataPath}`;
|
|
112
|
+
if(err.keyword === "additionalProperties") {
|
|
113
|
+
return `${dataPath} has an unknown property '${err.params.additionalProperty}'. These properties are valid:\n${getSchemaPartText(err.parentSchema)}`;
|
|
114
|
+
} else if(err.keyword === "oneOf" || err.keyword === "anyOf") {
|
|
115
|
+
if(err.children && err.children.length > 0) {
|
|
116
|
+
return `${dataPath} should be one of these:\n${getSchemaPartText(err.parentSchema)}\n` +
|
|
117
|
+
`Details:\n${err.children.map(err => " * " + indent(OptionsValidationError.formatValidationError(err), " ", false)).join("\n")}`;
|
|
118
|
+
}
|
|
119
|
+
return `${dataPath} should be one of these:\n${getSchemaPartText(err.parentSchema)}`;
|
|
120
|
+
|
|
121
|
+
} else if(err.keyword === "enum") {
|
|
122
|
+
if(err.parentSchema && err.parentSchema.enum && err.parentSchema.enum.length === 1) {
|
|
123
|
+
return `${dataPath} should be ${getSchemaPartText(err.parentSchema)}`;
|
|
124
|
+
}
|
|
125
|
+
return `${dataPath} should be one of these:\n${getSchemaPartText(err.parentSchema)}`;
|
|
126
|
+
} else if(err.keyword === "allOf") {
|
|
127
|
+
return `${dataPath} should be:\n${getSchemaPartText(err.parentSchema)}`;
|
|
128
|
+
} else if(err.keyword === "type") {
|
|
129
|
+
switch(err.params.type) {
|
|
130
|
+
case "object":
|
|
131
|
+
return `${dataPath} should be an object.`;
|
|
132
|
+
case "string":
|
|
133
|
+
return `${dataPath} should be a string.`;
|
|
134
|
+
case "boolean":
|
|
135
|
+
return `${dataPath} should be a boolean.`;
|
|
136
|
+
case "number":
|
|
137
|
+
return `${dataPath} should be a number.`;
|
|
138
|
+
case "array":
|
|
139
|
+
return `${dataPath} should be an array:\n${getSchemaPartText(err.parentSchema)}`;
|
|
140
|
+
}
|
|
141
|
+
return `${dataPath} should be ${err.params.type}:\n${getSchemaPartText(err.parentSchema)}`;
|
|
142
|
+
} else if(err.keyword === "instanceof") {
|
|
143
|
+
return `${dataPath} should be an instance of ${getSchemaPartText(err.parentSchema)}.`;
|
|
144
|
+
} else if(err.keyword === "required") {
|
|
145
|
+
const missingProperty = err.params.missingProperty.replace(/^\./, "");
|
|
146
|
+
return `${dataPath} misses the property '${missingProperty}'.\n${getSchemaPartText(err.parentSchema, ["properties", missingProperty])}`;
|
|
147
|
+
} else if(err.keyword === "minLength" || err.keyword === "minItems") {
|
|
148
|
+
if(err.params.limit === 1)
|
|
149
|
+
return `${dataPath} should not be empty.`;
|
|
150
|
+
else
|
|
151
|
+
return `${dataPath} ${err.message}`;
|
|
152
|
+
} else {
|
|
153
|
+
// eslint-disable-line no-fallthrough
|
|
154
|
+
return `${dataPath} ${err.message} (${JSON.stringify(err, 0, 2)}).\n${getSchemaPartText(err.parentSchema)}`;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
module.exports = OptionsValidationError;
|