@angular-devkit/build-angular 13.0.0 → 13.1.0-next.1

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.
Files changed (47) hide show
  1. package/package.json +25 -26
  2. package/src/babel/presets/application.d.ts +1 -0
  3. package/src/babel/presets/application.js +5 -2
  4. package/src/babel/webpack-loader.js +2 -1
  5. package/src/builders/browser/index.js +4 -7
  6. package/src/builders/dev-server/index.js +0 -4
  7. package/src/builders/extract-i18n/index.js +1 -4
  8. package/src/builders/karma/index.d.ts +2 -2
  9. package/src/builders/karma/index.js +1 -7
  10. package/src/builders/server/index.js +1 -7
  11. package/src/utils/build-options.d.ts +1 -2
  12. package/src/utils/i18n-inlining.js +18 -2
  13. package/src/utils/index.d.ts +0 -1
  14. package/src/utils/index.js +0 -1
  15. package/src/utils/normalize-builder-schema.js +2 -0
  16. package/src/{webpack/configs/worker.d.ts → utils/supported-browsers.d.ts} +1 -3
  17. package/src/utils/supported-browsers.js +26 -0
  18. package/src/webpack/configs/common.d.ts +2 -2
  19. package/src/webpack/configs/common.js +130 -158
  20. package/src/webpack/configs/dev-server.d.ts +2 -2
  21. package/src/webpack/configs/index.d.ts +0 -6
  22. package/src/webpack/configs/index.js +0 -6
  23. package/src/webpack/configs/styles.d.ts +2 -2
  24. package/src/webpack/configs/styles.js +2 -4
  25. package/src/webpack/plugins/hmr/hmr-accept.js +4 -1
  26. package/src/webpack/plugins/index.d.ts +2 -0
  27. package/src/webpack/plugins/index.js +5 -1
  28. package/src/webpack/plugins/json-stats-plugin.d.ts +13 -0
  29. package/src/webpack/plugins/json-stats-plugin.js +54 -0
  30. package/src/webpack/plugins/progress-plugin.d.ts +11 -0
  31. package/src/webpack/plugins/progress-plugin.js +38 -0
  32. package/src/webpack/{configs/browser.d.ts → plugins/typescript.d.ts} +2 -2
  33. package/src/webpack/{configs → plugins}/typescript.js +5 -24
  34. package/src/webpack/utils/helpers.d.ts +15 -5
  35. package/src/webpack/utils/helpers.js +159 -34
  36. package/src/webpack/utils/stats.js +1 -2
  37. package/src/utils/build-browser-features.d.ts +0 -16
  38. package/src/utils/build-browser-features.js +0 -54
  39. package/src/webpack/configs/browser.js +0 -81
  40. package/src/webpack/configs/server.d.ts +0 -14
  41. package/src/webpack/configs/server.js +0 -73
  42. package/src/webpack/configs/stats.d.ts +0 -38
  43. package/src/webpack/configs/stats.js +0 -53
  44. package/src/webpack/configs/test.d.ts +0 -10
  45. package/src/webpack/configs/test.js +0 -77
  46. package/src/webpack/configs/typescript.d.ts +0 -12
  47. package/src/webpack/configs/worker.js +0 -22
@@ -30,25 +30,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
30
30
  };
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
32
  exports.getCommonConfig = void 0;
33
+ const webpack_1 = require("@ngtools/webpack");
33
34
  const copy_webpack_plugin_1 = __importDefault(require("copy-webpack-plugin"));
34
- const crypto_1 = require("crypto");
35
- const fs_1 = require("fs");
36
35
  const path = __importStar(require("path"));
37
36
  const typescript_1 = require("typescript");
38
- const webpack_1 = require("webpack");
39
- const utils_1 = require("../../utils");
37
+ const webpack_2 = require("webpack");
38
+ const webpack_subresource_integrity_1 = require("webpack-subresource-integrity");
40
39
  const environment_options_1 = require("../../utils/environment-options");
41
40
  const load_esm_1 = require("../../utils/load-esm");
42
- const spinner_1 = require("../../utils/spinner");
43
- const webpack_diagnostics_1 = require("../../utils/webpack-diagnostics");
44
41
  const plugins_1 = require("../plugins");
