mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-15 18:13:38 +08:00
refactor(@angular-devkit/build-angular): use Webpack builder result provided output path
By using the output path provided directly by the Webpack builder's result, one additional reason for using the expensive `Stats.toJson` call is removed. This change also removes multiple linting disable rule comments now that the output path property is guaranteed to be present.
This commit is contained in:
parent
ff32ada86b
commit
6fd4da2ebf
@ -257,7 +257,12 @@ export function buildWebpackBrowser(
|
||||
const spinner = new Spinner();
|
||||
spinner.enabled = options.progress !== false;
|
||||
|
||||
const { webpackStats: webpackRawStats, success, emittedFiles = [] } = buildEvent;
|
||||
const {
|
||||
webpackStats: webpackRawStats,
|
||||
success,
|
||||
emittedFiles = [],
|
||||
outputPath: webpackOutputPath,
|
||||
} = buildEvent;
|
||||
if (!webpackRawStats) {
|
||||
throw new Error('Webpack stats build result is required.');
|
||||
}
|
||||
@ -311,8 +316,7 @@ export function buildWebpackBrowser(
|
||||
baseOutputPath,
|
||||
Array.from(outputPaths.values()),
|
||||
scriptsEntryPointName,
|
||||
// tslint:disable-next-line: no-non-null-assertion
|
||||
webpackStats.outputPath!,
|
||||
webpackOutputPath,
|
||||
target <= ScriptTarget.ES5,
|
||||
options.i18nMissingTranslation,
|
||||
);
|
||||
@ -386,8 +390,7 @@ export function buildWebpackBrowser(
|
||||
|
||||
// Retrieve the content/map for the file
|
||||
// NOTE: Additional future optimizations will read directly from memory
|
||||
// tslint:disable-next-line: no-non-null-assertion
|
||||
let filename = path.join(webpackStats.outputPath!, file.file);
|
||||
let filename = path.join(webpackOutputPath, file.file);
|
||||
const code = fs.readFileSync(filename, 'utf8');
|
||||
let map;
|
||||
if (actionOptions.sourceMaps) {
|
||||
@ -537,12 +540,10 @@ export function buildWebpackBrowser(
|
||||
[
|
||||
{
|
||||
glob: '**/*',
|
||||
// tslint:disable-next-line: no-non-null-assertion
|
||||
input: webpackStats.outputPath!,
|
||||
input: webpackOutputPath,
|
||||
output: '',
|
||||
ignore: [...processedFiles].map(f =>
|
||||
// tslint:disable-next-line: no-non-null-assertion
|
||||
path.relative(webpackStats.outputPath!, f),
|
||||
path.relative(webpackOutputPath, f),
|
||||
),
|
||||
},
|
||||
],
|
||||
@ -598,8 +599,7 @@ export function buildWebpackBrowser(
|
||||
baseOutputPath,
|
||||
Array.from(outputPaths.values()),
|
||||
scriptsEntryPointName,
|
||||
// tslint:disable-next-line: no-non-null-assertion
|
||||
webpackStats.outputPath!,
|
||||
webpackOutputPath,
|
||||
target <= ScriptTarget.ES5,
|
||||
options.i18nMissingTranslation,
|
||||
);
|
||||
|
@ -257,6 +257,7 @@ export async function execute(
|
||||
return {
|
||||
success: false,
|
||||
error: `Ivy extraction requires the '@angular/localize' package.`,
|
||||
outputPath: outFile,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -270,13 +271,11 @@ export async function execute(
|
||||
},
|
||||
).toPromise();
|
||||
|
||||
// Complete if using VE
|
||||
if (!usingIvy) {
|
||||
return webpackResult;
|
||||
}
|
||||
// Set the outputPath to the extraction output location for downstream consumers
|
||||
webpackResult.outputPath = outFile;
|
||||
|
||||
// Nothing to process if the Webpack build failed
|
||||
if (!webpackResult.success) {
|
||||
// Complete if using VE or if Webpack build failed
|
||||
if (!usingIvy || !webpackResult.success) {
|
||||
return webpackResult;
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ export function execute(
|
||||
},
|
||||
}).pipe(
|
||||
concatMap(async output => {
|
||||
const { emittedFiles = [], webpackStats } = output;
|
||||
const { emittedFiles = [], outputPath, webpackStats } = output;
|
||||
if (!webpackStats) {
|
||||
throw new Error('Webpack stats build result is required.');
|
||||
}
|
||||
@ -108,8 +108,7 @@ export function execute(
|
||||
baseOutputPath,
|
||||
Array.from(outputPaths.values()),
|
||||
[],
|
||||
// tslint:disable-next-line: no-non-null-assertion
|
||||
webpackStats.outputPath!,
|
||||
outputPath,
|
||||
target <= ScriptTarget.ES5,
|
||||
options.i18nMissingTranslation,
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user