MCPcopy
hub / github.com/webpack/webpack / createCompiler

Function createCompiler

lib/webpack.js:81–126  ·  view source on GitHub ↗
(rawOptions, compilerIndex)

Source from the content-addressed store, hash-verified

79 * @returns {Compiler} a compiler
80 */
81const createCompiler = (rawOptions, compilerIndex) => {
82 let options = getNormalizedWebpackOptions(rawOptions);
83 applyWebpackOptionsBaseDefaults(options);
84
85 /** @type {WebpackOptionsInterception=} */
86 let interception;
87 ({ options, interception } = applyWebpackOptionsInterception(options));
88
89 const compiler = new Compiler(
90 /** @type {string} */ (options.context),
91 options
92 );
93 new NodeEnvironmentPlugin({
94 infrastructureLogging: options.infrastructureLogging
95 }).apply(compiler);
96 if (Array.isArray(options.plugins)) {
97 for (const plugin of options.plugins) {
98 if (typeof plugin === "function") {
99 /** @type {WebpackPluginFunction} */
100 (plugin).call(compiler, compiler);
101 } else if (plugin) {
102 plugin.apply(compiler);
103 }
104 }
105 }
106 const resolvedDefaultOptions = applyWebpackOptionsDefaults(
107 options,
108 compilerIndex
109 );
110 if (resolvedDefaultOptions.platform) {
111 compiler.platform = resolvedDefaultOptions.platform;
112 }
113 if (options.validate) {
114 compiler.hooks.validate.call();
115 }
116 compiler.hooks.environment.call();
117 compiler.hooks.afterEnvironment.call();
118 new WebpackOptionsApply().process(
119 /** @type {WebpackOptionsNormalizedWithDefaults} */
120 (options),
121 compiler,
122 interception
123 );
124 compiler.hooks.initialize.call();
125 return compiler;
126};
127
128/**
129 * Returns array of options.

Callers 2

createMultiCompilerFunction · 0.70
createFunction · 0.70

Calls 8

isArrayMethod · 0.80
applyMethod · 0.65
callMethod · 0.45
processMethod · 0.45

Tested by

no test coverage detected