source: imaps-frontend/node_modules/webpack/lib/validateSchema.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 6.3 KB
RevLine 
[79a0317]1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5
6"use strict";
7
8const { validate } = require("schema-utils");
9
10/* cSpell:disable */
11const DID_YOU_MEAN = {
12 rules: "module.rules",
13 loaders: "module.rules or module.rules.*.use",
14 query: "module.rules.*.options (BREAKING CHANGE since webpack 5)",
15 noParse: "module.noParse",
16 filename: "output.filename or module.rules.*.generator.filename",
17 file: "output.filename",
18 chunkFilename: "output.chunkFilename",
19 chunkfilename: "output.chunkFilename",
20 ecmaVersion:
21 "output.environment (output.ecmaVersion was a temporary configuration option during webpack 5 beta)",
22 ecmaversion:
23 "output.environment (output.ecmaVersion was a temporary configuration option during webpack 5 beta)",
24 ecma: "output.environment (output.ecmaVersion was a temporary configuration option during webpack 5 beta)",
25 path: "output.path",
26 pathinfo: "output.pathinfo",
27 pathInfo: "output.pathinfo",
28 jsonpFunction: "output.chunkLoadingGlobal (BREAKING CHANGE since webpack 5)",
29 chunkCallbackName:
30 "output.chunkLoadingGlobal (BREAKING CHANGE since webpack 5)",
31 jsonpScriptType: "output.scriptType (BREAKING CHANGE since webpack 5)",
32 hotUpdateFunction: "output.hotUpdateGlobal (BREAKING CHANGE since webpack 5)",
33 splitChunks: "optimization.splitChunks",
34 immutablePaths: "snapshot.immutablePaths",
35 managedPaths: "snapshot.managedPaths",
36 maxModules: "stats.modulesSpace (BREAKING CHANGE since webpack 5)",
37 hashedModuleIds:
38 'optimization.moduleIds: "hashed" (BREAKING CHANGE since webpack 5)',
39 namedChunks:
40 'optimization.chunkIds: "named" (BREAKING CHANGE since webpack 5)',
41 namedModules:
42 'optimization.moduleIds: "named" (BREAKING CHANGE since webpack 5)',
43 occurrenceOrder:
44 'optimization.chunkIds: "size" and optimization.moduleIds: "size" (BREAKING CHANGE since webpack 5)',
45 automaticNamePrefix:
46 "optimization.splitChunks.[cacheGroups.*].idHint (BREAKING CHANGE since webpack 5)",
47 noEmitOnErrors:
48 "optimization.emitOnErrors (BREAKING CHANGE since webpack 5: logic is inverted to avoid negative flags)",
49 Buffer:
50 "to use the ProvidePlugin to process the Buffer variable to modules as polyfill\n" +
51 "BREAKING CHANGE: webpack 5 no longer provided Node.js polyfills by default.\n" +
52 "Note: if you are using 'node.Buffer: false', you can just remove that as this is the default behavior now.\n" +
53 "To provide a polyfill to modules use:\n" +
54 'new ProvidePlugin({ Buffer: ["buffer", "Buffer"] }) and npm install buffer.',
55 process:
56 "to use the ProvidePlugin to process the process variable to modules as polyfill\n" +
57 "BREAKING CHANGE: webpack 5 no longer provided Node.js polyfills by default.\n" +
58 "Note: if you are using 'node.process: false', you can just remove that as this is the default behavior now.\n" +
59 "To provide a polyfill to modules use:\n" +
60 'new ProvidePlugin({ process: "process" }) and npm install buffer.'
61};
62
63const REMOVED = {
64 concord:
65 "BREAKING CHANGE: resolve.concord has been removed and is no longer available.",
66 devtoolLineToLine:
67 "BREAKING CHANGE: output.devtoolLineToLine has been removed and is no longer available."
68};
69/* cSpell:enable */
70
71/**
72 * @param {Parameters<typeof validate>[0]} schema a json schema
73 * @param {Parameters<typeof validate>[1]} options the options that should be validated
74 * @param {Parameters<typeof validate>[2]=} validationConfiguration configuration for generating errors
75 * @returns {void}
76 */
77const validateSchema = (schema, options, validationConfiguration) => {
78 validate(
79 schema,
80 options,
81 validationConfiguration || {
82 name: "Webpack",
83 postFormatter: (formattedError, error) => {
84 const children = error.children;
85 if (
86 children &&
87 children.some(
88 child =>
89 child.keyword === "absolutePath" &&
90 child.dataPath === ".output.filename"
91 )
92 ) {
93 return `${formattedError}\nPlease use output.path to specify absolute path and output.filename for the file name.`;
94 }
95
96 if (
97 children &&
98 children.some(
99 child =>
100 child.keyword === "pattern" && child.dataPath === ".devtool"
101 )
102 ) {
103 return (
104 `${formattedError}\n` +
105 "BREAKING CHANGE since webpack 5: The devtool option is more strict.\n" +
106 "Please strictly follow the order of the keywords in the pattern."
107 );
108 }
109
110 if (error.keyword === "additionalProperties") {
111 const params =
112 /** @type {import("ajv").AdditionalPropertiesParams} */ (
113 error.params
114 );
115 if (
116 Object.prototype.hasOwnProperty.call(
117 DID_YOU_MEAN,
118 params.additionalProperty
119 )
120 ) {
121 return `${formattedError}\nDid you mean ${
122 DID_YOU_MEAN[
123 /** @type {keyof DID_YOU_MEAN} */ (params.additionalProperty)
124 ]
125 }?`;
126 }
127
128 if (
129 Object.prototype.hasOwnProperty.call(
130 REMOVED,
131 params.additionalProperty
132 )
133 ) {
134 return `${formattedError}\n${
135 REMOVED[/** @type {keyof REMOVED} */ (params.additionalProperty)]
136 }?`;
137 }
138
139 if (!error.dataPath) {
140 if (params.additionalProperty === "debug") {
141 return (
142 `${formattedError}\n` +
143 "The 'debug' property was removed in webpack 2.0.0.\n" +
144 "Loaders should be updated to allow passing this option via loader options in module.rules.\n" +
145 "Until loaders are updated one can use the LoaderOptionsPlugin to switch loaders into debug mode:\n" +
146 "plugins: [\n" +
147 " new webpack.LoaderOptionsPlugin({\n" +
148 " debug: true\n" +
149 " })\n" +
150 "]"
151 );
152 }
153
154 if (params.additionalProperty) {
155 return (
156 `${formattedError}\n` +
157 "For typos: please correct them.\n" +
158 "For loader options: webpack >= v2.0.0 no longer allows custom properties in configuration.\n" +
159 " Loaders should be updated to allow passing options via loader options in module.rules.\n" +
160 " Until loaders are updated one can use the LoaderOptionsPlugin to pass these options to the loader:\n" +
161 " plugins: [\n" +
162 " new webpack.LoaderOptionsPlugin({\n" +
163 " // test: /\\.xxx$/, // may apply this only for some modules\n" +
164 " options: {\n" +
165 ` ${params.additionalProperty}: …\n` +
166 " }\n" +
167 " })\n" +
168 " ]"
169 );
170 }
171 }
172 }
173
174 return formattedError;
175 }
176 }
177 );
178};
179module.exports = validateSchema;
Note: See TracBrowser for help on using the repository browser.