-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@angular-devkit/build-webpack): report emitted files
With this change the builder will report the emitted chunks and assets after the compilation, this is needed for deferential loading so that we can build an index from the outputs of multiple builds
- Loading branch information
Showing
6 changed files
with
117 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* @license | ||
* Copyright Google Inc. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import * as webpack from 'webpack'; | ||
|
||
export interface EmittedFiles { | ||
name?: string; | ||
file: string; | ||
initial: boolean; | ||
extension: string; | ||
} | ||
|
||
export function getEmittedFiles(compilation: webpack.compilation.Compilation): EmittedFiles[] { | ||
const getExtension = (file: string) => file.split('.').reverse()[0]; | ||
const files: EmittedFiles[] = []; | ||
|
||
for (const chunk of Object.values(compilation.chunks)) { | ||
const entry: Partial<EmittedFiles> = { | ||
name: chunk.name, | ||
initial: chunk.isOnlyInitial(), | ||
}; | ||
|
||
for (const file of chunk.files) { | ||
files.push({ ...entry, file, extension: getExtension(file) } as EmittedFiles); | ||
} | ||
} | ||
|
||
for (const file of Object.keys(compilation.assets)) { | ||
if (files.some(e => e.file === file)) { | ||
// skip as this already exists | ||
continue; | ||
} | ||
|
||
files.push({ | ||
file, | ||
extension: getExtension(file), | ||
initial: false, | ||
}); | ||
} | ||
|
||
return files; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters