Skip to content

Commit 4740224

Browse files
refactor(package): migrate to schema-utils (dependencies) (#1464)
1 parent 2e1e23a commit 4740224

8 files changed

+1332
-2035
lines changed

bin/webpack-dev-server.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,7 @@ function startDevServer(config, options) {
354354
try {
355355
server = new Server(compiler, options, log);
356356
} catch (err) {
357-
const OptionsValidationError = require('../lib/OptionsValidationError');
358-
359-
if (err instanceof OptionsValidationError) {
357+
if (err.name === 'ValidationError') {
360358
log.error(colors.error(options.stats.colors, err.message));
361359
// eslint-disable-next-line no-process-exit
362360
process.exit(1);

lib/OptionsValidationError.js

-152
This file was deleted.

lib/Server.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ const webpackDevMiddleware = require('webpack-dev-middleware');
3636
const createLogger = require('./utils/createLogger');
3737
const createCertificate = require('./utils/createCertificate');
3838

39-
const OptionsValidationError = require('./OptionsValidationError');
40-
const optionsSchema = require('./optionsSchema.json');
39+
const validateOptions = require('schema-utils');
40+
const schema = require('./options.json');
4141

4242
const STATS = {
4343
all: false,
@@ -51,10 +51,7 @@ const STATS = {
5151
function Server (compiler, options = {}, _log) {
5252
this.log = _log || createLogger(options);
5353

54-
const validationErrors = webpack.validateSchema(optionsSchema, options);
55-
if (validationErrors.length) {
56-
throw new OptionsValidationError(validationErrors);
57-
}
54+
validateOptions(schema, options, 'webpack Dev Server');
5855

5956
if (options.lazy && !options.filename) {
6057
throw new Error("'filename' option must be set in lazy mode.");

0 commit comments

Comments
 (0)