@angular-devkit/build-angular 12.2.0-next.0 → 12.2.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 (40) hide show
  1. package/package.json +33 -32
  2. package/src/app-shell/index.js +3 -5
  3. package/src/babel/plugins/adjust-static-class-members.js +22 -1
  4. package/src/babel/presets/application.d.ts +0 -1
  5. package/src/babel/presets/application.js +3 -2
  6. package/src/babel/webpack-loader.js +0 -9
  7. package/src/browser/index.js +13 -3
  8. package/src/browser/schema.d.ts +1 -1
  9. package/src/browser/schema.json +1 -1
  10. package/src/dev-server/index.js +2 -2
  11. package/src/extract-i18n/index.js +1 -1
  12. package/src/extract-i18n/ivy-extract-loader.d.ts +6 -1
  13. package/src/extract-i18n/ivy-extract-loader.js +8 -12
  14. package/src/karma/index.js +1 -1
  15. package/src/server/index.js +1 -1
  16. package/src/server/tests/setup.d.ts +18 -0
  17. package/src/server/tests/setup.js +27 -0
  18. package/src/utils/action-executor.d.ts +3 -8
  19. package/src/utils/action-executor.js +19 -73
  20. package/src/utils/delete-output-dir.js +28 -2
  21. package/src/utils/index-file/inline-fonts.d.ts +3 -1
  22. package/src/utils/index-file/inline-fonts.js +112 -55
  23. package/src/utils/process-bundle.d.ts +0 -5
  24. package/src/utils/process-bundle.js +50 -140
  25. package/src/utils/version.d.ts +1 -2
  26. package/src/utils/version.js +5 -4
  27. package/src/webpack/configs/browser.js +0 -16
  28. package/src/webpack/configs/common.js +56 -67
  29. package/src/webpack/configs/server.js +0 -1
  30. package/src/webpack/configs/styles.js +92 -75
  31. package/src/webpack/plugins/builder-watch-plugin.d.ts +1 -26
  32. package/src/webpack/plugins/hmr/hmr-accept.js +1 -0
  33. package/src/webpack/plugins/javascript-optimizer-plugin.d.ts +59 -0
  34. package/src/webpack/plugins/javascript-optimizer-plugin.js +150 -0
  35. package/src/webpack/plugins/javascript-optimizer-worker.d.ts +37 -0
  36. package/src/webpack/plugins/javascript-optimizer-worker.js +74 -0
  37. package/src/webpack/plugins/postcss-cli-resources.d.ts +1 -1
  38. package/src/webpack/plugins/postcss-cli-resources.js +2 -1
  39. package/src/webpack/plugins/single-test-transform.d.ts +1 -1
  40. package/src/webpack/plugins/single-test-transform.js +1 -2
@@ -8,7 +8,6 @@
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.getBrowserConfig = void 0;
11
- const typescript_1 = require("typescript");
12
11
  const utils_1 = require("../../utils");
13
12
  const plugins_1 = require("../plugins");
14
13
  const helpers_1 = require("../utils/helpers");
@@ -23,18 +22,6 @@ function getBrowserConfig(wco) {
23
22
  hashFuncNames: ['sha384'],
24
23
  }));
25
24
  }
26
- if (extractLicenses) {
27
- const LicenseWebpackPlugin = require('license-webpack-plugin').LicenseWebpackPlugin;
28
- extraPlugins.push(new LicenseWebpackPlugin({
29
- stats: {
30
- warnings: false,
31
- errors: false,
32
- },
33
- perChunkOutput: false,
34
- outputFilename: '3rdpartylicenses.txt',
35
- skipChildCompilers: true,
36
- }));
37
- }
38
25
  if (scriptsSourceMap || stylesSourceMap) {
39
26
  extraPlugins.push(helpers_1.getSourceMapDevTool(scriptsSourceMap, stylesSourceMap, buildOptions.differentialLoadingNeeded && !buildOptions.watch ? true : hiddenSourceMap, false));
40
27
  }
