MCPcopy Index your code
hub / github.com/toeverything/AFFiNE / buildWithWebpack

Method buildWithWebpack

tools/cli/src/bundle.ts:266–309  ·  view source on GitHub ↗
(pkg: Package)

Source from the content-addressed store, hash-verified

264 }
265
266 static async buildWithWebpack(pkg: Package) {
267 process.env.NODE_ENV = 'production';
268 const logger = new Logger('bundle');
269 logger.info(`Packing package ${pkg.name} with webpack...`);
270 logger.info('Cleaning old output...');
271 rmSync(pkg.distPath.value, { recursive: true, force: true });
272
273 const config = getWebpackBundleConfigs(pkg);
274 config.parallelism = cpus().length;
275
276 const compiler = webpack(config);
277 if (!compiler) {
278 throw new Error('Failed to create webpack compiler');
279 }
280
281 try {
282 const stats = await new Promise<webpack.Stats | webpack.MultiStats>(
283 (resolve, reject) => {
284 compiler.run((error, stats) => {
285 if (error) {
286 reject(error);
287 return;
288 }
289 if (!stats) {
290 reject(new Error('Failed to get webpack stats'));
291 return;
292 }
293 resolve(stats);
294 });
295 }
296 );
297 if (stats.hasErrors()) {
298 console.error(stats.toString('errors-only'));
299 process.exit(1);
300 return;
301 }
302 console.log(stats.toString('minimal'));
303 await uploadAssetsForPackage(pkg, logger);
304 } catch (error) {
305 console.error(error);
306 process.exit(1);
307 return;
308 }
309 }
310
311 static async dev(
312 pkg: Package,

Callers 1

buildMethod · 0.80

Calls 9

getWebpackBundleConfigsFunction · 0.85
rejectFunction · 0.85
resolveFunction · 0.85
uploadAssetsForPackageFunction · 0.85
runMethod · 0.65
toStringMethod · 0.65
infoMethod · 0.45
errorMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected