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

Function runCompiler

test/Compiler-caching.test.js:102–136  ·  view source on GitHub ↗

* @param {Record<string, unknown> | ((stats: CachingStats, files: Record<string, string>, iteration: number) => void)} options run options or callback * @param {((stats: CachingStats, files: Record<string, string>, iteration: number) => void)=} callback done callback

(options, callback)

Source from the content-addressed store, hash-verified

100 * @param {((stats: CachingStats, files: Record<string, string>, iteration: number) => void)=} callback done callback
101 */
102 function runCompiler(options, callback) {
103 if (typeof options === "function") {
104 callback = options;
105 options = {};
106 }
107 c.run((err, rawStats) => {
108 if (err) throw err;
109 expect(typeof rawStats).toBe("object");
110 const stats = /** @type {CachingStats} */ (
111 /** @type {import("../").Stats} */ (rawStats).toJson({
112 modules: true,
113 reasons: true
114 })
115 );
116 expect(typeof stats).toBe("object");
117 expect(stats).toHaveProperty("errors");
118 expect(Array.isArray(stats.errors)).toBe(true);
119 if (/** @type {Record<string, unknown>} */ (options).expectErrors) {
120 expect(stats.errors).toHaveLength(
121 /** @type {number} */ (
122 /** @type {Record<string, unknown>} */ (options).expectErrors
123 )
124 );
125 } else if (stats.errors && stats.errors.length > 0) {
126 expect(typeof stats.errors[0]).toBe("string");
127 throw new Error(
128 /** @type {string} */ (/** @type {unknown} */ (stats.errors[0]))
129 );
130 }
131 stats.logs = logs;
132 /** @type {(stats: CachingStats, files: Record<string, string>, iteration: number) => void} */ (
133 callback
134 )(stats, files, compilerIteration++);
135 });
136 }
137
138 runCompiler(callback);
139

Callers 1

compileFunction · 0.70

Calls 3

isArrayMethod · 0.80
runMethod · 0.45
toJsonMethod · 0.45

Tested by

no test coverage detected