MCPcopy
hub / github.com/webpack/webpack / callback

Function callback

test/HotModuleReplacementPlugin.test.js:145–185  ·  view source on GitHub ↗
(
			/** @type {Error | null} */ err,
			/** @type {import("../").Stats | undefined} */ _stats
		)

Source from the content-addressed store, hash-verified

143 plugins: [new webpack.HotModuleReplacementPlugin()]
144 });
145 const callback = (
146 /** @type {Error | null} */ err,
147 /** @type {import("../").Stats | undefined} */ _stats
148 ) => {
149 if (err) return done(err);
150 const stats = /** @type {import("../").Stats} */ (_stats);
151 const jsonStats = stats.toJson();
152 const hash = jsonStats.hash;
153 const hmrUpdateMainFileName = `0.${hash}.hot-update.json`;
154
155 switch (step) {
156 case 1:
157 expect(updates.size).toBe(0);
158 firstUpdate = hmrUpdateMainFileName;
159 break;
160 case 2:
161 expect(updates.size).toBe(1);
162 expect(updates.has(firstUpdate)).toBe(true);
163 expect(hasFile(firstUpdate)).toBe(true);
164 break;
165 case 3:
166 expect(updates.size).toBe(2);
167 for (const file of updates) {
168 expect(hasFile(file)).toBe(true);
169 }
170 return setTimeout(() => {
171 fs.writeFileSync(entryFile, `${++step}`, "utf8");
172 compiler.run((err) => {
173 if (err) return done(err);
174 for (const file of updates) {
175 expect(hasFile(file)).toBe(false);
176 }
177 done();
178 });
179 }, 10100);
180 }
181
182 updates.add(hmrUpdateMainFileName);
183 fs.writeFileSync(entryFile, `${++step}`, "utf8");
184 compiler.run(callback);
185 };
186
187 compiler.run(callback);
188 }, 20000);

Callers

nothing calls this directly

Calls 5

hasFileFunction · 0.85
toJsonMethod · 0.45
hasMethod · 0.45
runMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected