@angular-devkit/build-angular 0.1101.0 → 0.1101.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@angular-devkit/build-angular",
3
- "version": "0.1101.0",
3
+ "version": "0.1101.4",
4
4
  "description": "Angular Webpack Build Facade",
5
5
  "experimental": true,
6
6
  "main": "src/index.js",
7
7
  "typings": "src/index.d.ts",
8
8
  "builders": "builders.json",
9
9
  "dependencies": {
10
- "@angular-devkit/architect": "0.1101.0",
11
- "@angular-devkit/build-optimizer": "0.1101.0",
12
- "@angular-devkit/build-webpack": "0.1101.0",
13
- "@angular-devkit/core": "11.1.0",
10
+ "@angular-devkit/architect": "0.1101.4",
11
+ "@angular-devkit/build-optimizer": "0.1101.4",
12
+ "@angular-devkit/build-webpack": "0.1101.4",
13
+ "@angular-devkit/core": "11.1.4",
14
14
  "@babel/core": "7.12.10",
15
15
  "@babel/generator": "7.12.11",
16
16
  "@babel/plugin-transform-runtime": "7.12.10",
@@ -18,7 +18,7 @@
18
18
  "@babel/runtime": "7.12.5",
19
19
  "@babel/template": "7.12.7",
20
20
  "@jsdevtools/coverage-istanbul-loader": "3.0.5",
21
- "@ngtools/webpack": "11.1.0",
21
+ "@ngtools/webpack": "11.1.4",
22
22
  "ansi-colors": "4.1.1",
23
23
  "autoprefixer": "10.2.1",
24
24
  "babel-loader": "8.2.2",
@@ -34,11 +34,12 @@
34
34
  "file-loader": "6.2.0",
35
35
  "find-cache-dir": "3.3.1",
36
36
  "glob": "7.1.6",
37
+ "https-proxy-agent": "5.0.0",
37
38
  "inquirer": "7.3.3",
38
39
  "jest-worker": "26.6.2",
39
40
  "karma-source-map-support": "1.4.0",
40
41
  "less": "4.1.0",
41
- "less-loader": "7.2.1",
42
+ "less-loader": "7.3.0",
42
43
  "license-webpack-plugin": "2.3.11",
43
44
  "loader-utils": "2.0.0",
44
45
  "mini-css-extract-plugin": "1.3.3",
@@ -49,7 +50,7 @@
49
50
  "pnp-webpack-plugin": "1.6.4",
50
51
  "postcss": "8.2.4",
51
52
  "postcss-import": "14.0.0",
52
- "postcss-loader": "4.1.0",
53
+ "postcss-loader": "4.2.0",
53
54
  "raw-loader": "4.0.2",
54
55
  "regenerator-runtime": "0.13.7",
55
56
  "resolve-url-loader": "3.1.2",
@@ -79,10 +80,10 @@
79
80
  "worker-plugin": "5.0.0"
80
81
  },
81
82
  "peerDependencies": {
82
- "@angular/compiler-cli": "^11.0.0 || ^11.1.0-next",
83
- "@angular/localize": "^11.0.0 || ^11.1.0-next",
83
+ "@angular/compiler-cli": "^11.0.0",
84
+ "@angular/localize": "^11.0.0",
84
85
  "karma": "^5.2.0",
85
- "ng-packagr": "^11.0.0 || ^11.1.0-next",
86
+ "ng-packagr": "^11.0.0",
86
87
  "protractor": "^7.0.0",
87
88
  "tslint": "^6.1.0",
88
89
  "typescript": "~4.0.0 || ~4.1.0"
@@ -117,7 +118,7 @@
117
118
  },
118
119
  "engines": {
119
120
  "node": ">= 10.13.0",
120
- "npm": ">= 6.11.0",
121
+ "npm": "^6.11.0",
121
122
  "yarn": ">= 1.13.0"
122
123
  },
123
124
  "author": "Angular Authors",
@@ -159,8 +159,10 @@ function buildWebpackBrowser(options, context, transforms = {}) {
159
159
  throw new Error('Webpack stats build result is required.');
160
160
  }
