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

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 (43) hide show
  1. package/package.json +30 -30
  2. package/src/babel/presets/application.d.ts +8 -0
  3. package/src/babel/presets/application.js +18 -0
  4. package/src/babel/webpack-loader.d.ts +9 -0
  5. package/src/babel/webpack-loader.js +15 -24
  6. package/src/builders/browser/index.js +0 -4
  7. package/src/builders/browser/schema.json +1 -1
  8. package/src/builders/dev-server/index.js +0 -4
  9. package/src/builders/extract-i18n/index.js +11 -14
  10. package/src/builders/karma/index.d.ts +2 -2
  11. package/src/builders/karma/index.js +1 -7
  12. package/src/builders/server/index.js +1 -7
  13. package/src/sass/sass-service.js +2 -2
  14. package/src/sass/worker.js +0 -1
  15. package/src/utils/action-executor.js +4 -5
  16. package/src/utils/build-options.d.ts +0 -2
  17. package/src/utils/i18n-inlining.js +18 -2
  18. package/src/utils/normalize-optimization.js +2 -4
  19. package/src/webpack/configs/common.js +133 -156
  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/plugins/index.d.ts +2 -0
  25. package/src/webpack/plugins/index.js +5 -1
  26. package/src/webpack/plugins/json-stats-plugin.d.ts +13 -0
  27. package/src/webpack/plugins/json-stats-plugin.js +54 -0
  28. package/src/webpack/{configs/worker.d.ts → plugins/progress-plugin.d.ts} +4 -3
  29. package/src/webpack/plugins/progress-plugin.js +38 -0
  30. package/src/webpack/{configs/browser.d.ts → plugins/typescript.d.ts} +2 -2
  31. package/src/webpack/{configs → plugins}/typescript.js +5 -24
  32. package/src/webpack/utils/helpers.d.ts +16 -5
  33. package/src/webpack/utils/helpers.js +174 -34
  34. package/src/webpack/utils/stats.js +1 -2
  35. package/src/webpack/configs/browser.js +0 -81
  36. package/src/webpack/configs/server.d.ts +0 -14
  37. package/src/webpack/configs/server.js +0 -72
  38. package/src/webpack/configs/stats.d.ts +0 -38
  39. package/src/webpack/configs/stats.js +0 -53
  40. package/src/webpack/configs/test.d.ts +0 -10
  41. package/src/webpack/configs/test.js +0 -98
  42. package/src/webpack/configs/typescript.d.ts +0 -12
  43. package/src/webpack/configs/worker.js +0 -22
@@ -30,25 +30,25 @@ 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");
37
+ const webpack_2 = require("webpack");
38
+ const webpack_subresource_integrity_1 = require("webpack-subresource-integrity");
39
39
  const utils_1 = require("../../utils");
40
40
  const environment_options_1 = require("../../utils/environment-options");
41
41
  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
42
  const plugins_1 = require("../plugins");
45
- const javascript_optimizer_plugin_1 = require("../plugins/javascript-optimizer-plugin");
43
+ const progress_plugin_1 = require("../plugins/progress-plugin");
44
+ const typescript_2 = require("../plugins/typescript");
46
45
  const helpers_1 = require("../utils/helpers");
47
46
  // eslint-disable-next-line max-lines-per-function
48
47
  async function getCommonConfig(wco) {
49
48
  var _a, _b;
50
- const { root, projectRoot, buildOptions, tsConfig, projectName } = wco;
51
- const { cache, platform = 'browser', sourceMap: { styles: stylesSourceMap, scripts: scriptsSourceMap, vendor: vendorSourceMap }, optimization: { styles: stylesOptimization, scripts: scriptsOptimization }, } = buildOptions;
49
+ const { root, projectRoot, buildOptions, tsConfig, projectName, sourceRoot, tsConfigPath } = wco;
50
+ 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;
51
+ const isPlatformServer = buildOptions.platform === 'server';
52
52
  const extraPlugins = [];
53
53
  const extraRules = [];
54
54
  const entryPoints = {};
@@ -63,32 +63,17 @@ async function getCommonConfig(wco) {
63
63
  const hashFormat = (0, helpers_1.getOutputHashFormat)(buildOptions.outputHashing || 'none');
64
64
  const buildBrowserFeatures = new utils_1.BuildBrowserFeatures(projectRoot);
65
65
  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
- }));
66
+ extraPlugins.push(new progress_plugin_1.ProgressPlugin(platform));
86
67
  }
87
68
  if (buildOptions.main) {
88
69
  const mainPath = path.resolve(root, buildOptions.main);
89
70
  entryPoints['main'] = [mainPath];
90
71
  }
91
- if (platform !== 'server') {
72
+ if (isPlatformServer) {
73
+ // Fixes Critical dependency: the request of a dependency is an expression
74
+ extraPlugins.push(new webpack_2.ContextReplacementPlugin(/@?hapi|express[\\/]/));
75
+ }
76
+ if (!isPlatformServer) {
92
77
  if (buildOptions.polyfills) {
93
78
  const projectPolyfills = path.resolve(root, buildOptions.polyfills);
94
79
  if (entryPoints['polyfills']) {
@@ -109,89 +94,34 @@ async function getCommonConfig(wco) {
109
94
  }
110
95
  }
111
96
  if (environment_options_1.profilingEnabled) {
112
- extraPlugins.push(new webpack_1.debug.ProfilingPlugin({
97
+ extraPlugins.push(new webpack_2.debug.ProfilingPlugin({
113
98
  outputPath: path.resolve(root, 'chrome-profiler-events.json'),
114
99
  }));
115
100
  }
101
+ if (allowedCommonJsDependencies) {
102
+ // When this is not defined it means the builder doesn't support showing common js usages.
103
+ // When it does it will be an array.
104
+ extraPlugins.push(new plugins_1.CommonJsUsageWarnPlugin({
105
+ allowedDependencies: allowedCommonJsDependencies,
106
+ }));
107
+ }
116
108
  // 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
109
  // Add a new asset for each entry.
146
- for (const script of globalScriptsByBundleName) {
110
+ for (const { bundleName, inject, paths } of (0, helpers_1.globalScriptsByBundleName)(root, buildOptions.scripts)) {
147
111
  // 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;
112
+ const hash = inject ? hashFormat.script : '';
150
113
  extraPlugins.push(new plugins_1.ScriptsWebpackPlugin({
151
114
  name: bundleName,
152
115
  sourceMap: scriptsSourceMap,
116
+ scripts: paths,
153
117
  filename: `${path.basename(bundleName)}${hash}.js`,
154
- scripts: script.paths,
155
118
  basePath: projectRoot,
156
119
  }));
157
120
  }
158
121
  // process asset entries
159
122
  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
123
  extraPlugins.push(new copy_webpack_plugin_1.default({
194
- patterns: copyWebpackPluginPatterns,
124
+ patterns: (0, helpers_1.assetPatterns)(root, buildOptions.assets),
195
125
  }));
196
126
  }
197
127
  if (buildOptions.showCircularDependencies) {
@@ -212,26 +142,33 @@ async function getCommonConfig(wco) {
212
142
  skipChildCompilers: true,
213
143
  }));
214
144
  }
145
+ if (scriptsSourceMap || stylesSourceMap) {
146
+ const include = [];
147
+ if (scriptsSourceMap) {
148
+ include.push(/js$/);
149
+ }
150
+ if (stylesSourceMap) {
151
+ include.push(/css$/);
152
+ }
153
+ extraPlugins.push(new webpack_2.SourceMapDevToolPlugin({
154
+ filename: '[file].map',
155
+ include,
156
+ // We want to set sourceRoot to `webpack:///` for non
157
+ // inline sourcemaps as otherwise paths to sourcemaps will be broken in browser
158
+ // `webpack:///` is needed for Visual Studio breakpoints to work properly as currently
159
+ // there is no way to set the 'webRoot'
160
+ sourceRoot: 'webpack:///',
161
+ moduleFilenameTemplate: '[resource-path]',
162
+ append: hiddenSourceMap ? false : undefined,
163
+ }));
164
+ }
215
165
  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
- })());
166
+ extraPlugins.push(new plugins_1.JsonStatsPlugin(path.resolve(root, buildOptions.outputPath, 'stats.json')));
167
+ }
168
+ if (subresourceIntegrity) {
169
+ extraPlugins.push(new webpack_subresource_integrity_1.SubresourceIntegrityPlugin({
170
+ hashFuncNames: ['sha384'],
171
+ }));
235
172
  }
236
173
  if (scriptsSourceMap || stylesSourceMap) {
237
174
  extraRules.push({
@@ -251,22 +188,43 @@ async function getCommonConfig(wco) {
251
188
  },
252
189
  });
253
190
  }
191
+ if (main || polyfills) {
192
+ extraRules.push({
193
+ test: /\.[cm]?[tj]sx?$/,
194
+ loader: webpack_1.AngularWebpackLoaderPath,
195
+ });
196
+ extraPlugins.push((0, typescript_2.createIvyPlugin)(wco, aot, tsConfigPath));
197
+ }
198
+ if (webWorkerTsConfig) {
199
+ extraPlugins.push((0, typescript_2.createIvyPlugin)(wco, false, path.resolve(wco.root, webWorkerTsConfig)));
200
+ }
254
201
  const extraMinimizers = [];
255
202
  if (scriptsOptimization) {
256
- extraMinimizers.push(new javascript_optimizer_plugin_1.JavaScriptOptimizerPlugin({
203
+ extraMinimizers.push(new plugins_1.JavaScriptOptimizerPlugin({
257
204
  define: buildOptions.aot ? GLOBAL_DEFS_FOR_TERSER_WITH_AOT : GLOBAL_DEFS_FOR_TERSER,
258
205
  sourcemap: scriptsSourceMap,
259
206
  target: wco.scriptTarget,
260
- keepNames: !environment_options_1.allowMangle || platform === 'server',
207
+ keepNames: !environment_options_1.allowMangle || isPlatformServer,
261
208
  removeLicenses: buildOptions.extractLicenses,
262
209
  advanced: buildOptions.buildOptimizer,
263
210
  }));
264
211
  }
212
+ const externals = [...externalDependencies];
213
+ if (isPlatformServer && !bundleDependencies) {
214
+ externals.push(({ context, request }, callback) => (0, helpers_1.externalizePackages)(context !== null && context !== void 0 ? context : wco.projectRoot, request, callback));
215
+ }
216
+ let crossOriginLoading = false;
217
+ if (subresourceIntegrity && crossOrigin === 'none') {
218
+ crossOriginLoading = 'anonymous';
219
+ }
220
+ else if (crossOrigin !== 'none') {
221
+ crossOriginLoading = crossOrigin;
222
+ }
265
223
  return {
266
224
  mode: scriptsOptimization || stylesOptimization.minify ? 'production' : 'development',
267
225
  devtool: false,
268
226
  target: [
269
- platform === 'server' ? 'node' : 'web',
227
+ isPlatformServer ? 'node' : 'web',
270
228
  tsConfig.options.target === typescript_1.ScriptTarget.ES5 ? 'es5' : 'es2015',
271
229
  ],
272
230
  profile: buildOptions.statsJson,
@@ -275,12 +233,17 @@ async function getCommonConfig(wco) {
275
233
  extensions: ['.ts', '.tsx', '.mjs', '.js'],
276
234
  symlinks: !buildOptions.preserveSymlinks,
277
235
  modules: [tsConfig.options.baseUrl || projectRoot, 'node_modules'],
236
+ mainFields: isPlatformServer
237
+ ? ['es2015', 'module', 'main']
238
+ : ['es2020', 'es2015', 'browser', 'module', 'main'],
239
+ conditionNames: isPlatformServer ? ['es2015', '...'] : ['es2020', 'es2015', '...'],
278
240
  },
279
241
  resolveLoader: {
280
242
  symlinks: !buildOptions.preserveSymlinks,
281
243
  },
282
244
  context: root,
283
245
  entry: entryPoints,
246
+ externals,
284
247
  output: {
285
248
  uniqueName: projectName,
286
249
  hashFunction: 'xxhash64',
@@ -289,9 +252,16 @@ async function getCommonConfig(wco) {
289
252
  publicPath: (_b = buildOptions.deployUrl) !== null && _b !== void 0 ? _b : '',
290
253
  filename: `[name]${hashFormat.chunk}.js`,
291
254
  chunkFilename: `[name]${hashFormat.chunk}.js`,
255
+ libraryTarget: isPlatformServer ? 'commonjs' : undefined,
256
+ crossOriginLoading,
257
+ trustedTypes: 'angular#bundler',
258
+ scriptType: 'module',
292
259
  },
293
260
  watch: buildOptions.watch,
294
- watchOptions: (0, helpers_1.getWatchOptions)(buildOptions.poll),
261
+ watchOptions: {
262
+ poll,
263
+ ignored: poll === undefined ? undefined : 'node_modules/**',
264
+ },
295
265
  performance: {
296
266
  hints: false,
297
267
  },
@@ -304,6 +274,14 @@ async function getCommonConfig(wco) {
304
274
  module: {
305
275
  // Show an error for missing exports instead of a warning.
306
276
  strictExportPresence: true,
277
+ parser: webWorkerTsConfig === undefined
278
+ ? {
279
+ javascript: {
280
+ worker: false,
281
+ url: false,
282
+ },
283
+ }
284
+ : undefined,
307
285
  rules: [
308
286
  {
309
287
  // Mark files inside `rxjs/add` as containing side effects.
@@ -325,6 +303,12 @@ async function getCommonConfig(wco) {
325
303
  scriptTarget: wco.scriptTarget,
326
304
  aot: buildOptions.aot,
327
305
  optimize: buildOptions.buildOptimizer,
306
+ instrumentCode: codeCoverage
307
+ ? {
308
+ includedBasePath: sourceRoot,
309
+ excludedPaths: (0, helpers_1.getInstrumentationExcludedPaths)(root, codeCoverageExclude),
310
+ }
311
+ : undefined,
328
312
  },
329
313
  },
330
314
  ],
@@ -337,50 +321,43 @@ async function getCommonConfig(wco) {
337
321
  asyncWebAssembly: true,
338
322
  },
339
323
  infrastructureLogging: {
340
- level: buildOptions.verbose ? 'verbose' : 'error',
324
+ level: verbose ? 'verbose' : 'error',
341
325
  },
342
- cache: getCacheSettings(wco, buildBrowserFeatures.supportedBrowsers, NG_VERSION.full),
326
+ stats: (0, helpers_1.getStatsOptions)(verbose),
327
+ cache: (0, helpers_1.getCacheSettings)(wco, buildBrowserFeatures.supportedBrowsers, NG_VERSION.full),
343
328
  optimization: {
344
329
  minimizer: extraMinimizers,
345
330
  moduleIds: 'deterministic',
346
331
  chunkIds: buildOptions.namedChunks ? 'named' : 'deterministic',
347
332
  emitOnErrors: false,
333
+ runtimeChunk: isPlatformServer ? false : 'single',
334
+ splitChunks: {
335
+ maxAsyncRequests: Infinity,
336
+ cacheGroups: {
337
+ default: !!commonChunk && {
338
+ chunks: 'async',
339
+ minChunks: 2,
340
+ priority: 10,
341
+ },
342
+ common: !!commonChunk && {
343
+ name: 'common',
344
+ chunks: 'async',
345
+ minChunks: 2,
346
+ enforce: true,
347
+ priority: 5,
348
+ },
349
+ vendors: false,
350
+ defaultVendors: !!vendorChunk && {
351
+ name: 'vendor',
352
+ chunks: (chunk) => chunk.name === 'main',
353
+ enforce: true,
354
+ test: /[\\/]node_modules[\\/]/,
355
+ },
356
+ },
357
+ },
348
358
  },
349
- plugins: [new plugins_1.DedupeModuleResolvePlugin({ verbose: buildOptions.verbose }), ...extraPlugins],
359
+ plugins: [new plugins_1.DedupeModuleResolvePlugin({ verbose }), ...extraPlugins],
360
+ node: false,
350
361
  };
351
362
  }
352
363
  exports.getCommonConfig = getCommonConfig;
353
- function getCacheSettings(wco, supportedBrowsers, angularVersion) {
354
- const { enabled, path: cacheDirectory } = wco.buildOptions.cache;
355
- if (enabled) {
356
- const packageVersion = require('../../../package.json').version;
357
- return {
358
- type: 'filesystem',
359
- cacheDirectory: path.join(cacheDirectory, 'angular-webpack'),
360
- maxMemoryGenerations: 1,
361
- // We use the versions and build options as the cache name. The Webpack configurations are too
362
- // dynamic and shared among different build types: test, build and serve.
363
- // None of which are "named".
364
- name: (0, crypto_1.createHash)('sha1')
365
- .update(angularVersion)
366
- .update(packageVersion)
367
- .update(wco.projectRoot)
368
- .update(JSON.stringify(wco.tsConfig))
369
- .update(JSON.stringify({
370
- ...wco.buildOptions,
371
- // Needed because outputPath changes on every build when using i18n extraction
372
- // https://github.com/angular/angular-cli/blob/736a5f89deaca85f487b78aec9ff66d4118ceb6a/packages/angular_devkit/build_angular/src/utils/i18n-options.ts#L264-L265
373
- outputPath: undefined,
374
- }))
375
- .update(supportedBrowsers.join(''))
376
- .digest('hex'),
377
- };
378
- }
379
- if (wco.buildOptions.watch) {
380
- return {
381
- type: 'memory',
382
- maxGenerations: 1,
383
- };
384
- }
385
- return false;
386
- }
@@ -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;
@@ -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;
@@ -5,6 +5,7 @@
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 { Configuration } from 'webpack';
9
- import { WebpackConfigOptions } from '../../utils/build-options';
10
- export declare function getWorkerConfig(wco: WebpackConfigOptions): Configuration;
8
+ import { ProgressPlugin as WebpackProgressPlugin } from 'webpack';
9
+ export declare class ProgressPlugin extends WebpackProgressPlugin {
10
+ constructor(platform: 'server' | 'browser');
11
+ }
@@ -0,0 +1,38 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.ProgressPlugin = void 0;
11
+ const webpack_1 = require("webpack");
12
+ const spinner_1 = require("../../utils/spinner");
13
+ class ProgressPlugin extends webpack_1.ProgressPlugin {
14
+ constructor(platform) {
15
+ const platformCapitalFirst = platform.replace(/^\w/, (s) => s.toUpperCase());
16
+ const spinner = new spinner_1.Spinner();
17
+ spinner.start(`Generating ${platform} application bundles (phase: setup)...`);
18
+ super({
19
+ handler: (percentage, message) => {
20
+ const phase = message ? ` (phase: ${message})` : '';
21
+ spinner.text = `Generating ${platform} application bundles${phase}...`;
22
+ switch (percentage) {
23
+ case 1:
24
+ if (spinner.isSpinning) {
25
+ spinner.succeed(`${platformCapitalFirst} application bundle generation complete.`);
26
+ }
27
+ break;
28
+ case 0:
29
+ if (!spinner.isSpinning) {
30
+ spinner.start();
31
+ }
32
+ break;
33
+ }
34
+ },
35
+ });
36
+ }
37
+ }
38
+ exports.ProgressPlugin = ProgressPlugin;
@@ -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 { AngularWebpackPlugin } from '@ngtools/webpack';
9
9
  import { WebpackConfigOptions } from '../../utils/build-options';
10
- export declare function getBrowserConfig(wco: WebpackConfigOptions): webpack.Configuration;
10
+ export declare function createIvyPlugin(wco: WebpackConfigOptions, aot: boolean, tsconfig: string): AngularWebpackPlugin;