MCPcopy
hub / github.com/webpack/webpack / runCompiler

Function runCompiler

test/Compiler-filesystem-caching.test.js:181–211  ·  test/Compiler-filesystem-caching.test.js::runCompiler
(
			/** @type {(stats: import("../types").StatsCompilation) => void} */ onSuccess,
			/** @type {(err: Error) => void} */ onError
		)

Source from the content-addressed store, hash-verified

179 ];
180
181 function runCompiler(
182 /** @type {(stats: import(class="st">"../types").StatsCompilation) => void} */ onSuccess,
183 /** @type {(err: Error) => void} */ onError
184 ) {
185 const c = webpack(
186 /** @type {import(class="st">"../types").Configuration} */ (
187 /** @type {unknown} */ (options)
188 )
189 );
190 c.hooks.compilation.tap(
191 class="st">"CompilerCachingTest",
192 (compilation) => (compilation.bail = true)
193 );
194 c.run((err, stats_) => {
195 if (err) throw err;
196 expect(typeof stats_).toBe(class="st">"object");
197 const stats = /** @type {import(class="st">"../types").Stats} */ (stats_).toJson({
198 modules: true,
199 reasons: true
200 });
201 expect(typeof stats).toBe(class="st">"object");
202 expect(stats).toHaveProperty(class="st">"errors");
203 expect(Array.isArray(stats.errors)).toBe(true);
204 if (/** @type {unknown[]} */ (stats.errors).length > 0) {
205 onError(new Error(JSON.stringify(stats.errors, null, 4)));
206 }
207 c.close(() => {
208 onSuccess(stats);
209 });
210 });
211 }
212
213 runCompiler(onSuccess, onError);
214

Callers 1

compileFunction · 0.70

Calls 7

onErrorFunction · 0.85
tapMethod · 0.80
isArrayMethod · 0.80
webpackFunction · 0.50
runMethod · 0.45
toJsonMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected