- Timestamp:
- 11/25/21 22:08:24 (3 years ago)
- Branches:
- master
- Children:
- 8d391a1
- Parents:
- 59329aa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trip-planner-front/node_modules/@angular-devkit/build-angular/src/browser/index.js
r59329aa re29cc2e 132 132 // eslint-disable-next-line max-lines-per-function 133 133 operators_1.concatMap(async (buildEvent) => { 134 var _a, _b, _c, _d, _e, _f, _g, _h ;134 var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k; 135 135 const spinner = new spinner_1.Spinner(); 136 136 spinner.enabled = options.progress !== false; … … 242 242 try { 243 243 map = fs.readFileSync(filename + '.map', 'utf8'); 244 if (es5Polyfills ) {244 if (es5Polyfills || i18n.shouldInline) { 245 245 fs.unlinkSync(filename + '.map'); 246 246 } … … 251 251 fs.unlinkSync(filename); 252 252 filename = filename.replace(/\-es20\d{2}/, ''); 253 } 254 else if (i18n.shouldInline) { 255 // Original files must be deleted with i18n to avoid the original files from 256 // being copied over the translated files when copying the project assets. 257 fs.unlinkSync(filename); 253 258 } 254 259 const es2015Polyfills = file.file.startsWith('polyfills-es20'); … … 266 271 ignoreOriginal: es5Polyfills, 267 272 optimizeOnly: es2015Polyfills, 273 // When using i18n, file results are kept in memory for further processing 274 memoryMode: i18n.shouldInline, 268 275 }); 269 276 // ES2015 polyfills are only optimized; optimization check was performed above … … 280 287 let processRuntimeAction; 281 288 for (const action of actions) { 289 if (options.verbose) { 290 context.logger.info(`[${new Date().toISOString()}] Differential loading file queued: ${action.filename}`); 291 } 282 292 // If SRI is enabled always process the runtime bundle 283 293 // Lazy route integrity values are stored in the runtime bundle … … 289 299 } 290 300 } 291 const executor = new action_executor_1.BundleActionExecutor({ cachePath: cacheDownlevelPath, i18n }, options.subresourceIntegrity ? 'sha384' : undefined);301 const differentialLoadingExecutor = new action_executor_1.BundleActionExecutor({ cachePath: cacheDownlevelPath, i18n }, options.subresourceIntegrity ? 'sha384' : undefined); 292 302 // Execute the bundle processing actions 293 303 try { 294 304 spinner.start('Generating ES5 bundles for differential loading...'); 295 for await (const result of executor.processAll(processActions)) { 305 for await (const result of differentialLoadingExecutor.processAll(processActions)) { 306 if (options.verbose) { 307 if (result.original) { 308 context.logger.info(`[${new Date().toISOString()}] Differential loading file processed: ${result.original.filename}`); 309 } 310 if (result.downlevel) { 311 context.logger.info(`[${new Date().toISOString()}] Differential loading file processed: ${result.downlevel.filename}`); 312 } 313 } 296 314 processResults.push(result); 297 315 } 298 // Runtime must be processed after all other files 299 if (processRuntimeAction) { 300 const runtimeOptions = { 301 ...processRuntimeAction, 302 runtimeData: processResults, 303 supportedBrowsers: buildBrowserFeatures.supportedBrowsers, 304 }; 305 processResults.push(await Promise.resolve().then(() => __importStar(require('../utils/process-bundle'))).then((m) => m.process(runtimeOptions))); 306 } 307 spinner.succeed('ES5 bundle generation complete.'); 308 if (i18n.shouldInline) { 309 spinner.start('Generating localized bundles...'); 310 const inlineActions = []; 311 const processedFiles = new Set(); 312 for (const result of processResults) { 313 if (result.original) { 314 inlineActions.push({ 315 filename: path.basename(result.original.filename), 316 code: fs.readFileSync(result.original.filename, 'utf8'), 317 map: result.original.map && 318 fs.readFileSync(result.original.map.filename, 'utf8'), 319 outputPath: baseOutputPath, 320 es5: false, 321 missingTranslation: options.i18nMissingTranslation, 322 setLocale: result.name === mainChunkId, 323 }); 324 processedFiles.add(result.original.filename); 325 if (result.original.map) { 326 processedFiles.add(result.original.map.filename); 316 } 317 finally { 318 differentialLoadingExecutor.stop(); 319 } 320 // Runtime must be processed after all other files 321 if (processRuntimeAction) { 322 const runtimeOptions = { 323 ...processRuntimeAction, 324 runtimeData: processResults, 325 supportedBrowsers: buildBrowserFeatures.supportedBrowsers, 326 }; 327 processResults.push(await Promise.resolve().then(() => __importStar(require('../utils/process-bundle'))).then((m) => m.process(runtimeOptions))); 328 } 329 if (options.verbose) { 330 context.logger.info(`[${new Date().toISOString()}] Differential loading processing complete.`); 331 } 332 spinner.succeed('ES5 bundle generation complete.'); 333 if (i18n.shouldInline) { 334 spinner.start('Generating localized bundles...'); 335 const inlineActions = []; 336 for (const result of processResults) { 337 if (result.original) { 338 if (options.verbose) { 339 context.logger.info(`[${new Date().toISOString()}] i18n localize file queued: ${result.original.filename}`); 340 } 341 inlineActions.push({ 342 filename: path.basename(result.original.filename), 343 // Memory mode is always enabled for i18n 344 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion 345 code: result.original.content, 346 map: (_a = result.original.map) === null || _a === void 0 ? void 0 : _a.content, 347 outputPath: baseOutputPath, 348 es5: false, 349 missingTranslation: options.i18nMissingTranslation, 350 setLocale: result.name === mainChunkId, 351 }); 352 } 353 if (result.downlevel) { 354 if (options.verbose) { 355 context.logger.info(`[${new Date().toISOString()}] i18n localize file queued: ${result.downlevel.filename}`); 356 } 357 inlineActions.push({ 358 filename: path.basename(result.downlevel.filename), 359 // Memory mode is always enabled for i18n 360 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion 361 code: result.downlevel.content, 362 map: (_b = result.downlevel.map) === null || _b === void 0 ? void 0 : _b.content, 363 outputPath: baseOutputPath, 364 es5: true, 365 missingTranslation: options.i18nMissingTranslation, 366 setLocale: result.name === mainChunkId, 367 }); 368 } 369 } 370 let hasErrors = false; 371 const i18nExecutor = new action_executor_1.BundleActionExecutor({ i18n }, options.subresourceIntegrity ? 'sha384' : undefined); 372 try { 373 let localizedCount = 0; 374 for await (const result of i18nExecutor.inlineAll(inlineActions)) { 375 localizedCount++; 376 if (options.verbose) { 377 context.logger.info(`[${new Date().toISOString()}] (${localizedCount}/${inlineActions.length}) Localized "${result.file}" [${result.count} translation(s)].`); 378 } 379 for (const diagnostic of result.diagnostics) { 380 spinner.stop(); 381 if (diagnostic.type === 'error') { 382 hasErrors = true; 383 context.logger.error(diagnostic.message); 327 384 } 328 } 329 if (result.downlevel) { 330 inlineActions.push({ 331 filename: path.basename(result.downlevel.filename), 332 code: fs.readFileSync(result.downlevel.filename, 'utf8'), 333 map: result.downlevel.map && 334 fs.readFileSync(result.downlevel.map.filename, 'utf8'), 335 outputPath: baseOutputPath, 336 es5: true, 337 missingTranslation: options.i18nMissingTranslation, 338 setLocale: result.name === mainChunkId, 339 }); 340 processedFiles.add(result.downlevel.filename); 341 if (result.downlevel.map) { 342 processedFiles.add(result.downlevel.map.filename); 385 else { 386 context.logger.warn(diagnostic.message); 343 387 } 344 } 345 } 346 let hasErrors = false; 347 try { 348 for await (const result of executor.inlineAll(inlineActions)) { 349 if (options.verbose) { 350 context.logger.info(`Localized "${result.file}" [${result.count} translation(s)].`); 351 } 352 for (const diagnostic of result.diagnostics) { 353 spinner.stop(); 354 if (diagnostic.type === 'error') { 355 hasErrors = true; 356 context.logger.error(diagnostic.message); 357 } 358 else { 359 context.logger.warn(diagnostic.message); 360 } 361 spinner.start(); 362 } 363 } 364 // Copy any non-processed files into the output locations 365 await copy_assets_1.copyAssets([ 366 { 367 glob: '**/*', 368 input: webpackOutputPath, 369 output: '', 370 ignore: [...processedFiles].map((f) => path.relative(webpackOutputPath, f)), 371 }, 372 ], Array.from(outputPaths.values()), ''); 373 } 374 catch (err) { 375 spinner.fail('Localized bundle generation failed.'); 376 return { success: false, error: mapErrorToMessage(err) }; 377 } 378 if (hasErrors) { 379 spinner.fail('Localized bundle generation failed.'); 380 } 381 else { 382 spinner.succeed('Localized bundle generation complete.'); 383 } 384 if (hasErrors) { 385 return { success: false }; 386 } 387 } 388 } 389 finally { 390 executor.stop(); 388 spinner.start(); 389 } 390 } 391 // Copy any non-processed files into the output locations 392 await copy_assets_1.copyAssets([ 393 { 394 glob: '**/*', 395 input: webpackOutputPath, 396 output: '', 397 }, 398 ], Array.from(outputPaths.values()), ''); 399 } 400 catch (err) { 401 spinner.fail('Localized bundle generation failed.'); 402 return { success: false, error: mapErrorToMessage(err) }; 403 } 404 finally { 405 i18nExecutor.stop(); 406 } 407 if (hasErrors) { 408 spinner.fail('Localized bundle generation failed.'); 409 } 410 else { 411 spinner.succeed('Localized bundle generation complete.'); 412 } 413 if (hasErrors) { 414 return { success: false }; 415 } 391 416 } 392 417 for (const result of processResults) { 393 const chunk = (_ a = webpackStats.chunks) === null || _a === void 0 ? void 0 : _a.find((chunk) => { var _a; return ((_a = chunk.id) === null || _a === void 0 ? void 0 : _a.toString()) === result.name; });418 const chunk = (_c = webpackStats.chunks) === null || _c === void 0 ? void 0 : _c.find((chunk) => { var _a; return ((_a = chunk.id) === null || _a === void 0 ? void 0 : _a.toString()) === result.name; }); 394 419 if (result.original) { 395 420 bundleInfoStats.push(generateBundleInfoStats(result.original, chunk, 'modern')); … … 399 424 } 400 425 } 401 const unprocessedChunks = ((_ b = webpackStats.chunks) === null || _b === void 0 ? void 0 : _b.filter((chunk) => !processResults.find((result) => { var _a; return ((_a = chunk.id) === null || _a === void 0 ? void 0 : _a.toString()) === result.name; }))) || [];426 const unprocessedChunks = ((_d = webpackStats.chunks) === null || _d === void 0 ? void 0 : _d.filter((chunk) => !processResults.find((result) => { var _a; return ((_a = chunk.id) === null || _a === void 0 ? void 0 : _a.toString()) === result.name; }))) || []; 402 427 for (const chunk of unprocessedChunks) { 403 const asset = (_ c = webpackStats.assets) === null || _c === void 0 ? void 0 : _c.find((a) => { var _a; return a.name === ((_a = chunk.files) === null || _a === void 0 ? void 0 : _a[0]); });428 const asset = (_e = webpackStats.assets) === null || _e === void 0 ? void 0 : _e.find((a) => { var _a; return a.name === ((_a = chunk.files) === null || _a === void 0 ? void 0 : _a[0]); }); 404 429 bundleInfoStats.push(stats_1.generateBundleStats({ ...chunk, size: asset === null || asset === void 0 ? void 0 : asset.size })); 405 430 } … … 422 447 switch (severity) { 423 448 case bundle_calculator_1.ThresholdSeverity.Warning: 424 (_ d = webpackStats.warnings) === null || _d === void 0 ? void 0 : _d.push({ message });449 (_f = webpackStats.warnings) === null || _f === void 0 ? void 0 : _f.push({ message }); 425 450 break; 426 451 case bundle_calculator_1.ThresholdSeverity.Error: 427 (_ e = webpackStats.errors) === null || _e === void 0 ? void 0 : _e.push({ message });452 (_g = webpackStats.errors) === null || _g === void 0 ? void 0 : _g.push({ message }); 428 453 break; 429 454 default: … … 435 460 if (buildSuccess) { 436 461 // Copy assets 437 if (!options.watch && ((_ f = options.assets) === null || _f === void 0 ? void 0 : _f.length)) {462 if (!options.watch && ((_h = options.assets) === null || _h === void 0 ? void 0 : _h.length)) { 438 463 spinner.start('Copying assets...'); 439 464 try { … … 450 475 const WOFFSupportNeeded = !buildBrowserFeatures.isFeatureSupported('woff2'); 451 476 const entrypoints = package_chunk_sort_1.generateEntryPoints({ 452 scripts: (_ g = options.scripts) !== null && _g !== void 0 ? _g: [],453 styles: (_ h = options.styles) !== null && _h !== void 0 ? _h: [],477 scripts: (_j = options.scripts) !== null && _j !== void 0 ? _j : [], 478 styles: (_k = options.styles) !== null && _k !== void 0 ? _k : [], 454 479 }); 455 480 const indexHtmlGenerator = new index_html_generator_1.IndexHtmlGenerator({
Note:
See TracChangeset
for help on using the changeset viewer.