161
161
  // Fix incorrectly set `initial` value on chunks.
162
- const extraEntryPoints = configs_1.normalizeExtraEntryPoints(options.styles || [], 'styles')
163
- .concat(configs_1.normalizeExtraEntryPoints(options.scripts || [], 'scripts'));
162
+ const extraEntryPoints = [
163
+ ...configs_1.normalizeExtraEntryPoints(options.styles || [], 'styles'),
164
+ ...configs_1.normalizeExtraEntryPoints(options.scripts || [], 'scripts'),
165
+ ];
164
166
  const webpackStats = {
165
167
  ...webpackRawStats,
166
168
  chunks: async_chunks_1.markAsyncChunksNonInitial(webpackRawStats, extraEntryPoints),
@@ -329,7 +329,8 @@ export declare type Localize = string[] | boolean;
329
329
  export declare type OptimizationUnion = boolean | OptimizationClass;
330
330
  export interface OptimizationClass {
331
331
  /**
332
- * Enables optimization for fonts. This requires internet access.
332
+ * Enables optimization for fonts. This option requires internet access. `HTTPS_PROXY`
333
+ * environment variable can be used to specify a proxy server.
333
334
  */
334
335
  fonts?: FontsUnion;
335
336
  /**
@@ -342,13 +343,15 @@ export interface OptimizationClass {
342
343
  styles?: StylesUnion;
343
344
  }
344
345
  /**
345
- * Enables optimization for fonts. This requires internet access.
346
+ * Enables optimization for fonts. This option requires internet access. `HTTPS_PROXY`
347
+ * environment variable can be used to specify a proxy server.
346
348
  */
347
349
  export declare type FontsUnion = boolean | FontsClass;
348
350
  export interface FontsClass {
349
351
  /**
350
352
  * Reduce render blocking requests by inlining external Google fonts and icons CSS
351
- * definitions in the application's HTML index file. This requires internet access.
353
+ * definitions in the application's HTML index file. This option requires internet access.
354
+ * `HTTPS_PROXY` environment variable can be used to specify a proxy server.
352
355
  */
353
356
  inline?: boolean;
354
357
  }
@@ -95,7 +95,7 @@
95
95
  ]
96
96
  },
