(pkg: Package)
| 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, |
no test coverage detected