MCPcopy
hub / github.com/webpack/webpack / create

Function create

lib/webpack.js:189–234  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

187 */
188const webpack = (options, callback) => {
189 const create = () => {
190 const isMultiCompiler = Array.isArray(options);
191
192 if (
193 !asArray(/** @type {WebpackOptions} */ (options)).every((options) =>
194 needValidate(options) ? webpackOptionsSchemaCheck(options) : true
195 )
196 ) {
197 getValidateSchema()(
198 webpackOptionsSchema,
199 isMultiCompiler
200 ? options.map((options) => (needValidate(options) ? options : {}))
201 : needValidate(options)
202 ? options
203 : {}
204 );
205 util.deprecate(
206 () => {},
207 "webpack bug: Pre-compiled schema reports error while real schema is happy. This has performance drawbacks.",
208 "DEP_WEBPACK_PRE_COMPILED_SCHEMA_INVALID"
209 )();
210 }
211 /** @type {MultiCompiler | Compiler} */
212 let compiler;
213 /** @type {boolean | undefined} */
214 let watch = false;
215 /** @type {WatchOptions | WatchOptions[]} */
216 let watchOptions;
217 if (isMultiCompiler) {
218 /** @type {MultiCompiler} */
219 compiler = createMultiCompiler(
220 options,
221 /** @type {MultiCompilerOptions} */
222 (options)
223 );
224 watch = options.some((options) => options.watch);
225 watchOptions = options.map((options) => options.watchOptions || {});
226 } else {
227 const webpackOptions = /** @type {WebpackOptions} */ (options);
228 /** @type {Compiler} */
229 compiler = createCompiler(webpackOptions);
230 watch = webpackOptions.watch;
231 watchOptions = webpackOptions.watchOptions || {};
232 }
233 return { compiler, watch, watchOptions };
234 };
235 if (callback) {
236 try {
237 const { compiler, watch, watchOptions } = create();

Callers 1

webpackFunction · 0.70

Calls 5

needValidateFunction · 0.85
isArrayMethod · 0.80
asArrayFunction · 0.70
createMultiCompilerFunction · 0.70
createCompilerFunction · 0.70

Tested by

no test coverage detected