MCPcopy
hub / github.com/webpack/webpack / run

Method run

lib/Watching.js:177–252  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

175 this._collectedRemovedFiles = undefined;
176
177 const run = () => {
178 if (this.compiler.idle) {
179 return this.compiler.cache.endIdle((err) => {
180 if (err) return this._done(err);
181 this.compiler.idle = false;
182 run();
183 });
184 }
185 if (this._needRecords) {
186 return this.compiler.readRecords((err) => {
187 if (err) return this._done(err);
188
189 this._needRecords = false;
190 run();
191 });
192 }
193 this.invalid = false;
194 this._invalidReported = false;
195 this.compiler.hooks.watchRun.callAsync(this.compiler, (err) => {
196 if (err) return this._done(err);
197 /**
198 * Processes the provided err.
199 * @param {Error | null} err error
200 * @param {Compilation=} _compilation compilation
201 * @returns {void}
202 */
203 const onCompiled = (err, _compilation) => {
204 if (err) return this._done(err, _compilation);
205
206 const compilation = /** @type {Compilation} */ (_compilation);
207
208 if (this.compiler.hooks.shouldEmit.call(compilation) === false) {
209 return this._done(null, compilation);
210 }
211
212 process.nextTick(() => {
213 const logger = compilation.getLogger("webpack.Compiler");
214 logger.time("emitAssets");
215 this.compiler.emitAssets(compilation, (err) => {
216 logger.timeEnd("emitAssets");
217 if (err) return this._done(err, compilation);
218 if (this.invalid) return this._done(null, compilation);
219
220 logger.time("emitRecords");
221 this.compiler.emitRecords((err) => {
222 logger.timeEnd("emitRecords");
223 if (err) return this._done(err, compilation);
224
225 if (compilation.hooks.needAdditionalPass.call()) {
226 compilation.needAdditionalPass = true;
227
228 compilation.startTime = /** @type {number} */ (
229 this.startTime
230 );
231 compilation.endTime = Date.now();
232 logger.time("done hook");
233 const stats = new Stats(compilation);
234 this.compiler.hooks.done.callAsync(stats, (err) => {

Callers 4

webpackFunction · 0.45
bench.mjsFile · 0.45
receiveInstanceFunction · 0.45
example.jsFile · 0.45

Calls 5

_doneMethod · 0.95
endIdleMethod · 0.80
readRecordsMethod · 0.80
runFunction · 0.50
compileMethod · 0.45

Tested by

no test coverage detected