UNPKG

1.31 kBJavaScriptView Raw
1"use strict";
2/**
3 * @license
4 * Copyright Google Inc. All Rights Reserved.
5 *
6 * Use of this source code is governed by an MIT-style license that can be
7 * found in the LICENSE file at https://angular.io/license
8 */
9Object.defineProperty(exports, "__esModule", { value: true });
10const path = require("path");
11function getEmittedFiles(compilation) {
12 const files = [];
13 // adds all chunks to the list of emitted files such as lazy loaded modules
14 for (const chunk of compilation.chunks) {
15 for (const file of chunk.files) {
16 files.push({
17 // The id is guaranteed to exist at this point in the compilation process
18 // tslint:disable-next-line: no-non-null-assertion
19 id: chunk.id.toString(),
20 name: chunk.name,
21 file,
22 extension: path.extname(file),
23 initial: chunk.isOnlyInitial(),
24 });
25 }
26 }
27 // other all files
28 for (const file of Object.keys(compilation.assets)) {
29 files.push({ file, extension: path.extname(file), initial: false, asset: true });
30 }
31 // dedupe
32 return files.filter(({ file, name }, index) => files.findIndex(f => f.file === file && (!name || name === f.name)) === index);
33}
34exports.getEmittedFiles = getEmittedFiles;