97
97
  "fonts": {
98
- "description": "Enables optimization for fonts. This requires internet access.",
98
+ "description": "Enables optimization for fonts. This option requires internet access. `HTTPS_PROXY` environment variable can be used to specify a proxy server.",
99
99
  "default": true,
100
100
  "oneOf": [
101
101
  {
@@ -103,7 +103,7 @@
103
103
  "properties": {
104
104
  "inline": {
105
105
  "type": "boolean",
106
- "description": "Reduce render blocking requests by inlining external Google fonts and icons CSS definitions in the application's HTML index file. This requires internet access.",
106
+ "description": "Reduce render blocking requests by inlining external Google fonts and icons CSS definitions in the application's HTML index file. This option requires internet access. `HTTPS_PROXY` environment variable can be used to specify a proxy server.",
107
107
  "default": true
108
108
  }
109
109
  },
@@ -45,6 +45,7 @@ export declare class BuilderHarness<T> {
45
45
  removeFile(path: string): Promise<void>;
46
46
  modifyFile(path: string, modifier: (content: string) => string | Promise<string>): Promise<void>;
47
47
  hasFile(path: string): boolean;
48
+ hasFileMatch(directory: string, pattern: RegExp): boolean;
48
49
  readFile(path: string): string;
49
50
  private validateProjectName;
50
51
  }
@@ -213,6 +213,11 @@ class BuilderHarness {
213
213
  hasFile(path) {
214
214
  return this.host.scopedSync().exists(core_1.normalize(path));
215
215
  }
216
+ hasFileMatch(directory, pattern) {
217
+ return this.host.scopedSync()
218
+ .list(core_1.normalize(directory))
219
+ .some(name => pattern.test(name));
220
+ }
216
221
  readFile(path) {
217
222
  const content = this.host.scopedSync().read(core_1.normalize(path));
218
223
  return Buffer.from(content).toString('utf8');
@@ -1,10 +1,3 @@
1
- /**
2
- * @license
3
- * Copyright Google Inc. All Rights Reserved.
4
- *
5
- * Use of this source code is governed by an MIT-style license that can be
6
- * found in the LICENSE file at https://angular.io/license
7
- */
8
1
  import * as webpack from 'webpack';
9
2
  import { Budget } from '../browser/schema';
10
3
  import { ProcessBundleResult } from '../utils/process-bundle';
@@ -1,6 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.checkThresholds = exports.checkBudgets = exports.calculateThresholds = exports.ThresholdSeverity = void 0;
4
+ /**
5
+ * @license
6
+ * Copyright Google Inc. All Rights Reserved.
7
+ *
8
+ * Use of this source code is governed by an MIT-style license that can be
9
+ * found in the LICENSE file at https://angular.io/license
10
+ */
11
+ const path_1 = require("path");
4
12
  const schema_1 = require("../browser/schema");
5
13
  const stats_1 = require("../webpack/utils/stats");
6
14
  var ThresholdType;
@@ -133,6 +141,16 @@ class Calculator {
133
141
  .reduce((l, r) => l + r, 0);
134
142
  }
135
143
  }
144
+ getAssetSize(asset) {
145
+ if (asset.name.endsWith('.js')) {
146
+ const processResult = this.processResults
147
+ .find((processResult) => processResult.original && path_1.basename(processResult.original.filename) === asset.name);
148
+ if (processResult === null || processResult === void 0 ? void 0 : processResult.original) {
149
+ return processResult.original.size;
150
+ }
151
+ }
152
+ return asset.size;
153
+ }
136
154
  }
137
155
  /**
138
156
  * A named bundle.
@@ -193,7 +211,7 @@ class AllScriptCalculator extends Calculator {
193
211
  calculate() {
194
212
  const size = this.assets
195
213
  .filter(asset => asset.name.endsWith('.js'))
196
- .map(asset => asset.size)
214
+ .map(asset => this.getAssetSize(asset))
197
215
  .reduce((total, size) => total + size, 0);
198
216
  return [{ size, label: 'total scripts' }];
199
217
  }
@@ -205,7 +223,7 @@ class AllCalculator extends Calculator {
205
223
  calculate() {
206
224
  const size = this.assets
207
225
  .filter(asset => !asset.name.endsWith('.map'))
208
- .map(asset => asset.size)
226
+ .map(asset => this.getAssetSize(asset))
209
227
  .reduce((total, size) => total + size, 0);
210
228
  return [{ size, label: 'total' }];
211
229
  }
@@ -218,7 +236,7 @@ class AnyScriptCalculator extends Calculator {
218
236
  return this.assets
219
237
  .filter(asset => asset.name.endsWith('.js'))
220
238
  .map(asset => ({
221
- size: asset.size,
239
+ size: this.getAssetSize(asset),
222
240
  label: asset.name,
223
241
  }));
224
242
  }
@@ -231,7 +249,7 @@ class AnyCalculator extends Calculator {
231
249
  return this.assets
232
250
  .filter(asset => !asset.name.endsWith('.map'))
233
251
  .map(asset => ({
234
- size: asset.size,
252
+ size: this.getAssetSize(asset),
235
253
  label: asset.name,
236
254
  }));
237
255
  }
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.InlineFontsProcessor = void 0;
11
11
  const cacache = require("cacache");
12
12
  const https = require("https");
13
+ const proxyAgent = require("https-proxy-agent");
13
14
  const url_1 = require("url");
14
15
  const cache_path_1 = require("../cache-path");
15
16
  const environment_options_1 = require("../environment-options");
@@ -69,6 +70,7 @@ class InlineFontsProcessor {
69
70
  return transformedContent;
70
71
  }
71
72
  async getResponse(url, userAgent) {
73
+ var _a;
72
74
  const key = `${packageVersion}|${url}|${userAgent}`;
73
75
  if (cacheFontsPath) {
74
76
  const entry = await cacache.get.info(cacheFontsPath, key);
@@ -76,13 +78,24 @@ class InlineFontsProcessor {
76
78
  return fs_1.readFile(entry.path, 'utf8');
77
79
  }
78
80
  }
81
+ let agent;
82
+ const httpsProxy = (_a = process.env.HTTPS_PROXY) !== null && _a !== void 0 ? _a : process.env.https_proxy;
83
+ if (httpsProxy) {
84
+ agent = proxyAgent(httpsProxy);
85
+ }
79
86
  const data = await new Promise((resolve, reject) => {
80
87
  let rawResponse = '';
81
88
  https.get(url, {
89
+ agent,
90
+ rejectUnauthorized: false,
82
91
  headers: {
83
92
  'user-agent': userAgent,
84
93
  },
85
94
  }, res => {
95
+ if (res.statusCode !== 200) {
96
+ reject(new Error(`Inlining of fonts failed. ${url} returned status code: ${res.statusCode}.`));
97
+ return;
98
+ }
86
99
  res
87
100
  .on('data', chunk => rawResponse += chunk)
88
101
  .on('end', () => resolve(rawResponse));
@@ -38,7 +38,7 @@ function assertCompatibleAngularVersion(projectRoot, logger) {
38
38
  const angularCliPkgPath = require.resolve('@angular/cli/package.json', resolveOptions);
39
39
  angularCliPkgJson = require(angularCliPkgPath);
40
40
  if (!(angularCliPkgJson && angularCliPkgJson['version'])) {
41
- throw new Error();
41
+ return;
42
42
  }
43
43
  }
44
44
  catch (_b) {
@@ -46,17 +46,16 @@ function assertCompatibleAngularVersion(projectRoot, logger) {
46
46
  // In this case we don't provide as many version checks.
47
47
  return;
48
48
  }
49
- if (angularCliPkgJson['version'] === '0.0.0') {
50
- // Internal testing version
49
+ if (angularCliPkgJson['version'] === '0.0.0' || angularPkgJson['version'] === '0.0.0-PLACEHOLDER') {
50
+ // Internal CLI testing version or integration testing in the angular/angular
51
+ // repository with the generated development @angular/core npm package which is versioned "0.0.0-PLACEHOLDER".
51
52
  return;
52
53
  }
53
- const cliMajor = new semver_1.SemVer(angularCliPkgJson['version']).major;
54
- // e.g. CLI 8.0 supports '>=8.0.0 <9.0.0', including pre-releases (betas, rcs, snapshots)
55
- // of both 8 and 9. Also allow version "0.0.0" for integration testing in the angular/angular
56
- // repository with the generated development @angular/core npm package which is versioned "0.0.0".
57
- const supportedAngularSemver = `0.0.0 || ^${cliMajor}.0.0-beta || ` + `>=${cliMajor}.0.0 <${cliMajor + 1}.0.0`;
58
54
  const angularVersion = new semver_1.SemVer(angularPkgJson['version']);
59
- const rxjsVersion = new semver_1.SemVer(rxjsPkgJson['version']);
55
+ const cliMajor = new semver_1.SemVer(angularCliPkgJson['version']).major;
56
+ // e.g. CLI 8.0 supports '>=8.0.0 <9.0.0', including pre-releases (next, rcs, snapshots)
57
+ // of both 8 and 9.
58
+ const supportedAngularSemver = `^${cliMajor}.0.0-next || >=${cliMajor}.0.0 <${cliMajor + 1}.0.0`;
60
59
  if (!semver_1.satisfies(angularVersion, supportedAngularSemver, { includePrerelease: true })) {
61
60
  logger.error(core_1.tags.stripIndents `
62
61
  This version of CLI is only compatible with Angular versions ${supportedAngularSemver},
@@ -67,25 +66,5 @@ function assertCompatibleAngularVersion(projectRoot, logger) {
67
66
  ` + '\n');
68
67
  process.exit(3);
69
68
  }
70
- else if (semver_1.gte(angularVersion, '6.0.0-rc.0') &&
71
- !semver_1.gte(rxjsVersion, '5.6.0-forward-compat.0') &&
72
- !semver_1.gte(rxjsVersion, '6.0.0-beta.0')) {
73
- logger.error(core_1.tags.stripIndents `
74
- This project uses version ${rxjsVersion} of RxJs, which is not supported by Angular v6+.
75
- The official RxJs version that is supported is 5.6.0-forward-compat.0 and greater.
76
-
77
- Please visit the link below to find instructions on how to update RxJs.
78
- https://docs.google.com/document/d/12nlLt71VLKb-z3YaSGzUfx6mJbc34nsMXtByPUN35cg/edit#
79
- ` + '\n');
80
- process.exit(3);
81
- }
82
- else if (semver_1.gte(angularVersion, '6.0.0-rc.0') && !semver_1.gte(rxjsVersion, '6.0.0-beta.0')) {
83
- logger.warn(core_1.tags.stripIndents `
84
- This project uses a temporary compatibility version of RxJs (${rxjsVersion}).
85
-
86
- Please visit the link below to find instructions on how to update RxJs.
87
- https://docs.google.com/document/d/12nlLt71VLKb-z3YaSGzUfx6mJbc34nsMXtByPUN35cg/edit#
88
- ` + '\n');
89
- }
90
69
  }
91
70
  exports.assertCompatibleAngularVersion = assertCompatibleAngularVersion;
@@ -269,10 +269,14 @@ function getCommonConfig(wco) {
269
269
  // Provide full names for lazy routes that use the deprecated string format
270
270
  extraPlugins.push(new webpack_1.ContextReplacementPlugin(/\@angular[\\\/]core[\\\/]/, (data) => (data.chunkName = '[request]')));
271
271
  }
272
- if (!differentialLoadingMode) {
272
+ if (buildOptions.budgets.length && !differentialLoadingMode) {
273
273
  // Budgets are computed after differential builds, not via a plugin.
274
274
  // https://github.com/angular/angular-cli/blob/master/packages/angular_devkit/build_angular/src/browser/index.ts
275
- extraPlugins.push(new plugins_1.BundleBudgetPlugin({ budgets: buildOptions.budgets }));
275
+ const extraEntryPoints = [
276
+ ...helpers_1.normalizeExtraEntryPoints(buildOptions.styles || [], 'styles'),
277
+ ...helpers_1.normalizeExtraEntryPoints(buildOptions.scripts || [], 'scripts'),
278
+ ];
279
+ extraPlugins.push(new plugins_1.BundleBudgetPlugin({ budgets: buildOptions.budgets, extraEntryPoints }));
276
280
  }
277
281
  if ((scriptsSourceMap || stylesSourceMap)) {
278
282
  extraRules.push({
@@ -7,10 +7,12 @@
7
7
  */
8
8
  import { WebpackConfigOptions } from '../../utils/build-options';
9
9
  export declare function getWebpackStatsConfig(verbose?: boolean): {
10
+ all: boolean;
10
11
  colors: boolean;
11
12
  hash: boolean;
12
13
  timings: boolean;
13
14
  chunks: boolean;
15
+ builtAt: boolean;
14
16
  chunkModules: boolean;
15
17
  children: boolean;
16
18
  modules: boolean;
@@ -24,10 +26,12 @@ export declare function getWebpackStatsConfig(verbose?: boolean): {
24
26
  };
25
27
  export declare function getStatsConfig(wco: WebpackConfigOptions): {
26
28
  stats: {
29
+ all: boolean;
27
30
  colors: boolean;
28
31
  hash: boolean;
29
32
  timings: boolean;
30
33
  chunks: boolean;
34
+ builtAt: boolean;
31
35
  chunkModules: boolean;
32
36
  children: boolean;
33
37
  modules: boolean;
@@ -10,10 +10,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.getStatsConfig = exports.getWebpackStatsConfig = void 0;
11
11
  const webpack_version_1 = require("../../utils/webpack-version");
12
12
  const webpackOutputOptions = {
13
+ all: false,
13
14
  colors: true,
14
15
  hash: true,
15
16
  timings: true,
16
17
  chunks: true,
18
+ builtAt: true,
17
19
  chunkModules: false,
18
20
  children: false,
19
21
  modules: false,
@@ -109,6 +109,7 @@ function getStylesConfig(wco) {
109
109
  {
110
110
  loader: require.resolve('less-loader'),
111
111
  options: {
112
+ implementation: require('less'),
112
113
  sourceMap: cssSourceMap,
113
114
  lessOptions: {
114
115
  javascriptEnabled: true,
@@ -135,6 +136,7 @@ function getStylesConfig(wco) {
135
136
  ],
136
137
  },
137
138
  ];
139
+ const assetNameTemplate = helpers_1.assetNameTemplateFactory(hashFormat);
138
140
  const postcssOptionsCreator = (sourceMap, extracted) => {
139
141
  return (loader) => ({
140
142
  map: sourceMap && {
@@ -162,7 +164,7 @@ function getStylesConfig(wco) {
162
164
  deployUrl: buildOptions.deployUrl,
163
165
  resourcesOutputPath: buildOptions.resourcesOutputPath,
164
166
  loader,
165
- filename: `[name]${hashFormat.file}.[ext]`,
167
+ filename: assetNameTemplate,
166
168
  emitFile: buildOptions.platform !== 'server',
167
169
  extracted,
168
170
  }),
@@ -186,6 +188,7 @@ function getStylesConfig(wco) {
186
188
  {
187
189
  loader: require.resolve('postcss-loader'),
188
190
  options: {
191
+ implementation: require('postcss'),
189
192
  postcssOptions: postcssOptionsCreator(componentsSourceMap, false),
190
193
  },
191
194
  },
@@ -215,6 +218,7 @@ function getStylesConfig(wco) {
215
218
  {
216
219
  loader: require.resolve('postcss-loader'),
217
220
  options: {
221
+ implementation: require('postcss'),
218
222
  postcssOptions: postcssOptionsCreator(globalSourceMap, buildOptions.extractCss),
219
223
  },
220
224
  },
@@ -30,7 +30,6 @@ function createIvyPlugin(wco, aot, tsconfig) {
30
30
  const { buildOptions } = wco;
31
31
  const optimize = buildOptions.optimization.scripts;
32
32
  const compilerOptions = {
33
- skipTemplateCodegen: !aot,
34
33
  sourceMap: buildOptions.sourceMap.scripts,
35
34
  };
36
35
  if (buildOptions.preserveSymlinks !== undefined) {
@@ -46,6 +45,7 @@ function createIvyPlugin(wco, aot, tsconfig) {
46
45
  tsconfig,
47
46
  compilerOptions,
48
47
  fileReplacements,
48
+ jitMode: !aot,
49
49
  emitNgModuleScope: !optimize,
50
50
  });
51
51
  }
@@ -7,8 +7,10 @@
7
7
  */
8
8
  import { Compiler } from 'webpack';
9
9
  import { Budget } from '../../browser/schema';
10
+ import { NormalizedEntryPoint } from '../utils/helpers';
10
11
  export interface BundleBudgetPluginOptions {
11
12
  budgets: Budget[];
13
+ extraEntryPoints: NormalizedEntryPoint[];
12
14
  }
13
15
  export declare class BundleBudgetPlugin {
14
16
  private options;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BundleBudgetPlugin = void 0;
4
4
  const bundle_calculator_1 = require("../../utils/bundle-calculator");
5
5
  const webpack_diagnostics_1 = require("../../utils/webpack-diagnostics");
6
+ const async_chunks_1 = require("../utils/async-chunks");
6
7
  class BundleBudgetPlugin {
7
8
  constructor(options) {
8
9
  this.options = options;
@@ -16,7 +17,9 @@ class BundleBudgetPlugin {
16
17
  // No process bundle results because this plugin is only used when differential
17
18
  // builds are disabled.
18
19
  const processResults = [];
20
+ // Fix incorrectly set `initial` value on chunks.
19
21
  const stats = compilation.getStats().toJson();
22
+ stats.chunks = async_chunks_1.markAsyncChunksNonInitial(stats, this.options.extraEntryPoints);
20
23
  for (const { severity, message } of bundle_calculator_1.checkBudgets(budgets, stats, processResults)) {
21
24
  switch (severity) {
22
25
  case bundle_calculator_1.ThresholdSeverity.Warning:
@@ -48,36 +48,41 @@ class IndexHtmlWebpackPlugin extends index_html_generator_1.IndexHtmlGenerator {
48
48
  const files = [];
49
49
  const noModuleFiles = [];
50
50
  const moduleFiles = [];
51
- for (const [entryName, entrypoint] of this.compilation.entrypoints) {
52
- const entryFiles = (_a = entrypoint === null || entrypoint === void 0 ? void 0 : entrypoint.getFiles()) === null || _a === void 0 ? void 0 : _a.map((f) => ({
53
- name: entryName,
54
- file: f,
55
- extension: path_1.extname(f),
56
- }));
57
- if (!entryFiles) {
58
- continue;
59
- }
60
- if (this.options.noModuleEntrypoints.includes(entryName)) {
61
- noModuleFiles.push(...entryFiles);
62
- }
63
- else if (this.options.moduleEntrypoints.includes(entryName)) {
64
- moduleFiles.push(...entryFiles);
65
- }
66
- else {
67
- files.push(...entryFiles);
51
+ try {
52
+ for (const [entryName, entrypoint] of this.compilation.entrypoints) {
53
+ const entryFiles = (_a = entrypoint === null || entrypoint === void 0 ? void 0 : entrypoint.getFiles()) === null || _a === void 0 ? void 0 : _a.map((f) => ({
54
+ name: entryName,
55
+ file: f,
56
+ extension: path_1.extname(f),
57
+ }));
58
+ if (!entryFiles) {
59
+ continue;
60
+ }
61
+ if (this.options.noModuleEntrypoints.includes(entryName)) {
62
+ noModuleFiles.push(...entryFiles);
63
+ }
64
+ else if (this.options.moduleEntrypoints.includes(entryName)) {
65
+ moduleFiles.push(...entryFiles);
66
+ }
67
+ else {
68
+ files.push(...entryFiles);
69
+ }
68
70
  }
71
+ const { content, warnings, errors } = await this.process({
72
+ files,
73
+ noModuleFiles,
74
+ moduleFiles,
75
+ outputPath: path_1.dirname(this.options.outputPath),
76
+ baseHref: this.options.baseHref,
77
+ lang: this.options.lang,
78
+ });
79
+ assets[this.options.outputPath] = new webpack_sources_1.RawSource(content);
80
+ warnings.forEach(msg => webpack_diagnostics_1.addWarning(this.compilation, msg));
81
+ errors.forEach(msg => webpack_diagnostics_1.addError(this.compilation, msg));
82
+ }
83
+ catch (error) {
84
+ webpack_diagnostics_1.addError(this.compilation, error.message);
69
85
  }
70
- const { content, warnings, errors } = await this.process({
71
- files,
72
- noModuleFiles,
73
- moduleFiles,
74
- outputPath: path_1.dirname(this.options.outputPath),
75
- baseHref: this.options.baseHref,
76
- lang: this.options.lang,
77
- });
78
- assets[this.options.outputPath] = new webpack_sources_1.RawSource(content);
79
- warnings.forEach(msg => webpack_diagnostics_1.addWarning(this.compilation, msg));
80
- errors.forEach(msg => webpack_diagnostics_1.addError(this.compilation, msg));
81
86
  };
82
87
  }
83
88
  async readAsset(path) {
@@ -7,7 +7,7 @@ export interface PostcssCliResourcesOptions {
7
7
  rebaseRootRelative?: boolean;
8
8
  /** CSS is extracted to a `.css` or is embedded in a `.js` file. */
9
9
  extracted?: boolean;
10
- filename: string;
10
+ filename: (resourcePath: string) => string;
11
11
  loader: webpack.loader.LoaderContext;
12
12
  emitFile: boolean;
13
13
  }
@@ -74,7 +74,8 @@ function default_1(options) {
74
74
  reject(err);
75
75
  return;
76
76
  }
77
- let outputPath = loader_utils_1.interpolateName({ resourcePath: result }, filename, { content });
77
+ let outputPath = loader_utils_1.interpolateName({ resourcePath: result }, filename(result), { content, context: loader.context || loader.rootContext })
78
+ .replace(/\\|\//g, '-');
78
79
  if (resourcesOutputPath) {
79
80
  outputPath = path.posix.join(resourcesOutputPath, outputPath);
80
81
  }
@@ -71,6 +71,7 @@ class ScriptsWebpackPlugin {
71
71
  compilation.chunks.push(chunk);
72
72
  }
73
73
  compilation.assets[filename] = source;
74
+ compilation.hooks.chunkAsset.call(chunk, filename);
74
75
  }
75
76
  apply(compiler) {
76
77
  if (!this.options.scripts || this.options.scripts.length === 0) {
@@ -6,7 +6,7 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  import * as webpack from 'webpack';
9
- import { NormalizedEntryPoint } from '../configs';
9
+ import { NormalizedEntryPoint } from './helpers';
10
10
  /**
11
11
  * Webpack stats may incorrectly mark extra entry points `initial` chunks, when
12
12
  * they are actually loaded asynchronously and thus not in the main bundle. This
@@ -24,3 +24,4 @@ export declare function getSourceMapDevTool(scriptsSourceMap: boolean | undefine
24
24
  export declare function getEsVersionForFileName(scriptTarget: ScriptTarget | undefined, esVersionInFileName?: boolean): string;
25
25
  export declare function isPolyfillsEntry(name: string): boolean;
26
26
  export declare function getWatchOptions(poll: number | undefined): Options.WatchOptions;
27
+ export declare function assetNameTemplateFactory(hashFormat: HashFormat): (resourcePath: string) => string;
@@ -7,8 +7,9 @@
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.getWatchOptions = exports.isPolyfillsEntry = exports.getEsVersionForFileName = exports.getSourceMapDevTool = exports.normalizeExtraEntryPoints = exports.getOutputHashFormat = void 0;
10
+ exports.assetNameTemplateFactory = exports.getWatchOptions = exports.isPolyfillsEntry = exports.getEsVersionForFileName = exports.getSourceMapDevTool = exports.normalizeExtraEntryPoints = exports.getOutputHashFormat = void 0;
11
11
  const core_1 = require("@angular-devkit/core");
12
+ const path = require("path");
12
13
  const typescript_1 = require("typescript");
13
14
  const webpack_1 = require("webpack");
14
15
  const webpack_version_1 = require("../../utils/webpack-version");
@@ -98,3 +99,27 @@ function getWatchOptions(poll) {
98
99
  };
99
100
  }
100
101
  exports.getWatchOptions = getWatchOptions;
102
+ function assetNameTemplateFactory(hashFormat) {
103
+ const visitedFiles = new Map();
104
+ return (resourcePath) => {
105
+ if (hashFormat.file) {
106
+ // File names are hashed therefore we don't need to handle files with the same file name.
107
+ return `[name]${hashFormat.file}.[ext]`;
108
+ }
109
+ const filename = path.basename(resourcePath);
110
+ // Check if the file with the same name has already been processed.
111
+ const visited = visitedFiles.get(filename);
112
+ if (!visited) {
113
+ // Not visited.
114
+ visitedFiles.set(filename, resourcePath);
115
+ return filename;
116
+ }
117
+ else if (visited === resourcePath) {
118
+ // Same file.
119
+ return filename;
120
+ }
121
+ // File has the same name but it's in a different location.
122
+ return '[path][name].[ext]';
123
+ };
124
+ }
125
+ exports.assetNameTemplateFactory = assetNameTemplateFactory;