Skip to content

Commit

Permalink
Rename schemas; Make imports less verbose
Browse files Browse the repository at this point in the history
  • Loading branch information
gribnoysup committed Nov 12, 2017
1 parent d73ad04 commit cdd593b
Show file tree
Hide file tree
Showing 27 changed files with 37 additions and 28 deletions.
4 changes: 2 additions & 2 deletions lib/BannerPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const ConcatSource = require("webpack-sources").ConcatSource;
const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");

const validateOptions = require("schema-utils");
const bannerPluginSchema = require("../schemas/plugins/bannerPluginSchema.json");
const schema = require("../schemas/plugins/BannerPlugin.json");

const wrapComment = (str) => {
if(!str.includes("\n")) return `/*! ${str} */`;
Expand All @@ -21,7 +21,7 @@ class BannerPlugin {
if(arguments.length > 1)
throw new Error("BannerPlugin only takes one argument (pass an options object)");

validateOptions(bannerPluginSchema, options, "Banner Plugin");
validateOptions(schema, options, "Banner Plugin");

if(typeof options === "string")
options = {
Expand Down
4 changes: 2 additions & 2 deletions lib/DllPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ const LibManifestPlugin = require("./LibManifestPlugin");
const FlagInitialModulesAsUsedPlugin = require("./FlagInitialModulesAsUsedPlugin");

const validateOptions = require("schema-utils");
const dllPluginSchema = require("../schemas/plugins/dllPluginSchema.json");
const schema = require("../schemas/plugins/DllPlugin.json");

class DllPlugin {
constructor(options) {
validateOptions(dllPluginSchema, options, "Dll Plugin");
validateOptions(schema, options, "Dll Plugin");
this.options = options;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/DllReferencePlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ const DelegatedExportsDependency = require("./dependencies/DelegatedExportsDepen
const NullFactory = require("./NullFactory");

const validateOptions = require("schema-utils");
const dllReferencePluginSchema = require("../schemas/plugins/dllReferencePluginSchema.json");
const schema = require("../schemas/plugins/DllReferencePlugin.json");

class DllReferencePlugin {
constructor(options) {
validateOptions(dllReferencePluginSchema, options, "Dll Reference Plugin");
validateOptions(schema, options, "Dll Reference Plugin");
this.options = options;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/HashedModuleIdsPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
const createHash = require("crypto").createHash;

const validateOptions = require("schema-utils");
const hashedModuleIdsPluginSchema = require("../schemas/plugins/hashedModuleIdsPluginSchema.json");
const schema = require("../schemas/plugins/HashedModuleIdsPlugin.json");

class HashedModuleIdsPlugin {
constructor(options) {
validateOptions(hashedModuleIdsPluginSchema, options || {}, "Hashed Module Ids Plugin");
validateOptions(schema, options || {}, "Hashed Module Ids Plugin");

this.options = Object.assign({
hashFunction: "md5",
Expand Down
4 changes: 2 additions & 2 deletions lib/LoaderOptionsPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");

const validateOptions = require("schema-utils");
const loaderOptionsPluginSchema = require("../schemas/plugins/loaderOptionsPluginSchema.json");
const schema = require("../schemas/plugins/LoaderOptionsPlugin.json");

class LoaderOptionsPlugin {
constructor(options) {
validateOptions(loaderOptionsPluginSchema, options || {}, "Loader Options Plugin");
validateOptions(schema, options || {}, "Loader Options Plugin");

if(typeof options !== "object") options = {};
if(!options.test) options.test = {
Expand Down
4 changes: 2 additions & 2 deletions lib/SourceMapDevToolPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
const SourceMapDevToolModuleOptionsPlugin = require("./SourceMapDevToolModuleOptionsPlugin");

const validateOptions = require("schema-utils");
const sourceMapDevToolPluginSchema = require("../schemas/plugins/sourceMapDevToolPluginSchema.json");
const schema = require("../schemas/plugins/SourceMapDevToolPlugin.json");

const basename = (name) => {
if(name.indexOf("/") < 0) return name;
Expand Down Expand Up @@ -57,7 +57,7 @@ class SourceMapDevToolPlugin {
if(arguments.length > 1)
throw new Error("SourceMapDevToolPlugin only takes one argument (pass an options object)");

validateOptions(sourceMapDevToolPluginSchema, options || {}, "Source Map Dev Tool Plugin");
validateOptions(schema, options || {}, "SourceMap DevTool Plugin");

if(!options) options = {};
this.sourceMapFilename = options.filename;
Expand Down
4 changes: 2 additions & 2 deletions lib/WatchIgnorePlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
"use strict";

const validateOptions = require("schema-utils");
const watchIgnorePluginSchema = require("../schemas/plugins/watchIgnorePluginSchema.json");
const schema = require("../schemas/plugins/WatchIgnorePlugin.json");

class WatchIgnorePlugin {
constructor(paths) {
validateOptions(watchIgnorePluginSchema, paths, "Watch Ignore Plugin");
validateOptions(schema, paths, "Watch Ignore Plugin");
this.paths = paths;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/WebpackOptionsValidationError.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"use strict";

const WebpackError = require("./WebpackError");
const webpackOptionsSchema = require("../schemas/webpackOptionsSchema.json");
const webpackOptionsSchema = require("../schemas/WebpackOptions.json");

const getSchemaPart = (path, parents, additionalPath) => {
parents = parents || 0;
Expand Down
4 changes: 2 additions & 2 deletions lib/optimize/AggressiveSplittingPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
const identifierUtils = require("../util/identifier");

const validateOptions = require("schema-utils");
const aggressiveSplittingPluginSchema = require("../../schemas/plugins/optimize/aggressiveSplittingPluginSchema.json");
const schema = require("../../schemas/plugins/optimize/AggressiveSplittingPlugin.json");

function moveModuleBetween(oldChunk, newChunk) {
return function(module) {
Expand All @@ -33,7 +33,7 @@ function copyWithReason(obj) {

class AggressiveSplittingPlugin {
constructor(options) {
validateOptions(aggressiveSplittingPluginSchema, options || {}, "Aggressive Splitting Plugin");
validateOptions(schema, options || {}, "Aggressive Splitting Plugin");

this.options = options || {};
if(typeof this.options.minSize !== "number") this.options.minSize = 30 * 1024;
Expand Down
4 changes: 2 additions & 2 deletions lib/optimize/CommonsChunkPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
let nextIdent = 0;

const validateOptions = require("schema-utils");
const commonsChunkPluginSchema = require("../../schemas/plugins/optimize/commonsChunkPluginSchema.json");
const schema = require("../../schemas/plugins/optimize/CommonsChunkPlugin.json");

class CommonsChunkPlugin {
constructor(options) {
Expand All @@ -28,7 +28,7 @@ The available options are:
minSize: number`);
}

validateOptions(commonsChunkPluginSchema, options, "Commons Chunk Plugin");
validateOptions(schema, options, "Commons Chunk Plugin");

const normalizedOptions = this.normalizeOptions(options);

Expand Down
4 changes: 2 additions & 2 deletions lib/optimize/LimitChunkCountPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
"use strict";

const validateOptions = require("schema-utils");
const limitChunkCountPluginSchema = require("../../schemas/plugins/optimize/limitChunkCountPluginSchema.json");
const schema = require("../../schemas/plugins/optimize/LimitChunkCountPlugin.json");

class LimitChunkCountPlugin {
constructor(options) {
validateOptions(limitChunkCountPluginSchema, options || {}, "Limit Chunk Count Plugin");
validateOptions(schema, options || {}, "Limit Chunk Count Plugin");
this.options = options || {};
}
apply(compiler) {
Expand Down
4 changes: 2 additions & 2 deletions lib/optimize/MinChunkSizePlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
"use strict";

const validateOptions = require("schema-utils");
const minChunkSizePluginSchema = require("../../schemas/plugins/optimize/minChunkSizePluginSchema.json");
const schema = require("../../schemas/plugins/optimize/MinChunkSizePlugin.json");

class MinChunkSizePlugin {
constructor(options) {
validateOptions(minChunkSizePluginSchema, options, "Min Chunk Size Plugin");
validateOptions(schema, options, "Min Chunk Size Plugin");
this.options = options;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const WebpackOptionsApply = require("./WebpackOptionsApply");
const WebpackOptionsDefaulter = require("./WebpackOptionsDefaulter");
const validateSchema = require("./validateSchema");
const WebpackOptionsValidationError = require("./WebpackOptionsValidationError");
const webpackOptionsSchema = require("../schemas/webpackOptionsSchema.json");
const webpackOptionsSchema = require("../schemas/WebpackOptions.json");

function webpack(options, callback) {
const webpackOptionsValidationErrors = validateSchema(webpackOptionsSchema, options);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"memory-fs": "~0.4.1",
"mkdirp": "~0.5.0",
"node-libs-browser": "^2.0.0",
"schema-utils": "^0.4.0",
"schema-utils": "^0.4.2",
"source-map": "^0.5.3",
"supports-color": "^4.2.1",
"tapable": "^0.2.7",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
15 changes: 12 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,14 @@ chalk@^2.0.0, chalk@^2.0.1:
escape-string-regexp "^1.0.5"
supports-color "^4.0.0"

chalk@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.3.0.tgz#b5ea48efc9c1793dccc9b4767c93914d3f2d52ba"
dependencies:
ansi-styles "^3.1.0"
escape-string-regexp "^1.0.5"
supports-color "^4.0.0"

[email protected]:
version "1.2.1"
resolved "https://registry.yarnpkg.com/character-parser/-/character-parser-1.2.1.tgz#c0dde4ab182713b919b970959a123ecc1a30fcd6"
Expand Down Expand Up @@ -3569,12 +3577,13 @@ schema-utils@^0.3.0:
dependencies:
ajv "^5.0.0"

schema-utils@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-0.4.0.tgz#cf98d870a5f74e7526211f6d38caf0d250366688"
schema-utils@^0.4.2:
version "0.4.2"
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-0.4.2.tgz#86d92aedf4dfc51c9b321ef16bd33a9417b122d0"
dependencies:
ajv "^5.0.0"
ajv-keywords "^2.1.0"
chalk "^2.3.0"

script-loader@~0.7.0:
version "0.7.0"
Expand Down

0 comments on commit cdd593b

Please sign in to comment.