@@ -51,9 +38,6 @@ function getBrowserConfig(wco) {
51
38
  resolve: {
52
39
  mainFields: ['es2015', 'browser', 'module', 'main'],
53
40
  },
54
- target: wco.tsConfig.options.target === typescript_1.ScriptTarget.ES5 || buildBrowserFeatures.isEs5SupportNeeded()
55
- ? ['web', 'es5']
56
- : 'web',
57
41
  output: {
58
42
  crossOriginLoading,
59
43
  trustedTypes: 'angular#bundler',
@@ -45,6 +45,7 @@ const find_up_1 = require("../../utils/find-up");
45
45
  const spinner_1 = require("../../utils/spinner");
46
46
  const webpack_diagnostics_1 = require("../../utils/webpack-diagnostics");
47
47
  const plugins_1 = require("../plugins");
48
+ const javascript_optimizer_plugin_1 = require("../plugins/javascript-optimizer-plugin");
48
49
  const helpers_1 = require("../utils/helpers");
49
50
  // eslint-disable-next-line max-lines-per-function
50
51
  function getCommonConfig(wco) {
@@ -170,7 +171,7 @@ function getCommonConfig(wco) {
170
171
  }
171
172
  // process asset entries
172
173
  if (buildOptions.assets.length) {
173
- const copyWebpackPluginPatterns = buildOptions.assets.map((asset) => {
174
+ const copyWebpackPluginPatterns = buildOptions.assets.map((asset, index) => {
174
175
  // Resolve input paths relative to workspace root and add slash at the end.
175
176
  // eslint-disable-next-line prefer-const
176
177
  let { input, output, ignore = [], glob } = asset;
@@ -200,6 +201,7 @@ function getCommonConfig(wco) {
200
201
  ...ignore,
201
202
  ].map((i) => path.posix.join(input, i)),
202
203
  },
204
+ priority: index,
203
205
  };
204
206
  });
205
207
  extraPlugins.push(new copy_webpack_plugin_1.default({
@@ -212,6 +214,18 @@ function getCommonConfig(wco) {
212
214
  exclude: /[\\\/]node_modules[\\\/]/,
213
215
  }));
214
216
  }
217
+ if (buildOptions.extractLicenses) {
218
+ const LicenseWebpackPlugin = require('license-webpack-plugin').LicenseWebpackPlugin;
219
+ extraPlugins.push(new LicenseWebpackPlugin({
220
+ stats: {
221
+ warnings: false,
222
+ errors: false,
223
+ },
224
+ perChunkOutput: false,
225
+ outputFilename: '3rdpartylicenses.txt',
226
+ skipChildCompilers: true,
227
+ }));
228
+ }
215
229
  if (buildOptions.statsJson) {
216
230
  extraPlugins.push(new (class {
217
231
  apply(compiler) {
@@ -253,83 +267,53 @@ function getCommonConfig(wco) {
253
267
  }
254
268
  const extraMinimizers = [];
255
269
  if (scriptsOptimization) {
256
- const TerserPlugin = require('terser-webpack-plugin');
257
- const angularGlobalDefinitions = buildOptions.aot
258
- ? compiler_cli_1.GLOBAL_DEFS_FOR_TERSER_WITH_AOT
259
- : compiler_cli_1.GLOBAL_DEFS_FOR_TERSER;
260
- // TODO: Investigate why this fails for some packages: wco.supportES2015 ? 6 : 5;
261
- const terserEcma = 5;
262
- const terserOptions = {
263
- warnings: !!buildOptions.verbose,
264
- safari10: true,
265
- output: {
266
- ecma: terserEcma,
267
- // For differential loading, this is handled in the bundle processing.
268
- ascii_only: !differentialLoadingMode,
269
- // Default behavior (undefined value) is to keep only important comments (licenses, etc.)
270
- comments: !buildOptions.extractLicenses && undefined,
271
- webkit: true,
272
- beautify: environment_options_1.shouldBeautify,
273
- wrap_func_args: false,
274
- },
275
- // On server, we don't want to compress anything. We still set the ngDevMode = false for it
276
- // to remove dev code, and ngI18nClosureMode to remove Closure compiler i18n code
277
- compress: environment_options_1.allowMinify &&
278
- (platform === 'server'
279
- ? {
280
- ecma: terserEcma,
281
- global_defs: angularGlobalDefinitions,
282
- keep_fnames: true,
283
- }
284
- : {
285
- ecma: terserEcma,
286
- pure_getters: buildOptions.buildOptimizer,
287
- // PURE comments work best with 3 passes.
288
- // See https://github.com/webpack/webpack/issues/2899#issuecomment-317425926.
289
- passes: buildOptions.buildOptimizer ? 3 : 1,
290
- global_defs: angularGlobalDefinitions,
291
- pure_funcs: ['forwardRef'],
292
- }),
293
- // We also want to avoid mangling on server.
294
- // Name mangling is handled within the browser builder
295
- mangle: environment_options_1.allowMangle && platform !== 'server' && !differentialLoadingMode,
296
- };
297
270
  const globalScriptsNames = globalScriptsByBundleName.map((s) => s.bundleName);
298
- extraMinimizers.push(new TerserPlugin({
299
- parallel: environment_options_1.maxWorkers,
300
- extractComments: false,
301
- exclude: globalScriptsNames,
302
- terserOptions,
303
- }),
304
- // Script bundles are fully optimized here in one step since they are never downleveled.
305
- // They are shared between ES2015 & ES5 outputs so must support ES5.
306
- new TerserPlugin({
307
- parallel: environment_options_1.maxWorkers,
308
- extractComments: false,
309
- include: globalScriptsNames,
310
- terserOptions: {
311
- ...terserOptions,
312
- compress: environment_options_1.allowMinify && {
313
- ...terserOptions.compress,
271
+ if (globalScriptsNames.length > 0) {
272
+ // Script bundles are fully optimized here in one step since they are never downleveled.
273
+ // They are shared between ES2015 & ES5 outputs so must support ES5.
274
+ // The `terser-webpack-plugin` will add the minified flag to the asset which will prevent
275
+ // additional optimizations by the next plugin.
276
+ const TerserPlugin = require('terser-webpack-plugin');
277
+ extraMinimizers.push(new TerserPlugin({
278
+ parallel: environment_options_1.maxWorkers,
279
+ extractComments: false,
280
+ include: globalScriptsNames,
281
+ terserOptions: {
314
282
  ecma: 5,
283
+ compress: environment_options_1.allowMinify,
284
+ output: {
285
+ ascii_only: true,
286
+ wrap_func_args: false,
287
+ },
288
+ mangle: environment_options_1.allowMangle && platform !== 'server',
315
289
  },
316
- output: {
317
- ...terserOptions.output,
318
- ecma: 5,
319
- },
320
- mangle: environment_options_1.allowMangle && platform !== 'server',
321
- },
290
+ }));
291
+ }
292
+ extraMinimizers.push(new javascript_optimizer_plugin_1.JavaScriptOptimizerPlugin({
293
+ define: buildOptions.aot ? compiler_cli_1.GLOBAL_DEFS_FOR_TERSER_WITH_AOT : compiler_cli_1.GLOBAL_DEFS_FOR_TERSER,
294
+ sourcemap: scriptsSourceMap,
295
+ target: wco.scriptTarget,
296
+ keepNames: !environment_options_1.allowMangle || platform === 'server',
297
+ removeLicenses: buildOptions.extractLicenses,
298
+ advanced: buildOptions.buildOptimizer,
322
299
  }));
323
300
  }
324
301
  return {
325
302
  mode: scriptsOptimization || stylesOptimization.minify ? 'production' : 'development',
326
303
  devtool: false,
304
+ target: [
305
+ platform === 'server' ? 'node' : 'web',
306
+ tsConfig.options.target === typescript_1.ScriptTarget.ES5 ||
307
+ (platform !== 'server' && buildBrowserFeatures.isEs5SupportNeeded())
308
+ ? 'es5'
309
+ : 'es2015',
310
+ ],
327
311
  profile: buildOptions.statsJson,
328
312
  resolve: {
329
313
  roots: [projectRoot],
330
314
  extensions: ['.ts', '.tsx', '.mjs', '.js'],
331
315
  symlinks: !buildOptions.preserveSymlinks,
332
- modules: [wco.tsConfig.options.baseUrl || projectRoot, 'node_modules'],
316
+ modules: [tsConfig.options.baseUrl || projectRoot, 'node_modules'],
333
317
  },
334
318
  resolveLoader: {
335
319
  symlinks: !buildOptions.preserveSymlinks,
@@ -445,9 +429,14 @@ function getCacheSettings(wco, supportedBrowsers) {
445
429
  .update(packageVersion)
446
430
  .update(wco.projectRoot)
447
431
  .update(JSON.stringify(wco.tsConfig))
448
- .update(JSON.stringify(wco.buildOptions))
432
+ .update(JSON.stringify({
433
+ ...wco.buildOptions,
434
+ // Needed because outputPath changes on every build when using i18n extraction
435
+ // https://github.com/angular/angular-cli/blob/736a5f89deaca85f487b78aec9ff66d4118ceb6a/packages/angular_devkit/build_angular/src/utils/i18n-options.ts#L264-L265
436
+ outputPath: undefined,
437
+ }))
449
438
  .update(supportedBrowsers.join(''))
450
- .digest('base64'),
439
+ .digest('hex'),
451
440
  };
452
441
  }
453
442
  if (wco.buildOptions.watch && !environment_options_1.cachingDisabled) {
@@ -30,7 +30,6 @@ function getServerConfig(wco) {
30
30
  resolve: {
31
31
  mainFields: ['es2015', 'main', 'module'],
32
32
  },
33
- target: 'node',
34
33
  output: {
35
34
  libraryTarget: 'commonjs',
36
35
  },
@@ -207,12 +207,13 @@ function getStylesConfig(wco) {
207
207
  extraPlugins.push(new plugins_1.SuppressExtractedTextChunksWebpackPlugin());
208
208
  }
209
209
  }
210
+ const postCss = require('postcss');
211
+ const postCssLoaderPath = require.resolve('postcss-loader');
210
212
  const componentStyleLoaders = [
211
- { loader: require.resolve('raw-loader') },
212
213
  {
213
- loader: require.resolve('postcss-loader'),
214
+ loader: postCssLoaderPath,
214
215
  options: {
215
- implementation: require('postcss'),
216
+ implementation: postCss,
216
217
  postcssOptions: postcssOptionsCreator(componentsSourceMap, false),
217
218
  },
218
219
  },
@@ -231,23 +232,77 @@ function getStylesConfig(wco) {
231
232
  },
232
233
  },
233
234
  {
234
- loader: require.resolve('postcss-loader'),
235
+ loader: postCssLoaderPath,
235
236
  options: {
236
- implementation: require('postcss'),
237
+ implementation: postCss,
237
238
  postcssOptions: postcssOptionsCreator(false, buildOptions.extractCss),
238
239
  sourceMap: !!cssSourceMap,
239
240
  },
240
241
  },
241
242
  ];
243
+ const extraMinimizers = [];
244
+ if (buildOptions.optimization.styles.minify) {
245
+ const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
246
+ const esbuild = require('esbuild');
247
+ const cssnanoOptions = {
248
+ preset: [
249
+ 'default',
250
+ {
251
+ // Disable SVG optimizations, as this can cause optimizations which are not compatible in all browsers.
252
+ svgo: false,
253
+ // Disable `calc` optimizations, due to several issues. #16910, #16875, #17890
254
+ calc: false,
255
+ // Disable CSS rules sorted due to several issues #20693, https://github.com/ionic-team/ionic-framework/issues/23266 and https://github.com/cssnano/cssnano/issues/1054
256
+ cssDeclarationSorter: false,
257
+ // Workaround for Critters as it doesn't work when `@media all {}` is minified to `@media {}`.
258
+ // TODO: Remove once they move to postcss.
259
+ minifyParams: !buildOptions.optimization.styles.inlineCritical,
260
+ },
261
+ ],
262
+ };
263
+ const globalBundlesRegExp = new RegExp(`^(${Object.keys(entryPoints).join('|')})(\.[0-9a-f]{20})?.css$`);
264
+ extraMinimizers.push(
265
+ // Component styles use esbuild which is faster and generates smaller files on average.
266
+ // esbuild does not yet support style sourcemaps but component style sourcemaps are not
267
+ // supported by the CLI when style minify is enabled.
268
+ new CssMinimizerPlugin({
269
+ // Component styles retain their original file name
270
+ test: /\.(?:css|scss|sass|less|styl)$/,
271
+ exclude: globalBundlesRegExp,
272
+ parallel: false,
273
+ minify: async (data) => {
274
+ const [[sourcefile, input]] = Object.entries(data);
275
+ const { code, warnings } = await esbuild.transform(input, {
276
+ loader: 'css',
277
+ minify: true,
278
+ sourcefile,
279
+ });
280
+ return {
281
+ code,
282
+ warnings: warnings.length > 0
283
+ ? await esbuild.formatMessages(warnings, { kind: 'warning' })
284
+ : [],
285
+ };
286
+ },
287
+ }),
288
+ // Global styles use cssnano since sourcemap support is required even when minify
289
+ // is enabled. Once esbuild supports style sourcemaps this can be changed.
290
+ // esbuild stylesheet source map support issue: https://github.com/evanw/esbuild/issues/519
291
+ new CssMinimizerPlugin({
292
+ test: /\.css$/,
293
+ include: globalBundlesRegExp,
294
+ parallel: environment_options_1.maxWorkers,
295
+ minify: [CssMinimizerPlugin.cssnanoMinify],
296
+ minimizerOptions: cssnanoOptions,
297
+ }));
298
+ }
242
299
  const styleLanguages = [
243
300
  {
244
301
  extensions: ['css'],
245
- mimetype: 'text/css',
246
302
  use: [],
247
303
  },
248
304
  {
249
305
  extensions: ['scss'],
250
- mimetype: 'text/x-scss',
251
306
  use: [
252
307
  {
253
308
  loader: require.resolve('resolve-url-loader'),
@@ -270,6 +325,9 @@ function getStylesConfig(wco) {
270
325
  // Ex: /* autoprefixer grid: autoplace */
271
326
  // See: https://github.com/webpack-contrib/sass-loader/blob/45ad0be17264ceada5f0b4fb87e9357abe85c4ff/src/getSassOptions.js#L68-L70
272
327
  outputStyle: 'expanded',
328
+ // Silences compiler warnings from 3rd party stylesheets
329
+ quietDeps: !buildOptions.verbose,
330
+ verbose: buildOptions.verbose,
273
331
  },
274
332
  },
275
333
  },
@@ -277,7 +335,6 @@ function getStylesConfig(wco) {
277
335
  },
278
336
  {
279
337
  extensions: ['sass'],
280
- mimetype: 'text/x-sass',
281
338
  use: [
282
339
  {
283
340
  loader: require.resolve('resolve-url-loader'),
@@ -291,6 +348,8 @@ function getStylesConfig(wco) {
291
348
  implementation: sassImplementation,
292
349
  sourceMap: true,
293
350
  sassOptions: {
351
+ // Prevent use of `fibers` package as it no longer works in newer Node.js versions
352
+ fiber: false,
294
353
  indentedSyntax: true,
295
354
  // bootstrap-sass requires a minimum precision of 8
296
355
  precision: 8,
@@ -299,6 +358,9 @@ function getStylesConfig(wco) {
299
358
  // Ex: /* autoprefixer grid: autoplace */
300
359
  // See: https://github.com/webpack-contrib/sass-loader/blob/45ad0be17264ceada5f0b4fb87e9357abe85c4ff/src/getSassOptions.js#L68-L70
301
360
  outputStyle: 'expanded',
361
+ // Silences compiler warnings from 3rd party stylesheets
362
+ quietDeps: !buildOptions.verbose,
363
+ verbose: buildOptions.verbose,
302
364
  },
303
365
  },
304
366
  },
@@ -306,7 +368,6 @@ function getStylesConfig(wco) {
306
368
  },
307
369
  {
308
370
  extensions: ['less'],
309
- mimetype: 'text/x-less',
310
371
  use: [
311
372
  {
312
373
  loader: require.resolve('less-loader'),
@@ -323,7 +384,6 @@ function getStylesConfig(wco) {
323
384
  },
324
385
  {
325
386
  extensions: ['styl'],
326
- mimetype: 'text/x-stylus',
327
387
  use: [
328
388
  {
329
389
  loader: require.resolve('stylus-loader'),
@@ -339,74 +399,31 @@ function getStylesConfig(wco) {
339
399
  ],
340
400
  },
341
401
  ];
342
- const inlineLanguageRules = [];
343
- const fileLanguageRules = [];
344
- for (const language of styleLanguages) {
345
- if (language.mimetype) {
346
- // inline component styles use data URIs and processing is selected by mimetype
347
- inlineLanguageRules.push({
348
- mimetype: language.mimetype,
349
- use: [...componentStyleLoaders, ...language.use],
350
- });
351
- }
352
- fileLanguageRules.push({
353
- test: new RegExp(`\\.(?:${language.extensions.join('|')})$`, 'i'),
354
- rules: [
355
- // Setup processing rules for global and component styles
356
- {
357
- oneOf: [
358
- // Component styles are all styles except defined global styles
359
- {
360
- exclude: globalStylePaths,
361
- use: componentStyleLoaders,
362
- },
363
- // Global styles are only defined global styles
364
- {
365
- include: globalStylePaths,
366
- use: globalStyleLoaders,
367
- },
368
- ],
369
- },
370
- { use: language.use },
371
- ],
372
- });
373
- }
374
- const extraMinimizers = [];
375
- if (buildOptions.optimization.styles.minify) {
376
- const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
377
- const minimizerOptions = {
378
- preset: [
379
- 'default',
380
- {
381
- // Disable SVG optimizations, as this can cause optimizations which are not compatible in all browsers.
382
- svgo: false,
383
- // Disable `calc` optimizations, due to several issues. #16910, #16875, #17890
384
- calc: false,
385
- // Disable CSS rules sorted due to several issues #20693, https://github.com/ionic-team/ionic-framework/issues/23266 and https://github.com/cssnano/cssnano/issues/1054
386
- cssDeclarationSorter: false,
387
- },
388
- ],
389
- };
390
- const globalBundlesRegExp = new RegExp(`^(${Object.keys(entryPoints).join('|')})(\.[0-9a-f]{20})?.css$`);
391
- extraMinimizers.push(new CssMinimizerPlugin({
392
- // Component styles retain their original file name
393
- test: /\.(?:css|scss|sass|less|styl)$/,
394
- parallel: false,
395
- exclude: globalBundlesRegExp,
396
- minify: [CssMinimizerPlugin.cssnanoMinify],
397
- minimizerOptions,
398
- }), new CssMinimizerPlugin({
399
- test: /\.css$/,
400
- include: globalBundlesRegExp,
401
- parallel: environment_options_1.maxWorkers,
402
- minify: [CssMinimizerPlugin.cssnanoMinify],
403
- minimizerOptions,
404
- }));
405
- }
406
402
  return {
407
403
  entry: entryPoints,
408
404
  module: {
409
- rules: [...fileLanguageRules, ...inlineLanguageRules],
405
+ rules: styleLanguages.map(({ extensions, use }) => ({
406
+ test: new RegExp(`\\.(?:${extensions.join('|')})$`, 'i'),
407
+ rules: [
408
+ // Setup processing rules for global and component styles
409
+ {
410
+ oneOf: [
411
+ // Component styles are all styles except defined global styles
412
+ {
413
+ exclude: globalStylePaths,
414
+ use: componentStyleLoaders,
415
+ type: 'asset/source',
416
+ },
417
+ // Global styles are only defined global styles
418
+ {
419
+ include: globalStylePaths,
420
+ use: globalStyleLoaders,
421
+ },
422
+ ],
423
+ },
424
+ { use },
425
+ ],
426
+ })),
410
427
  },
411
428
  optimization: {
412
429
  minimizer: extraMinimizers,
@@ -16,33 +16,8 @@ export interface BuilderWatcherFactory {
16
16
  close(): void;
17
17
  };
18
18
  }
19
- export interface WebpackWatcher {
20
- close(): void;
21
- pause(): void;
22
- getFileTimeInfoEntries(): Map<string, {
23
- safeTime: number;
24
- timestamp: number;
25
- }>;
26
- getContextTimeInfoEntries(): Map<string, {
27
- safeTime: number;
28
- timestamp: number;
29
- }>;
30
- }
31
- declare type WatchCallback = (error: Error | undefined, files: Map<string, {
32
- safeTime: number;
33
- timestamp: number;
34
- }>, contexts: Map<string, {
35
- safeTime: number;
36
- timestamp: number;
37
- }>, changes: Set<string>, removals: Set<string>) => void;
38
- export interface WebpackWatchFileSystem {
39
- watch(files: Iterable<string>, directories: Iterable<string>, missing: Iterable<string>, startTime: number, options: {}, callback: WatchCallback, callbackUndelayed: (file: string, time: number) => void): WebpackWatcher;
40
- }
41
19
  export declare class BuilderWatchPlugin {
42
20
  private readonly watcherFactory;
43
21
  constructor(watcherFactory: BuilderWatcherFactory);
44
- apply(compiler: Compiler & {
45
- watchFileSystem: unknown;
46
- }): void;
22
+ apply(compiler: Compiler): void;
47
23
  }
48
- export {};
@@ -7,6 +7,7 @@
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
+ // eslint-disable-next-line import/no-extraneous-dependencies
10
11
  const core_1 = require("@angular/core");
11
12
  const operators_1 = require("rxjs/operators");
12
13
  function default_1(mod) {
@@ -0,0 +1,59 @@
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 { ScriptTarget } from 'typescript';
9
+ import type { Compiler } from 'webpack';
10
+ /**
11
+ * The options used to configure the {@link JavaScriptOptimizerPlugin}.
12
+ */
13
+ export interface JavaScriptOptimizerOptions {
14
+ /**
15
+ * Enables advanced optimizations in the underlying JavaScript optimizers.
16
+ * This currently increases the `terser` passes to 3 and enables the `pure_getters`
17
+ * option for `terser`.
18
+ */
19
+ advanced: boolean;
20
+ /**
21
+ * An object record of string keys that will be replaced with their respective values when found
22
+ * within the code during optimization.
23
+ */
24
+ define: Record<string, string | number | boolean>;
25
+ /**
26
+ * Enables the generation of a sourcemap during optimization.
27
+ * The output sourcemap will be a full sourcemap containing the merge of the input sourcemap and
28
+ * all intermediate sourcemaps.
29
+ */
30
+ sourcemap: boolean;
31
+ /**
32
+ * The ECMAScript version that should be used when generating output code.
33
+ * The optimizer will not adjust the output code with features present in newer
34
+ * ECMAScript versions.
35
+ */
36
+ target: ScriptTarget;
37
+ /**
38
+ * Enables the retention of identifier names and ensures that function and class names are
39
+ * present in the output code.
40
+ */
41
+ keepNames: boolean;
42
+ /**
43
+ * Enables the removal of all license comments from the output code.
44
+ */
45
+ removeLicenses: boolean;
46
+ }
47
+ /**
48
+ * A Webpack plugin that provides JavaScript optimization capabilities.
49
+ *
50
+ * The plugin uses both `esbuild` and `terser` to provide both fast and highly-optimized
51
+ * code output. `esbuild` is used as an initial pass to remove the majority of unused code
52
+ * as well as shorten identifiers. `terser` is then used as a secondary pass to apply
53
+ * optimizations not yet implemented by `esbuild`.
54
+ */
55
+ export declare class JavaScriptOptimizerPlugin {
56
+ options: Partial<JavaScriptOptimizerOptions>;
57
+ constructor(options?: Partial<JavaScriptOptimizerOptions>);
58
+ apply(compiler: Compiler): void;
59
+ }