45
- const javascript_optimizer_plugin_1 = require("../plugins/javascript-optimizer-plugin");
42
+ const progress_plugin_1 = require("../plugins/progress-plugin");
43
+ const typescript_2 = require("../plugins/typescript");
46
44
  const helpers_1 = require("../utils/helpers");
47
45
  // eslint-disable-next-line max-lines-per-function
48
46
  async function getCommonConfig(wco) {
49
47
  var _a, _b;
50
- const { root, projectRoot, buildOptions, tsConfig, projectName, sourceRoot } = wco;
51
- const { cache, codeCoverage, codeCoverageExclude = [], platform = 'browser', sourceMap: { styles: stylesSourceMap, scripts: scriptsSourceMap, vendor: vendorSourceMap }, optimization: { styles: stylesOptimization, scripts: scriptsOptimization }, } = buildOptions;
48
+ const { root, projectRoot, buildOptions, tsConfig, projectName, sourceRoot, tsConfigPath } = wco;
49
+ const { cache, codeCoverage, crossOrigin = 'none', platform = 'browser', aot = true, codeCoverageExclude = [], main, polyfills, sourceMap: { styles: stylesSourceMap, scripts: scriptsSourceMap, vendor: vendorSourceMap, hidden: hiddenSourceMap, }, optimization: { styles: stylesOptimization, scripts: scriptsOptimization }, commonChunk, vendorChunk, subresourceIntegrity, verbose, poll, webWorkerTsConfig, externalDependencies = [], allowedCommonJsDependencies, bundleDependencies, } = buildOptions;
50
+ const isPlatformServer = buildOptions.platform === 'server';
52
51
  const extraPlugins = [];
53
52
  const extraRules = [];
54
53
  const entryPoints = {};
@@ -61,34 +60,18 @@ async function getCommonConfig(wco) {
61
60
  const { GLOBAL_DEFS_FOR_TERSER, GLOBAL_DEFS_FOR_TERSER_WITH_AOT, VERSION: NG_VERSION, } = (compilerCliModule.GLOBAL_DEFS_FOR_TERSER ? compilerCliModule : compilerCliModule.default);
62
61
  // determine hashing format
63
62
  const hashFormat = (0, helpers_1.getOutputHashFormat)(buildOptions.outputHashing || 'none');
64
- const buildBrowserFeatures = new utils_1.BuildBrowserFeatures(projectRoot);
65
63
  if (buildOptions.progress) {
66
- const spinner = new spinner_1.Spinner();
67
- spinner.start(`Generating ${platform} application bundles (phase: setup)...`);
68
- extraPlugins.push(new webpack_1.ProgressPlugin({
69
- handler: (percentage, message) => {
70
- const phase = message ? ` (phase: ${message})` : '';
71
- spinner.text = `Generating ${platform} application bundles${phase}...`;
72
- switch (percentage) {
73
- case 1:
74
- if (spinner.isSpinning) {
75
- spinner.succeed(`${platform.replace(/^\w/, (s) => s.toUpperCase())} application bundle generation complete.`);
76
- }
77
- break;
78
- case 0:
79
- if (!spinner.isSpinning) {
80
- spinner.start();
81
- }
82
- break;
83
- }
84
- },
85
- }));
64
+ extraPlugins.push(new progress_plugin_1.ProgressPlugin(platform));
86
65
  }
87
66
  if (buildOptions.main) {
88
67
  const mainPath = path.resolve(root, buildOptions.main);
89
68
  entryPoints['main'] = [mainPath];
90
69
  }
91
- if (platform !== 'server') {
70
+ if (isPlatformServer) {
71
+ // Fixes Critical dependency: the request of a dependency is an expression
72
+ extraPlugins.push(new webpack_2.ContextReplacementPlugin(/@?hapi|express[\\/]/));
73
+ }
74
+ if (!isPlatformServer) {
92
75
  if (buildOptions.polyfills) {
93
76
  const projectPolyfills = path.resolve(root, buildOptions.polyfills);
94
77
  if (entryPoints['polyfills']) {
@@ -109,89 +92,34 @@ async function getCommonConfig(wco) {
109
92
  }
110
93
  }
111
94
  if (environment_options_1.profilingEnabled) {
112
- extraPlugins.push(new webpack_1.debug.ProfilingPlugin({
95
+ extraPlugins.push(new webpack_2.debug.ProfilingPlugin({
113
96
  outputPath: path.resolve(root, 'chrome-profiler-events.json'),
114
97
  }));
115
98
  }
99
+ if (allowedCommonJsDependencies) {
100
+ // When this is not defined it means the builder doesn't support showing common js usages.
101
+ // When it does it will be an array.
102
+ extraPlugins.push(new plugins_1.CommonJsUsageWarnPlugin({
103
+ allowedDependencies: allowedCommonJsDependencies,
104
+ }));
105
+ }
116
106
  // process global scripts
117
- const globalScriptsByBundleName = (0, helpers_1.normalizeExtraEntryPoints)(buildOptions.scripts, 'scripts').reduce((prev, curr) => {
118
- const { bundleName, inject, input } = curr;
119
- let resolvedPath = path.resolve(root, input);
120
- if (!(0, fs_1.existsSync)(resolvedPath)) {
121
- try {
122
- resolvedPath = require.resolve(input, { paths: [root] });
123
- }
124
- catch {
125
- throw new Error(`Script file ${input} does not exist.`);
126
- }
127
- }
128
- const existingEntry = prev.find((el) => el.bundleName === bundleName);
129
- if (existingEntry) {
130
- if (existingEntry.inject && !inject) {
131
- // All entries have to be lazy for the bundle to be lazy.
132
- throw new Error(`The ${bundleName} bundle is mixing injected and non-injected scripts.`);
133
- }
134
- existingEntry.paths.push(resolvedPath);
135
- }
136
- else {
137
- prev.push({
138
- bundleName,
139
- inject,
140
- paths: [resolvedPath],
141
- });
142
- }
143
- return prev;
144
- }, []);
145
107
  // Add a new asset for each entry.
146
- for (const script of globalScriptsByBundleName) {
108
+ for (const { bundleName, inject, paths } of (0, helpers_1.globalScriptsByBundleName)(root, buildOptions.scripts)) {
147
109
  // Lazy scripts don't get a hash, otherwise they can't be loaded by name.
148
- const hash = script.inject ? hashFormat.script : '';
149
- const bundleName = script.bundleName;
110
+ const hash = inject ? hashFormat.script : '';
150
111
  extraPlugins.push(new plugins_1.ScriptsWebpackPlugin({
151
112
  name: bundleName,
152
113
  sourceMap: scriptsSourceMap,
114
+ scripts: paths,
153
115
  filename: `${path.basename(bundleName)}${hash}.js`,
154
- scripts: script.paths,
155
116
  basePath: projectRoot,
156
117
  }));
157
118
  }
158
119
  // process asset entries
159
120
  if (buildOptions.assets.length) {
160
- const copyWebpackPluginPatterns = buildOptions.assets.map((asset, index) => {
161
- // Resolve input paths relative to workspace root and add slash at the end.
162
- // eslint-disable-next-line prefer-const
163
- let { input, output, ignore = [], glob } = asset;
164
- input = path.resolve(root, input).replace(/\\/g, '/');
165
- input = input.endsWith('/') ? input : input + '/';
166
- output = output.endsWith('/') ? output : output + '/';
167
- if (output.startsWith('..')) {
168
- throw new Error('An asset cannot be written to a location outside of the output path.');
169
- }
170
- return {
171
- context: input,
172
- // Now we remove starting slash to make Webpack place it from the output root.
173
- to: output.replace(/^\//, ''),
174
- from: glob,
175
- noErrorOnMissing: true,
176
- force: true,
177
- globOptions: {
178
- dot: true,
179
- followSymbolicLinks: !!asset.followSymlinks,
180
- ignore: [
181
- '.gitkeep',
182
- '**/.DS_Store',
183
- '**/Thumbs.db',
184
- // Negate patterns needs to be absolute because copy-webpack-plugin uses absolute globs which
185
- // causes negate patterns not to match.
186
- // See: https://github.com/webpack-contrib/copy-webpack-plugin/issues/498#issuecomment-639327909
187
- ...ignore,
188
- ].map((i) => path.posix.join(input, i)),
189
- },
190
- priority: index,
191
- };
192
- });
193
121
  extraPlugins.push(new copy_webpack_plugin_1.default({
194
- patterns: copyWebpackPluginPatterns,
122
+ patterns: (0, helpers_1.assetPatterns)(root, buildOptions.assets),
195
123
  }));
196
124
  }
197
125
  if (buildOptions.showCircularDependencies) {
@@ -212,26 +140,33 @@ async function getCommonConfig(wco) {
212
140
  skipChildCompilers: true,
213
141
  }));
214
142
  }
143
+ if (scriptsSourceMap || stylesSourceMap) {
144
+ const include = [];
145
+ if (scriptsSourceMap) {
146
+ include.push(/js$/);
147
+ }
148
+ if (stylesSourceMap) {
149
+ include.push(/css$/);
150
+ }
151
+ extraPlugins.push(new webpack_2.SourceMapDevToolPlugin({
152
+ filename: '[file].map',
153
+ include,
154
+ // We want to set sourceRoot to `webpack:///` for non
155
+ // inline sourcemaps as otherwise paths to sourcemaps will be broken in browser
156
+ // `webpack:///` is needed for Visual Studio breakpoints to work properly as currently
157
+ // there is no way to set the 'webRoot'
158
+ sourceRoot: 'webpack:///',
159
+ moduleFilenameTemplate: '[resource-path]',
160
+ append: hiddenSourceMap ? false : undefined,
161
+ }));
162
+ }
215
163
  if (buildOptions.statsJson) {
216
- extraPlugins.push(new (class {
217
- apply(compiler) {
218
- compiler.hooks.done.tapPromise('angular-cli-stats', async (stats) => {
219
- const { stringifyStream } = await Promise.resolve().then(() => __importStar(require('@discoveryjs/json-ext')));
220
- const data = stats.toJson('verbose');
221
- const statsOutputPath = path.resolve(root, buildOptions.outputPath, 'stats.json');
222
- try {
223
- await fs_1.promises.mkdir(path.dirname(statsOutputPath), { recursive: true });
224
- await new Promise((resolve, reject) => stringifyStream(data)
225
- .pipe((0, fs_1.createWriteStream)(statsOutputPath))
226
- .on('close', resolve)
227
- .on('error', reject));
228
- }
229
- catch (error) {
230
- (0, webpack_diagnostics_1.addError)(stats.compilation, `Unable to write stats file: ${error.message || 'unknown error'}`);
231
- }
232
- });
233
- }
234
- })());
164
+ extraPlugins.push(new plugins_1.JsonStatsPlugin(path.resolve(root, buildOptions.outputPath, 'stats.json')));
165
+ }
166
+ if (subresourceIntegrity) {
167
+ extraPlugins.push(new webpack_subresource_integrity_1.SubresourceIntegrityPlugin({
168
+ hashFuncNames: ['sha384'],
169
+ }));
235
170
  }
236
171
  if (scriptsSourceMap || stylesSourceMap) {
237
172
  extraRules.push({
@@ -251,22 +186,43 @@ async function getCommonConfig(wco) {
251
186
  },
252
187
  });
253
188
  }
189
+ if (main || polyfills) {
190
+ extraRules.push({
191
+ test: /\.[cm]?[tj]sx?$/,
192
+ loader: webpack_1.AngularWebpackLoaderPath,
193
+ });
194
+ extraPlugins.push((0, typescript_2.createIvyPlugin)(wco, aot, tsConfigPath));
195
+ }
196
+ if (webWorkerTsConfig) {
197
+ extraPlugins.push((0, typescript_2.createIvyPlugin)(wco, false, path.resolve(wco.root, webWorkerTsConfig)));
198
+ }
254
199
  const extraMinimizers = [];
255
200
  if (scriptsOptimization) {
256
- extraMinimizers.push(new javascript_optimizer_plugin_1.JavaScriptOptimizerPlugin({
201
+ extraMinimizers.push(new plugins_1.JavaScriptOptimizerPlugin({
257
202
  define: buildOptions.aot ? GLOBAL_DEFS_FOR_TERSER_WITH_AOT : GLOBAL_DEFS_FOR_TERSER,
258
203
  sourcemap: scriptsSourceMap,
259
204
  target: wco.scriptTarget,
260
- keepNames: !environment_options_1.allowMangle || platform === 'server',
205
+ keepNames: !environment_options_1.allowMangle || isPlatformServer,
261
206
  removeLicenses: buildOptions.extractLicenses,
262
207
  advanced: buildOptions.buildOptimizer,
263
208
  }));
264
209
  }
210
+ const externals = [...externalDependencies];
211
+ if (isPlatformServer && !bundleDependencies) {
212
+ externals.push(({ context, request }, callback) => (0, helpers_1.externalizePackages)(context !== null && context !== void 0 ? context : wco.projectRoot, request, callback));
213
+ }
214
+ let crossOriginLoading = false;
215
+ if (subresourceIntegrity && crossOrigin === 'none') {
216
+ crossOriginLoading = 'anonymous';
217
+ }
218
+ else if (crossOrigin !== 'none') {
219
+ crossOriginLoading = crossOrigin;
220
+ }
265
221
  return {
266
222
  mode: scriptsOptimization || stylesOptimization.minify ? 'production' : 'development',
267
223
  devtool: false,
268
224
  target: [
269
- platform === 'server' ? 'node' : 'web',
225
+ isPlatformServer ? 'node' : 'web',
270
226
  tsConfig.options.target === typescript_1.ScriptTarget.ES5 ? 'es5' : 'es2015',
271
227
  ],
272
228
  profile: buildOptions.statsJson,
@@ -275,12 +231,17 @@ async function getCommonConfig(wco) {
275
231
  extensions: ['.ts', '.tsx', '.mjs', '.js'],
276
232
  symlinks: !buildOptions.preserveSymlinks,
277
233
  modules: [tsConfig.options.baseUrl || projectRoot, 'node_modules'],
234
+ mainFields: isPlatformServer
235
+ ? ['es2015', 'module', 'main']
236
+ : ['es2020', 'es2015', 'browser', 'module', 'main'],
237
+ conditionNames: isPlatformServer ? ['es2015', '...'] : ['es2020', 'es2015', '...'],
278
238
  },
279
239
  resolveLoader: {
280
240
  symlinks: !buildOptions.preserveSymlinks,
281
241
  },
282
242
  context: root,
283
243
  entry: entryPoints,
244
+ externals,
284
245
  output: {
285
246
  uniqueName: projectName,
286
247
  hashFunction: 'xxhash64',
@@ -289,9 +250,16 @@ async function getCommonConfig(wco) {
289
250
  publicPath: (_b = buildOptions.deployUrl) !== null && _b !== void 0 ? _b : '',
290
251
  filename: `[name]${hashFormat.chunk}.js`,
291
252
  chunkFilename: `[name]${hashFormat.chunk}.js`,
253
+ libraryTarget: isPlatformServer ? 'commonjs' : undefined,
254
+ crossOriginLoading,
255
+ trustedTypes: 'angular#bundler',
256
+ scriptType: 'module',
292
257
  },
293
258
  watch: buildOptions.watch,
294
- watchOptions: (0, helpers_1.getWatchOptions)(buildOptions.poll),
259
+ watchOptions: {
260
+ poll,
261
+ ignored: poll === undefined ? undefined : 'node_modules/**',
262
+ },
295
263
  performance: {
296
264
  hints: false,
297
265
  },
@@ -300,10 +268,21 @@ async function getCommonConfig(wco) {
300
268
  /Failed to parse source map from/,
301
269
  // https://github.com/webpack-contrib/postcss-loader/blob/bd261875fdf9c596af4ffb3a1a73fe3c549befda/src/index.js#L153-L158
302
270
  /Add postcss as project dependency/,
271
+ // esbuild will issue a warning, while still hoists the @charset at the very top.
272
+ // This is caused by a bug in css-loader https://github.com/webpack-contrib/css-loader/issues/1212
273
+ /"@charset" must be the first rule in the file/,
303
274
  ],
304
275
  module: {
305
276
  // Show an error for missing exports instead of a warning.
306
277
  strictExportPresence: true,
278
+ parser: webWorkerTsConfig === undefined
279
+ ? {
280
+ javascript: {
281
+ worker: false,
282
+ url: false,
283
+ },
284
+ }
285
+ : undefined,
307
286
  rules: [
308
287
  {
309
288
  // Mark files inside `rxjs/add` as containing side effects.
@@ -343,50 +322,43 @@ async function getCommonConfig(wco) {
343
322
  asyncWebAssembly: true,
344
323
  },
345
324
  infrastructureLogging: {
346
- level: buildOptions.verbose ? 'verbose' : 'error',
325
+ level: verbose ? 'verbose' : 'error',
347
326
  },
348
- cache: getCacheSettings(wco, buildBrowserFeatures.supportedBrowsers, NG_VERSION.full),
327
+ stats: (0, helpers_1.getStatsOptions)(verbose),
328
+ cache: (0, helpers_1.getCacheSettings)(wco, NG_VERSION.full),
349
329
  optimization: {
350
330
  minimizer: extraMinimizers,
351
331
  moduleIds: 'deterministic',
352
332
  chunkIds: buildOptions.namedChunks ? 'named' : 'deterministic',
353
333
  emitOnErrors: false,
334
+ runtimeChunk: isPlatformServer ? false : 'single',
335
+ splitChunks: {
336
+ maxAsyncRequests: Infinity,
337
+ cacheGroups: {
338
+ default: !!commonChunk && {
339
+ chunks: 'async',
340
+ minChunks: 2,
341
+ priority: 10,
342
+ },
343
+ common: !!commonChunk && {
344
+ name: 'common',
345
+ chunks: 'async',
346
+ minChunks: 2,
347
+ enforce: true,
348
+ priority: 5,
349
+ },
350
+ vendors: false,
351
+ defaultVendors: !!vendorChunk && {
352
+ name: 'vendor',
353
+ chunks: (chunk) => chunk.name === 'main',
354
+ enforce: true,
355
+ test: /[\\/]node_modules[\\/]/,
356
+ },
357
+ },
358
+ },
354
359
  },
355
- plugins: [new plugins_1.DedupeModuleResolvePlugin({ verbose: buildOptions.verbose }), ...extraPlugins],
360
+ plugins: [new plugins_1.DedupeModuleResolvePlugin({ verbose }), ...extraPlugins],
361
+ node: false,
356
362
  };
357
363
  }
358
364
  exports.getCommonConfig = getCommonConfig;
359
- function getCacheSettings(wco, supportedBrowsers, angularVersion) {
360
- const { enabled, path: cacheDirectory } = wco.buildOptions.cache;
361
- if (enabled) {
362
- const packageVersion = require('../../../package.json').version;
363
- return {
364
- type: 'filesystem',
365
- cacheDirectory: path.join(cacheDirectory, 'angular-webpack'),
366
- maxMemoryGenerations: 1,
367
- // We use the versions and build options as the cache name. The Webpack configurations are too
368
- // dynamic and shared among different build types: test, build and serve.
369
- // None of which are "named".
370
- name: (0, crypto_1.createHash)('sha1')
371
- .update(angularVersion)
372
- .update(packageVersion)
373
- .update(wco.projectRoot)
374
- .update(JSON.stringify(wco.tsConfig))
375
- .update(JSON.stringify({
376
- ...wco.buildOptions,
377
- // Needed because outputPath changes on every build when using i18n extraction
378
- // https://github.com/angular/angular-cli/blob/736a5f89deaca85f487b78aec9ff66d4118ceb6a/packages/angular_devkit/build_angular/src/utils/i18n-options.ts#L264-L265
379
- outputPath: undefined,
380
- }))
381
- .update(supportedBrowsers.join(''))
382
- .digest('hex'),
383
- };
384
- }
385
- if (wco.buildOptions.watch) {
386
- return {
387
- type: 'memory',
388
- maxGenerations: 1,
389
- };
390
- }
391
- return false;
392
- }
@@ -6,9 +6,9 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  import { logging } from '@angular-devkit/core';
9
- import * as webpack from 'webpack';
9
+ import { Configuration } from 'webpack';
10
10
  import { WebpackConfigOptions, WebpackDevServerOptions } from '../../utils/build-options';
11
- export declare function getDevServerConfig(wco: WebpackConfigOptions<WebpackDevServerOptions>): Promise<webpack.Configuration>;
11
+ export declare function getDevServerConfig(wco: WebpackConfigOptions<WebpackDevServerOptions>): Promise<Configuration>;
12
12
  /**
13
13
  * Resolve and build a URL _path_ that will be the root of the server. This resolved base href and
14
14
  * deploy URL from the browser options and returns a path from the root.
@@ -6,12 +6,6 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  export * from './analytics';
9
- export * from './browser';
10
9
  export * from './common';
11
10
  export * from './dev-server';
12
- export * from './server';
13
11
  export * from './styles';
14
- export * from './test';
15
- export * from './typescript';
16
- export * from './stats';
17
- export * from './worker';
@@ -18,12 +18,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
20
  __exportStar(require("./analytics"), exports);
21
- __exportStar(require("./browser"), exports);
22
21
  __exportStar(require("./common"), exports);
23
22
  __exportStar(require("./dev-server"), exports);
24
- __exportStar(require("./server"), exports);
25
23
  __exportStar(require("./styles"), exports);
26
- __exportStar(require("./test"), exports);
27
- __exportStar(require("./typescript"), exports);
28
- __exportStar(require("./stats"), exports);
29
- __exportStar(require("./worker"), exports);
@@ -5,6 +5,6 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
- import * as webpack from 'webpack';
8
+ import { Configuration } from 'webpack';
9
9
  import { WebpackConfigOptions } from '../../utils/build-options';
10
- export declare function getStylesConfig(wco: WebpackConfigOptions): webpack.Configuration;
10
+ export declare function getStylesConfig(wco: WebpackConfigOptions): Configuration;
@@ -30,7 +30,6 @@ exports.getStylesConfig = void 0;
30
30
  const fs = __importStar(require("fs"));
31
31
  const path = __importStar(require("path"));
32
32
  const sass_service_1 = require("../../sass/sass-service");
33
- const build_browser_features_1 = require("../../utils/build-browser-features");
34
33
  const plugins_1 = require("../plugins");
35
34
  const css_optimizer_plugin_1 = require("../plugins/css-optimizer-plugin");
36
35
  const helpers_1 = require("../utils/helpers");
@@ -134,9 +133,8 @@ function getStylesConfig(wco) {
134
133
  extraPostcssPlugins.push(require(tailwindPackagePath)({ config: tailwindConfigPath }));
135
134
  }
136
135
  }
137
- const { supportedBrowsers } = new build_browser_features_1.BuildBrowserFeatures(wco.projectRoot);
138
136
  const postcssPresetEnvPlugin = postcssPresetEnv({
139
- browsers: supportedBrowsers,
137
+ browsers: buildOptions.supportedBrowsers,
140
138
  autoprefixer: true,
141
139
  stage: 3,
142
140
  });
@@ -361,7 +359,7 @@ function getStylesConfig(wco) {
361
359
  minimizer: buildOptions.optimization.styles.minify
362
360
  ? [
363
361
  new css_optimizer_plugin_1.CssOptimizerPlugin({
364
- supportedBrowsers,
362
+ supportedBrowsers: buildOptions.supportedBrowsers,
365
363
  }),
366
364
  ]
367
365
  : undefined,
@@ -140,7 +140,6 @@ function restoreFormValues(oldInputs, oldOptions) {
140
140
  case 'date':
141
141
  case 'datetime-local':
142
142
  case 'email':
143
- case 'file':
144
143
  case 'hidden':
145
144
  case 'month':
146
145
  case 'number':
@@ -155,6 +154,10 @@ function restoreFormValues(oldInputs, oldOptions) {
155
154
  case 'week':
156
155
  newElement.value = oldElement.value;
157
156
  break;
157
+ case 'file':
158
+ // Ignored due: Uncaught DOMException: Failed to set the 'value' property on 'HTMLInputElement':
159
+ // This input element accepts a filename, which may only be programmatically set to the empty string.
160
+ break;
158
161
  default:
159
162
  console.warn('[NG HMR] Unknown input type ' + oldElement.type + '.');
160
163
  continue;
@@ -11,4 +11,6 @@ export { SuppressExtractedTextChunksWebpackPlugin } from './suppress-entry-chunk
11
11
  export { RemoveHashPlugin, RemoveHashPluginOptions } from './remove-hash-plugin';
12
12
  export { DedupeModuleResolvePlugin } from './dedupe-module-resolve-plugin';
13
13
  export { CommonJsUsageWarnPlugin } from './common-js-usage-warn-plugin';
14
+ export { JsonStatsPlugin } from './json-stats-plugin';
15
+ export { JavaScriptOptimizerPlugin } from './javascript-optimizer-plugin';
14
16
  export { default as PostcssCliResources, PostcssCliResourcesOptions, } from './postcss-cli-resources';
@@ -10,7 +10,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
10
10
  return (mod && mod.__esModule) ? mod : { "default": mod };
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.PostcssCliResources = exports.CommonJsUsageWarnPlugin = exports.DedupeModuleResolvePlugin = exports.RemoveHashPlugin = exports.SuppressExtractedTextChunksWebpackPlugin = exports.ScriptsWebpackPlugin = exports.AnyComponentStyleBudgetChecker = void 0;
13
+ exports.PostcssCliResources = exports.JavaScriptOptimizerPlugin = exports.JsonStatsPlugin = exports.CommonJsUsageWarnPlugin = exports.DedupeModuleResolvePlugin = exports.RemoveHashPlugin = exports.SuppressExtractedTextChunksWebpackPlugin = exports.ScriptsWebpackPlugin = exports.AnyComponentStyleBudgetChecker = void 0;
14
14
  // Exports the webpack plugins we use internally.
15
15
  var any_component_style_budget_checker_1 = require("./any-component-style-budget-checker");
16
16
  Object.defineProperty(exports, "AnyComponentStyleBudgetChecker", { enumerable: true, get: function () { return any_component_style_budget_checker_1.AnyComponentStyleBudgetChecker; } });
@@ -24,5 +24,9 @@ var dedupe_module_resolve_plugin_1 = require("./dedupe-module-resolve-plugin");
24
24
  Object.defineProperty(exports, "DedupeModuleResolvePlugin", { enumerable: true, get: function () { return dedupe_module_resolve_plugin_1.DedupeModuleResolvePlugin; } });
25
25
  var common_js_usage_warn_plugin_1 = require("./common-js-usage-warn-plugin");
26
26
  Object.defineProperty(exports, "CommonJsUsageWarnPlugin", { enumerable: true, get: function () { return common_js_usage_warn_plugin_1.CommonJsUsageWarnPlugin; } });
27
+ var json_stats_plugin_1 = require("./json-stats-plugin");
28
+ Object.defineProperty(exports, "JsonStatsPlugin", { enumerable: true, get: function () { return json_stats_plugin_1.JsonStatsPlugin; } });
29
+ var javascript_optimizer_plugin_1 = require("./javascript-optimizer-plugin");
30
+ Object.defineProperty(exports, "JavaScriptOptimizerPlugin", { enumerable: true, get: function () { return javascript_optimizer_plugin_1.JavaScriptOptimizerPlugin; } });
27
31
  var postcss_cli_resources_1 = require("./postcss-cli-resources");
28
32
  Object.defineProperty(exports, "PostcssCliResources", { enumerable: true, get: function () { return __importDefault(postcss_cli_resources_1).default; } });
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC 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
+ import { Compiler } from 'webpack';
9
+ export declare class JsonStatsPlugin {
10
+ private readonly statsOutputPath;
11
+ constructor(statsOutputPath: string);
12
+ apply(compiler: Compiler): void;
13
+ }
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ * Copyright Google LLC 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
+ */
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || function (mod) {
22
+ if (mod && mod.__esModule) return mod;
23
+ var result = {};
24
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
+ __setModuleDefault(result, mod);
26
+ return result;
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.JsonStatsPlugin = void 0;
30
+ const fs_1 = require("fs");
31
+ const path_1 = require("path");
32
+ const webpack_diagnostics_1 = require("../../utils/webpack-diagnostics");
33
+ class JsonStatsPlugin {
34
+ constructor(statsOutputPath) {
35
+ this.statsOutputPath = statsOutputPath;
36
+ }
37
+ apply(compiler) {
38
+ compiler.hooks.done.tapPromise('angular-json-stats', async (stats) => {
39
+ const { stringifyStream } = await Promise.resolve().then(() => __importStar(require('@discoveryjs/json-ext')));
40
+ const data = stats.toJson('verbose');
41
+ try {
42
+ await fs_1.promises.mkdir((0, path_1.dirname)(this.statsOutputPath), { recursive: true });
43
+ await new Promise((resolve, reject) => stringifyStream(data)
44
+ .pipe((0, fs_1.createWriteStream)(this.statsOutputPath))
45
+ .on('close', resolve)
46
+ .on('error', reject));
47
+ }
48
+ catch (error) {
49
+ (0, webpack_diagnostics_1.addError)(stats.compilation, `Unable to write stats file: ${error.message || 'unknown error'}`);
50
+ }
51
+ });
52
+ }
53
+ }
54
+ exports.JsonStatsPlugin = JsonStatsPlugin;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC 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
+ import { ProgressPlugin as WebpackProgressPlugin } from 'webpack';
9
+ export declare class ProgressPlugin extends WebpackProgressPlugin {
10
+ constructor(platform: 'server' | 'browser');
11
+ }