@angular-devkit/build-angular 0.1101.4 → 0.1102.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 (37) hide show
  1. package/package.json +30 -21
  2. package/plugins/karma.js +1 -1
  3. package/src/app-shell/index.js +1 -3
  4. package/src/babel/presets/application.js +0 -1
  5. package/src/babel/webpack-loader.js +19 -4
  6. package/src/browser/index.js +39 -37
  7. package/src/dev-server/index.js +6 -9
  8. package/src/extract-i18n/index.js +3 -0
  9. package/src/tslint/index.js +1 -1
  10. package/src/utils/find-up.d.ts +0 -1
  11. package/src/utils/find-up.js +1 -25
  12. package/src/utils/normalize-asset-patterns.d.ts +2 -2
  13. package/src/utils/normalize-asset-patterns.js +3 -2
  14. package/src/utils/normalize-builder-schema.d.ts +2 -2
  15. package/src/utils/normalize-builder-schema.js +3 -5
  16. package/src/utils/normalize-file-replacements.d.ts +2 -2
  17. package/src/utils/normalize-file-replacements.js +4 -3
  18. package/src/utils/package-chunk-sort.js +2 -2
  19. package/src/utils/service-worker.d.ts +2 -2
  20. package/src/utils/service-worker.js +3 -1
  21. package/src/utils/webpack-browser-config.d.ts +3 -5
  22. package/src/utils/webpack-browser-config.js +4 -6
  23. package/src/webpack/configs/common.js +1 -13
  24. package/src/webpack/configs/index.d.ts +1 -1
  25. package/src/webpack/configs/index.js +1 -1
  26. package/src/webpack/configs/styles.js +31 -0
  27. package/src/webpack/configs/typescript.js +2 -0
  28. package/src/webpack/plugins/index.d.ts +0 -1
  29. package/src/webpack/plugins/index.js +1 -3
  30. package/src/webpack/plugins/{karma-context.html → karma/karma-context.html} +0 -0
  31. package/src/webpack/plugins/{karma-debug.html → karma/karma-debug.html} +0 -0
  32. package/src/webpack/plugins/{karma-webpack-failure-cb.d.ts → karma/karma-webpack-failure-cb.d.ts} +0 -0
  33. package/src/webpack/plugins/{karma-webpack-failure-cb.js → karma/karma-webpack-failure-cb.js} +0 -0
  34. package/src/webpack/plugins/{karma.d.ts → karma/karma.d.ts} +0 -0
  35. package/src/webpack/plugins/{karma.js → karma/karma.js} +37 -34
  36. package/src/webpack/plugins/bundle-budget.d.ts +0 -19
  37. package/src/webpack/plugins/bundle-budget.js +0 -36
package/package.json CHANGED
@@ -1,33 +1,34 @@
1
1
  {
2
2
  "name": "@angular-devkit/build-angular",
3
- "version": "0.1101.4",
3
+ "version": "0.1102.0",
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.4",
11
- "@angular-devkit/build-optimizer": "0.1101.4",
12
- "@angular-devkit/build-webpack": "0.1101.4",
13
- "@angular-devkit/core": "11.1.4",
10
+ "@angular-devkit/architect": "0.1102.0",
11
+ "@angular-devkit/build-optimizer": "0.1102.0",
12
+ "@angular-devkit/build-webpack": "0.1102.0",
13
+ "@angular-devkit/core": "11.2.0",
14
14
  "@babel/core": "7.12.10",
15
15
  "@babel/generator": "7.12.11",
16
+ "@babel/plugin-transform-async-to-generator": "7.12.1",
16
17
  "@babel/plugin-transform-runtime": "7.12.10",
17
18
  "@babel/preset-env": "7.12.11",
18
19
  "@babel/runtime": "7.12.5",
19
20
  "@babel/template": "7.12.7",
20
21
  "@jsdevtools/coverage-istanbul-loader": "3.0.5",
21
- "@ngtools/webpack": "11.1.4",
22
+ "@ngtools/webpack": "11.2.0",
22
23
  "ansi-colors": "4.1.1",
23
- "autoprefixer": "10.2.1",
24
+ "autoprefixer": "10.2.4",
24
25
  "babel-loader": "8.2.2",
25
26
  "browserslist": "^4.9.1",
26
27
  "cacache": "15.0.5",
27
28
  "caniuse-lite": "^1.0.30001032",
28
29
  "circular-dependency-plugin": "5.2.2",
29
30
  "copy-webpack-plugin": "6.3.2",
30
- "core-js": "3.8.2",
31
+ "core-js": "3.8.3",
31
32
  "critters": "0.0.6",
32
33
  "css-loader": "5.0.1",
33
34
  "cssnano": "4.1.10",
@@ -38,14 +39,14 @@
38
39
  "inquirer": "7.3.3",
39
40
  "jest-worker": "26.6.2",
40
41
  "karma-source-map-support": "1.4.0",
41
- "less": "4.1.0",
42
+ "less": "4.1.1",
42
43
  "less-loader": "7.3.0",
43
44
  "license-webpack-plugin": "2.3.11",
44
45
  "loader-utils": "2.0.0",
45
- "mini-css-extract-plugin": "1.3.3",
46
+ "mini-css-extract-plugin": "1.3.5",
46
47
  "minimatch": "3.0.4",
47
- "open": "7.3.1",
48
- "ora": "5.2.0",
48
+ "open": "7.4.0",
49
+ "ora": "5.3.0",
49
50
  "parse5-html-rewriting-stream": "6.0.1",
50
51
  "pnp-webpack-plugin": "1.6.4",
51
52
  "postcss": "8.2.4",
@@ -55,36 +56,38 @@
55
56
  "regenerator-runtime": "0.13.7",
56
57
  "resolve-url-loader": "3.1.2",
57
58
  "rimraf": "3.0.2",
58
- "rollup": "2.36.1",
59
+ "rollup": "2.38.4",
59
60
  "rxjs": "6.6.3",
60
- "sass": "1.32.4",
61
+ "sass": "1.32.6",
61
62
  "sass-loader": "10.1.1",
62
63
  "semver": "7.3.4",
63
64
  "source-map": "0.7.3",
64
65
  "source-map-loader": "1.1.3",
65
66
  "source-map-support": "0.5.19",
66
- "speed-measure-webpack-plugin": "1.3.3",
67
+ "speed-measure-webpack-plugin": "1.4.2",
67
68
  "style-loader": "2.0.0",
68
69
  "stylus": "0.54.8",
69
- "stylus-loader": "4.3.2",
70
+ "stylus-loader": "4.3.3",
70
71
  "terser": "5.5.1",
71
72
  "terser-webpack-plugin": "4.2.3",
72
73
  "text-table": "0.2.0",
73
74
  "tree-kill": "1.2.2",
74
75
  "webpack": "4.44.2",
75
76
  "webpack-dev-middleware": "3.7.2",
76
- "webpack-dev-server": "3.11.1",
77
+ "webpack-dev-server": "3.11.2",
77
78
  "webpack-merge": "5.7.3",
78
79
  "webpack-sources": "2.2.0",
79
80
  "webpack-subresource-integrity": "1.5.2",
80
81
  "worker-plugin": "5.0.0"
81
82
  },
82
83
  "peerDependencies": {
83
- "@angular/compiler-cli": "^11.0.0",
84
- "@angular/localize": "^11.0.0",
85
- "karma": "^5.2.0",
86
- "ng-packagr": "^11.0.0",
84
+ "@angular/compiler-cli": "^11.0.0 || ^11.2.0-next",
85
+ "@angular/localize": "^11.0.0 || ^11.2.0-next",
86
+ "@angular/service-worker": "^11.0.0 || ^11.2.0-next",
87
+ "karma": "^5.2.0 || ^6.0.0",
88
+ "ng-packagr": "^11.0.0 || ^11.2.0-next",
87
89
  "protractor": "^7.0.0",
90
+ "tailwindcss": "^2.0.0",
88
91
  "tslint": "^6.1.0",
89
92
  "typescript": "~4.0.0 || ~4.1.0"
90
93
  },
@@ -92,6 +95,9 @@
92
95
  "@angular/localize": {
93
96
  "optional": true
94
97
  },
98
+ "@angular/service-worker": {
99
+ "optional": true
100
+ },
95
101
  "karma": {
96
102
  "optional": true
97
103
  },
@@ -101,6 +107,9 @@
101
107
  "protractor": {
102
108
  "optional": true
103
109
  },
110
+ "tailwindcss": {
111
+ "optional": true
112
+ },
104
113
  "tslint": {
105
114
  "optional": true
106
115
  }
package/plugins/karma.js CHANGED
@@ -6,4 +6,4 @@
6
6
  * Use of this source code is governed by an MIT-style license that can be
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
- module.exports = require('../src/webpack/plugins/karma');
9
+ module.exports = require('../src/webpack/plugins/karma/karma');
@@ -9,7 +9,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  */
10
10
  const architect_1 = require("@angular-devkit/architect");
11
11
  const core_1 = require("@angular-devkit/core");
12
- const node_1 = require("@angular-devkit/core/node");
13
12
  const fs = require("fs");
14
13
  const path = require("path");
15
14
  const utils_1 = require("../utils");
@@ -27,7 +26,6 @@ async function _renderUniversal(options, context, browserResult, serverResult, s
27
26
  const root = context.workspaceRoot;
28
27
  const zonePackage = require.resolve('zone.js', { paths: [root] });
29
28
  await Promise.resolve().then(() => require(zonePackage));
30
- const host = new node_1.NodeJsSyncHost();
31
29
  const projectName = context.target && context.target.project;
32
30
  if (!projectName) {
33
31
  throw new Error('The builder requires a target.');
@@ -82,7 +80,7 @@ async function _renderUniversal(options, context, browserResult, serverResult, s
82
80
  }
83
81
  await fs_1.writeFile(outputIndexPath, html);
84
82
  if (browserOptions.serviceWorker) {
85
- await service_worker_1.augmentAppWithServiceWorker(host, core_1.normalize(root), projectRoot, core_1.normalize(outputPath), browserOptions.baseHref || '/', browserOptions.ngswConfigPath);
83
+ await service_worker_1.augmentAppWithServiceWorker(core_1.normalize(root), projectRoot, core_1.normalize(outputPath), browserOptions.baseHref || '/', browserOptions.ngswConfigPath);
86
84
  }
87
85
  }
88
86
  return browserResult;
@@ -111,7 +111,6 @@ function default_1(api, options) {
111
111
  }
112
112
  if (options.forceAsyncTransformation) {
113
113
  // Always transform async/await to support Zone.js
114
- // tslint:disable-next-line: no-implicit-dependencies
115
114
  plugins.push(require('@babel/plugin-transform-async-to-generator').default);
116
115
  needRuntimeTransform = true;
117
116
  }
@@ -19,7 +19,8 @@ const typescript_1 = require("typescript");
19
19
  let needsLinking;
20
20
  async function checkLinking(path, source) {
21
21
  // @angular/core and @angular/compiler will cause false positives
22
- if (/[\\\/]@angular[\\\/](?:compiler|core)/.test(path)) {
22
+ // Also, TypeScript files do not require linking
23
+ if (/[\\\/]@angular[\\\/](?:compiler|core)|\.tsx?$/.test(path)) {
23
24
  return { requiresLinking: false };
24
25
  }
25
26
  if (needsLinking !== null) {
@@ -66,22 +67,35 @@ exports.default = babel_loader_1.custom(() => {
66
67
  shouldProcess || (shouldProcess = shouldLink);
67
68
  // Analyze for ES target processing
68
69
  let forceES5 = false;
70
+ let forceAsyncTransformation = false;
69
71
  const esTarget = scriptTarget;
70
72
  if (esTarget < typescript_1.ScriptTarget.ES2015) {
71
- forceES5 = true;
73
+ // TypeScript files will have already been downlevelled
74
+ forceES5 = !/\.tsx?$/.test(this.resourcePath);
72
75
  }
73
- shouldProcess || (shouldProcess = forceES5);
76
+ else if (esTarget >= typescript_1.ScriptTarget.ES2017) {
77
+ forceAsyncTransformation = source.includes('async');
78
+ }
79
+ shouldProcess || (shouldProcess = forceAsyncTransformation || forceES5);
74
80
  // Add provided loader options to default base options
75
81
  const options = {
76
82
  ...baseOptions,
77
83
  ...loaderOptions,
84
+ cacheIdentifier: JSON.stringify({
85
+ buildAngular: require('../../package.json').version,
86
+ forceAsyncTransformation,
87
+ forceES5,
88
+ shouldLink,
89
+ baseOptions,
90
+ loaderOptions,
91
+ }),
78
92
  };
79
93
  // Skip babel processing if no actions are needed
80
94
  if (!shouldProcess) {
81
95
  // Force the current file to be ignored
82
96
  options.ignore = [() => true];
83
97
  }
84
- return { custom: { forceES5, shouldLink }, loader: options };
98
+ return { custom: { forceAsyncTransformation, forceES5, shouldLink }, loader: options };
85
99
  },
86
100
  config(configuration, { customOptions }) {
87
101
  return {
@@ -93,6 +107,7 @@ exports.default = babel_loader_1.custom(() => {
93
107
  {
94
108
  angularLinker: customOptions.shouldLink,
95
109
  forceES5: customOptions.forceES5,
110
+ forceAsyncTransformation: customOptions.forceAsyncTransformation,
96
111
  diagnosticReporter: (type, message) => {
97
112
  switch (type) {
98
113
  case 'error':
@@ -11,7 +11,6 @@ exports.buildWebpackBrowser = exports.getCompilerConfig = exports.getAnalyticsCo
11
11
  const architect_1 = require("@angular-devkit/architect");
12
12
  const build_webpack_1 = require("@angular-devkit/build-webpack");
13
13
  const core_1 = require("@angular-devkit/core");
14
- const node_1 = require("@angular-devkit/core/node");
15
14
  const fs = require("fs");
16
15
  const path = require("path");
17
16
  const rxjs_1 = require("rxjs");
@@ -37,6 +36,7 @@ const webpack_browser_config_1 = require("../utils/webpack-browser-config");
37
36
  const configs_1 = require("../webpack/configs");
38
37
  const analytics_1 = require("../webpack/plugins/analytics");
39
38
  const async_chunks_1 = require("../webpack/utils/async-chunks");
39
+ const helpers_1 = require("../webpack/utils/helpers");
40
40
  const stats_1 = require("../webpack/utils/stats");
41
41
  const cacheDownlevelPath = environment_options_1.cachingDisabled ? undefined : cache_path_1.findCachePath('angular-build-dl');
42
42
  function getAnalyticsConfig(wco, context) {
@@ -63,7 +63,7 @@ function getCompilerConfig(wco) {
63
63
  return {};
64
64
  }
65
65
  exports.getCompilerConfig = getCompilerConfig;
66
- async function initialize(options, context, host, differentialLoadingNeeded, webpackConfigurationTransform) {
66
+ async function initialize(options, context, differentialLoadingNeeded, webpackConfigurationTransform) {
67
67
  var _a, _b;
68
68
  const originalOutputPath = options.outputPath;
69
69
  // Assets are processed directly by the builder except when watching
@@ -76,10 +76,10 @@ async function initialize(options, context, host, differentialLoadingNeeded, web
76
76
  getAnalyticsConfig(wco, context),
77
77
  getCompilerConfig(wco),
78
78
  wco.buildOptions.webWorkerTsConfig ? configs_1.getWorkerConfig(wco) : {},
79
- ], host, { differentialLoadingNeeded });
79
+ ], { differentialLoadingNeeded });
80
80
  // Validate asset option values if processed directly
81
81
  if (((_a = options.assets) === null || _a === void 0 ? void 0 : _a.length) && !((_b = adjustedOptions.assets) === null || _b === void 0 ? void 0 : _b.length)) {
82
- utils_1.normalizeAssetPatterns(options.assets, new core_1.virtualFs.SyncDelegateHost(host), core_1.normalize(context.workspaceRoot), core_1.normalize(projectRoot), projectSourceRoot === undefined ? undefined : core_1.normalize(projectSourceRoot)).forEach(({ output }) => {
82
+ utils_1.normalizeAssetPatterns(options.assets, core_1.normalize(context.workspaceRoot), core_1.normalize(projectRoot), projectSourceRoot === undefined ? undefined : core_1.normalize(projectSourceRoot)).forEach(({ output }) => {
83
83
  if (output.startsWith('..')) {
84
84
  throw new Error('An asset cannot be written to a location outside of the output path.');
85
85
  }
@@ -97,7 +97,6 @@ async function initialize(options, context, host, differentialLoadingNeeded, web
97
97
  // tslint:disable-next-line: no-big-function
98
98
  function buildWebpackBrowser(options, context, transforms = {}) {
99
99
  var _a;
100
- const host = new node_1.NodeJsSyncHost();
101
100
  const root = core_1.normalize(context.workspaceRoot);
102
101
  const projectName = (_a = context.target) === null || _a === void 0 ? void 0 : _a.project;
103
102
  if (!projectName) {
@@ -132,7 +131,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
132
131
  '\nFor additional information: https://v10.angular.io/guide/deprecations#ie-9-10-and-mobile');
133
132
  }
134
133
  return {
135
- ...(await initialize(options, context, host, isDifferentialLoadingNeeded, transforms.webpackConfiguration)),
134
+ ...(await initialize(options, context, isDifferentialLoadingNeeded, transforms.webpackConfiguration)),
136
135
  buildBrowserFeatures,
137
136
  isDifferentialLoadingNeeded,
138
137
  target,
@@ -160,8 +159,8 @@ function buildWebpackBrowser(options, context, transforms = {}) {
160
159
  }
161
160
  // Fix incorrectly set `initial` value on chunks.
162
161
  const extraEntryPoints = [
163
- ...configs_1.normalizeExtraEntryPoints(options.styles || [], 'styles'),
164
- ...configs_1.normalizeExtraEntryPoints(options.scripts || [], 'scripts'),
162
+ ...helpers_1.normalizeExtraEntryPoints(options.styles || [], 'styles'),
163
+ ...helpers_1.normalizeExtraEntryPoints(options.scripts || [], 'scripts'),
165
164
  ];
166
165
  const webpackStats = {
167
166
  ...webpackRawStats,
@@ -179,12 +178,13 @@ function buildWebpackBrowser(options, context, transforms = {}) {
179
178
  return { success };
180
179
  }
181
180
  else {
181
+ const processResults = [];
182
182
  const bundleInfoStats = [];
183
183
  outputPaths = output_paths_1.ensureOutputPaths(baseOutputPath, i18n);
184
184
  let noModuleFiles;
185
185
  let moduleFiles;
186
186
  let files;
187
- const scriptsEntryPointName = configs_1.normalizeExtraEntryPoints(options.scripts || [], 'scripts').map(x => x.bundleName);
187
+ const scriptsEntryPointName = helpers_1.normalizeExtraEntryPoints(options.scripts || [], 'scripts').map(x => x.bundleName);
188
188
  if (isDifferentialLoadingNeeded && options.watch) {
189
189
  moduleFiles = emittedFiles;
190
190
  files = moduleFiles.filter(x => x.extension === '.css' || (x.name && scriptsEntryPointName.includes(x.name)));
@@ -299,7 +299,6 @@ function buildWebpackBrowser(options, context, transforms = {}) {
299
299
  }
300
300
  const processActions = [];
301
301
  let processRuntimeAction;
302
- const processResults = [];
303
302
  for (const action of actions) {
304
303
  // If SRI is enabled always process the runtime bundle
305
304
  // Lazy route integrity values are stored in the runtime bundle
@@ -429,8 +428,22 @@ function buildWebpackBrowser(options, context, transforms = {}) {
429
428
  const asset = (_c = webpackStats.assets) === null || _c === void 0 ? void 0 : _c.find(a => a.name === chunk.files[0]);
430
429
  bundleInfoStats.push(stats_1.generateBundleStats({ ...chunk, size: asset === null || asset === void 0 ? void 0 : asset.size }));
431
430
  }
432
- // Check for budget errors and display them to the user.
433
- const budgets = options.budgets || [];
431
+ }
432
+ else {
433
+ files = emittedFiles.filter(x => x.name !== 'polyfills-es5');
434
+ noModuleFiles = emittedFiles.filter(x => x.name === 'polyfills-es5');
435
+ if (i18n.shouldInline) {
436
+ const success = await i18n_inlining_1.i18nInlineEmittedFiles(context, emittedFiles, i18n, baseOutputPath, Array.from(outputPaths.values()), scriptsEntryPointName,
437
+ // tslint:disable-next-line: no-non-null-assertion
438
+ webpackStats.outputPath, target <= typescript_1.ScriptTarget.ES5, options.i18nMissingTranslation);
439
+ if (!success) {
440
+ return { success: false };
441
+ }
442
+ }
443
+ }
444
+ // Check for budget errors and display them to the user.
445
+ const budgets = options.budgets;
446
+ if (budgets === null || budgets === void 0 ? void 0 : budgets.length) {
434
447
  const budgetFailures = bundle_calculator_1.checkBudgets(budgets, webpackStats, processResults);
435
448
  for (const { severity, message } of budgetFailures) {
436
449
  switch (severity) {
@@ -445,31 +458,20 @@ function buildWebpackBrowser(options, context, transforms = {}) {
445
458
  }
446
459
  }
447
460
  }
448
- else {
449
- files = emittedFiles.filter(x => x.name !== 'polyfills-es5');
450
- noModuleFiles = emittedFiles.filter(x => x.name === 'polyfills-es5');
451
- if (i18n.shouldInline) {
452
- const success = await i18n_inlining_1.i18nInlineEmittedFiles(context, emittedFiles, i18n, baseOutputPath, Array.from(outputPaths.values()), scriptsEntryPointName,
453
- // tslint:disable-next-line: no-non-null-assertion
454
- webpackStats.outputPath, target <= typescript_1.ScriptTarget.ES5, options.i18nMissingTranslation);
455
- if (!success) {
456
- return { success: false };
461
+ const buildSuccess = success && !stats_1.statsHasErrors(webpackStats);
462
+ if (buildSuccess) {
463
+ // Copy assets
464
+ if (!options.watch && ((_d = options.assets) === null || _d === void 0 ? void 0 : _d.length)) {
465
+ spinner.start('Copying assets...');
466
+ try {
467
+ await copy_assets_1.copyAssets(utils_1.normalizeAssetPatterns(options.assets, root, core_1.normalize(projectRoot), projectSourceRoot === undefined ? undefined : core_1.normalize(projectSourceRoot)), Array.from(outputPaths.values()), context.workspaceRoot);
468
+ spinner.succeed('Copying assets complete.');
469
+ }
470
+ catch (err) {
471
+ spinner.fail(color_1.colors.redBright('Copying of assets failed.'));
472
+ return { success: false, error: 'Unable to copy assets: ' + err.message };
457
473
  }
458
474
  }
459
- }
460
- // Copy assets
461
- if (!options.watch && ((_d = options.assets) === null || _d === void 0 ? void 0 : _d.length)) {
462
- spinner.start('Copying assets...');
463
- try {
464
- await copy_assets_1.copyAssets(utils_1.normalizeAssetPatterns(options.assets, new core_1.virtualFs.SyncDelegateHost(host), root, core_1.normalize(projectRoot), projectSourceRoot === undefined ? undefined : core_1.normalize(projectSourceRoot)), Array.from(outputPaths.values()), context.workspaceRoot);
465
- spinner.succeed('Copying assets complete.');
466
- }
467
- catch (err) {
468
- spinner.fail(color_1.colors.redBright('Copying of assets failed.'));
469
- return { success: false, error: 'Unable to copy assets: ' + err.message };
470
- }
471
- }
472
- if (success) {
473
475
  if (options.index) {
474
476
  spinner.start('Generating index html...');
475
477
  const WOFFSupportNeeded = !buildBrowserFeatures.isFeatureSupported('woff2');
@@ -519,7 +521,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
519
521
  spinner.start('Generating service worker...');
520
522
  for (const [locale, outputPath] of outputPaths.entries()) {
521
523
  try {
522
- await service_worker_1.augmentAppWithServiceWorker(host, root, core_1.normalize(projectRoot), core_1.normalize(outputPath), getLocaleBaseHref(i18n, locale) || options.baseHref || '/', options.ngswConfigPath);
524
+ await service_worker_1.augmentAppWithServiceWorker(root, core_1.normalize(projectRoot), core_1.normalize(outputPath), getLocaleBaseHref(i18n, locale) || options.baseHref || '/', options.ngswConfigPath);
523
525
  }
524
526
  catch (error) {
525
527
  spinner.fail('Service worker generation failed.');
@@ -530,7 +532,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
530
532
  }
531
533
  }
532
534
  stats_1.webpackStatsLogger(context.logger, webpackStats, config, bundleInfoStats);
533
- return { success: !stats_1.statsHasErrors(webpackStats) };
535
+ return { success: buildSuccess };
534
536
  }
535
537
  }), operators_1.map(event => ({
536
538
  ...event,
@@ -11,7 +11,6 @@ exports.serveWebpackBrowser = void 0;
11
11
  const architect_1 = require("@angular-devkit/architect");
12
12
  const build_webpack_1 = require("@angular-devkit/build-webpack");
13
13
  const core_1 = require("@angular-devkit/core");
14
- const node_1 = require("@angular-devkit/core/node");
15
14
  const path = require("path");
16
15
  const rxjs_1 = require("rxjs");
17
16
  const operators_1 = require("rxjs/operators");
@@ -30,7 +29,6 @@ const version_1 = require("../utils/version");
30
29
  const webpack_browser_config_1 = require("../utils/webpack-browser-config");
31
30
  const webpack_diagnostics_1 = require("../utils/webpack-diagnostics");
32
31
  const configs_1 = require("../webpack/configs");
33
- const dev_server_1 = require("../webpack/configs/dev-server");
34
32
  const index_html_webpack_plugin_1 = require("../webpack/plugins/index-html-webpack-plugin");
35
33
  const stats_1 = require("../webpack/utils/stats");
36
34
  const devServerBuildOverriddenKeys = [
@@ -59,7 +57,6 @@ function serveWebpackBrowser(options, context, transforms = {}) {
59
57
  const { logger, workspaceRoot } = context;
60
58
  version_1.assertCompatibleAngularVersion(workspaceRoot, logger);
61
59
  const browserTarget = architect_1.targetFromTargetString(options.browserTarget);
62
- const host = new node_1.NodeJsSyncHost();
63
60
  async function setup() {
64
61
  var _a;
65
62
  // Get the browser configuration from the target name.
@@ -89,7 +86,7 @@ function serveWebpackBrowser(options, context, transforms = {}) {
89
86
  const browserName = await context.getBuilderNameForTarget(browserTarget);
90
87
  const browserOptions = await context.validateOptions({ ...rawBrowserOptions, ...overrides }, browserName);
91
88
  const { config, projectRoot, i18n } = await webpack_browser_config_1.generateI18nBrowserWebpackConfigFromContext(browserOptions, context, wco => [
92
- dev_server_1.getDevServerConfig(wco),
89
+ configs_1.getDevServerConfig(wco),
93
90
  configs_1.getCommonConfig(wco),
94
91
  configs_1.getBrowserConfig(wco),
95
92
  configs_1.getStylesConfig(wco),
@@ -97,7 +94,7 @@ function serveWebpackBrowser(options, context, transforms = {}) {
97
94
  browser_1.getAnalyticsConfig(wco, context),
98
95
  browser_1.getCompilerConfig(wco),
99
96
  browserOptions.webWorkerTsConfig ? configs_1.getWorkerConfig(wco) : {},
100
- ], host, devServerOptions);
97
+ ], devServerOptions);
101
98
  if (!config.devServer) {
102
99
  throw new Error('Webpack Dev Server configuration was not set.');
103
100
  }
@@ -226,7 +223,7 @@ function serveWebpackBrowser(options, context, transforms = {}) {
226
223
  logging: transforms.logging || stats_1.createWebpackLoggingCallback(!!options.verbose, logger),
227
224
  webpackFactory: require('webpack'),
228
225
  webpackDevServerFactory: require('webpack-dev-server'),
229
- }).pipe(operators_1.concatMap((buildEvent, index) => {
226
+ }).pipe(operators_1.concatMap(async (buildEvent, index) => {
230
227
  var _a;
231
228
  // Resolve serve address.
232
229
  const serverAddress = url.format({
@@ -243,14 +240,14 @@ function serveWebpackBrowser(options, context, transforms = {}) {
243
240
  **
244
241
  ` + '\n');
245
242
  if (options.open) {
246
- const open = require('open');
247
- open(serverAddress);
243
+ const open = await Promise.resolve().then(() => require('open'));
244
+ await open(serverAddress);
248
245
  }
249
246
  }
250
247
  if (buildEvent.success) {
251
248
  logger.info(`\n${color_1.colors.greenBright(color_1.colors.symbols.check)} Compiled successfully.`);
252
249
  }
253
- return rxjs_1.of({ ...buildEvent, baseUrl: serverAddress });
250
+ return { ...buildEvent, baseUrl: serverAddress };
254
251
  }));
255
252
  }));
256
253
  }
@@ -144,6 +144,8 @@ async function execute(options, context, transforms) {
144
144
  scripts: [],
145
145
  styles: [],
146
146
  deleteOutputPath: false,
147
+ extractLicenses: false,
148
+ subresourceIntegrity: false,
147
149
  }, context, (wco) => {
148
150
  var _a;
149
151
  const isIvyApplication = wco.tsConfig.options.enableIvy !== false;
@@ -163,6 +165,7 @@ async function execute(options, context, transforms) {
163
165
  const partials = [
164
166
  { plugins: [new NoEmitPlugin()] },
165
167
  configs_1.getCommonConfig(wco),
168
+ configs_1.getBrowserConfig(wco),
166
169
  // Only use VE extraction if not using Ivy
167
170
  configs_1.getAotConfig(wco, !usingIvy),
168
171
  configs_1.getStatsConfig(wco),
@@ -15,7 +15,7 @@ const path = require("path");
15
15
  const strip_bom_1 = require("../utils/strip-bom");
16
16
  async function _run(options, context) {
17
17
  context.logger.warn(`TSLint's support is discontinued and we're deprecating its support in Angular CLI.\n` +
18
- 'To opt-in using the community driven ESLint builder, see: https://github.com/angular-eslint/angular-eslint#migrating-from-codelyzer-and-tslint.');
18
+ 'To opt-in using the community driven ESLint builder, see: https://github.com/angular-eslint/angular-eslint#migrating-an-angular-cli-project-from-codelyzer-and-tslint.');
19
19
  const systemRoot = context.workspaceRoot;
20
20
  process.chdir(context.currentDirectory);
21
21
  const projectName = (context.target && context.target.project) || '<???>';
@@ -1,2 +1 @@
1
- export declare function findUp(names: string | string[], from: string, stopOnNodeModules?: boolean): string | null;
2
1
  export declare function findAllNodeModules(from: string, root?: string): string[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.findAllNodeModules = exports.findUp = void 0;
3
+ exports.findAllNodeModules = void 0;
4
4
  /**
5
5
  * @license
6
6
  * Copyright Google Inc. All Rights Reserved.
@@ -11,30 +11,6 @@ exports.findAllNodeModules = exports.findUp = void 0;
11
11
  const fs_1 = require("fs");
12
12
  const path = require("path");
13
13
  const is_directory_1 = require("./is-directory");
14
- function findUp(names, from, stopOnNodeModules = false) {
15
- if (!Array.isArray(names)) {
16
- names = [names];
17
- }
18
- const root = path.parse(from).root;
19
- let currentDir = from;
20
- while (currentDir && currentDir !== root) {
21
- for (const name of names) {
22
- const p = path.join(currentDir, name);
23
- if (fs_1.existsSync(p)) {
24
- return p;
25
- }
26
- }
27
- if (stopOnNodeModules) {
28
- const nodeModuleP = path.join(currentDir, 'node_modules');
29
- if (fs_1.existsSync(nodeModuleP)) {
30
- return null;
31
- }
32
- }
33
- currentDir = path.dirname(currentDir);
34
- }
35
- return null;
36
- }
37
- exports.findUp = findUp;
38
14
  function findAllNodeModules(from, root) {
39
15
  const nodeModules = [];
40
16
  let current = from;
@@ -5,9 +5,9 @@
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 { BaseException, Path, virtualFs } from '@angular-devkit/core';
8
+ import { BaseException, Path } from '@angular-devkit/core';
9
9
  import { AssetPattern, AssetPatternClass } from '../browser/schema';
10
10
  export declare class MissingAssetSourceRootException extends BaseException {
11
11
  constructor(path: String);
12
12
  }
13
- export declare function normalizeAssetPatterns(assetPatterns: AssetPattern[], host: virtualFs.SyncDelegateHost, root: Path, projectRoot: Path, maybeSourceRoot: Path | undefined): AssetPatternClass[];
13
+ export declare function normalizeAssetPatterns(assetPatterns: AssetPattern[], root: Path, projectRoot: Path, maybeSourceRoot: Path | undefined): AssetPatternClass[];
@@ -9,13 +9,14 @@ exports.normalizeAssetPatterns = exports.MissingAssetSourceRootException = void
9
9
  * found in the LICENSE file at https://angular.io/license
10
10
  */
11
11
  const core_1 = require("@angular-devkit/core");
12
+ const fs_1 = require("fs");
12
13
  class MissingAssetSourceRootException extends core_1.BaseException {
13
14
  constructor(path) {
14
15
  super(`The ${path} asset path must start with the project source root.`);
15
16
  }
16
17
  }
17
18
  exports.MissingAssetSourceRootException = MissingAssetSourceRootException;
18
- function normalizeAssetPatterns(assetPatterns, host, root, projectRoot, maybeSourceRoot) {
19
+ function normalizeAssetPatterns(assetPatterns, root, projectRoot, maybeSourceRoot) {
19
20
  // When sourceRoot is not available, we default to ${projectRoot}/src.
20
21
  const sourceRoot = maybeSourceRoot || core_1.join(projectRoot, 'src');
21
22
  const resolvedSourceRoot = core_1.resolve(root, sourceRoot);
@@ -35,7 +36,7 @@ function normalizeAssetPatterns(assetPatterns, host, root, projectRoot, maybeSou
35
36
  let glob, input, output;
36
37
  let isDirectory = false;
37
38
  try {
38
- isDirectory = host.isDirectory(resolvedAssetPath);
39
+ isDirectory = fs_1.statSync(core_1.getSystemPath(resolvedAssetPath)).isDirectory();
39
40
  }
40
41
  catch (_a) {
41
42
  isDirectory = true;
@@ -5,7 +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 { Path, virtualFs } from '@angular-devkit/core';
8
+ import { Path } from '@angular-devkit/core';
9
9
  import { AssetPatternClass, Schema as BrowserBuilderSchema, SourceMapClass } from '../browser/schema';
10
10
  import { BuildOptions } from './build-options';
11
11
  import { NormalizedFileReplacement } from './normalize-file-replacements';
@@ -19,4 +19,4 @@ export declare type NormalizedBrowserBuilderSchema = BrowserBuilderSchema & Buil
19
19
  fileReplacements: NormalizedFileReplacement[];
20
20
  optimization: NormalizedOptimizationOptions;
21
21
  };
22
- export declare function normalizeBrowserSchema(host: virtualFs.Host<{}>, root: Path, projectRoot: Path, sourceRoot: Path | undefined, options: BrowserBuilderSchema): NormalizedBrowserBuilderSchema;
22
+ export declare function normalizeBrowserSchema(root: Path, projectRoot: Path, sourceRoot: Path | undefined, options: BrowserBuilderSchema): NormalizedBrowserBuilderSchema;
@@ -8,18 +8,16 @@
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.normalizeBrowserSchema = void 0;
11
- const core_1 = require("@angular-devkit/core");
12
11
  const normalize_asset_patterns_1 = require("./normalize-asset-patterns");
13
12
  const normalize_file_replacements_1 = require("./normalize-file-replacements");
14
13
  const normalize_optimization_1 = require("./normalize-optimization");
15
14
  const normalize_source_maps_1 = require("./normalize-source-maps");
16
- function normalizeBrowserSchema(host, root, projectRoot, sourceRoot, options) {
17
- const syncHost = new core_1.virtualFs.SyncDelegateHost(host);
15
+ function normalizeBrowserSchema(root, projectRoot, sourceRoot, options) {
18
16
  const normalizedSourceMapOptions = normalize_source_maps_1.normalizeSourceMaps(options.sourceMap || false);
19
17
  return {
20
18
  ...options,
21
- assets: normalize_asset_patterns_1.normalizeAssetPatterns(options.assets || [], syncHost, root, projectRoot, sourceRoot),
22
- fileReplacements: normalize_file_replacements_1.normalizeFileReplacements(options.fileReplacements || [], syncHost, root),
19
+ assets: normalize_asset_patterns_1.normalizeAssetPatterns(options.assets || [], root, projectRoot, sourceRoot),
20
+ fileReplacements: normalize_file_replacements_1.normalizeFileReplacements(options.fileReplacements || [], root),
23
21
  optimization: normalize_optimization_1.normalizeOptimization(options.optimization),
24
22
  sourceMap: normalizedSourceMapOptions,
25
23
  preserveSymlinks: options.preserveSymlinks === undefined ? process.execArgv.includes('--preserve-symlinks') : options.preserveSymlinks,
@@ -5,7 +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 { BaseException, Path, virtualFs } from '@angular-devkit/core';
8
+ import { BaseException, Path } from '@angular-devkit/core';
9
9
  import { FileReplacement } from '../browser/schema';
10
10
  export declare class MissingFileReplacementException extends BaseException {
11
11
  constructor(path: String);
@@ -14,4 +14,4 @@ export interface NormalizedFileReplacement {
14
14
  replace: Path;
15
15
  with: Path;
16
16
  }
17
- export declare function normalizeFileReplacements(fileReplacements: FileReplacement[], host: virtualFs.SyncDelegateHost, root: Path): NormalizedFileReplacement[];
17
+ export declare function normalizeFileReplacements(fileReplacements: FileReplacement[], root: Path): NormalizedFileReplacement[];
@@ -9,23 +9,24 @@
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.normalizeFileReplacements = exports.MissingFileReplacementException = void 0;
11
11
  const core_1 = require("@angular-devkit/core");
12
+ const fs_1 = require("fs");
12
13
  class MissingFileReplacementException extends core_1.BaseException {
13
14
  constructor(path) {
14
15
  super(`The ${path} path in file replacements does not exist.`);
15
16
  }
16
17
  }
17
18
  exports.MissingFileReplacementException = MissingFileReplacementException;
18
- function normalizeFileReplacements(fileReplacements, host, root) {
19
+ function normalizeFileReplacements(fileReplacements, root) {
19
20
  if (fileReplacements.length === 0) {
20
21
  return [];
21
22
  }
22
23
  const normalizedReplacement = fileReplacements
23
24
  .map(replacement => normalizeFileReplacement(replacement, root));
24
25
  for (const { replace, with: replacementWith } of normalizedReplacement) {
25
- if (!host.exists(replacementWith)) {
26
+ if (!fs_1.existsSync(core_1.getSystemPath(replacementWith))) {
26
27
  throw new MissingFileReplacementException(core_1.getSystemPath(replacementWith));
27
28
  }
28
- if (!host.exists(replace)) {
29
+ if (!fs_1.existsSync(core_1.getSystemPath(replace))) {
29
30
  throw new MissingFileReplacementException(core_1.getSystemPath(replace));
30
31
  }
31
32
  }
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateEntryPoints = void 0;
4
- const configs_1 = require("../webpack/configs");
4
+ const helpers_1 = require("../webpack/utils/helpers");
5
5
  function generateEntryPoints(appConfig) {
6
6
  // Add all styles/scripts, except lazy-loaded ones.
7
7
  const extraEntryPoints = (extraEntryPoints, defaultBundleName) => {
8
- const entryPoints = configs_1.normalizeExtraEntryPoints(extraEntryPoints, defaultBundleName)
8
+ const entryPoints = helpers_1.normalizeExtraEntryPoints(extraEntryPoints, defaultBundleName)
9
9
  .filter(entry => entry.inject)
10
10
  .map(entry => entry.bundleName);
11
11
  // remove duplicates
@@ -5,5 +5,5 @@
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 { Path, virtualFs } from '@angular-devkit/core';
9
- export declare function augmentAppWithServiceWorker(host: virtualFs.Host, projectRoot: Path, appRoot: Path, outputPath: Path, baseHref: string, ngswConfigPath?: string): Promise<void>;
8
+ import { Path } from '@angular-devkit/core';
9
+ export declare function augmentAppWithServiceWorker(projectRoot: Path, appRoot: Path, outputPath: Path, baseHref: string, ngswConfigPath?: string): Promise<void>;
@@ -9,6 +9,7 @@ exports.augmentAppWithServiceWorker = void 0;
9
9
  * found in the LICENSE file at https://angular.io/license
10
10
  */
11
11
  const core_1 = require("@angular-devkit/core");
12
+ const node_1 = require("@angular-devkit/core/node");
12
13
  const crypto = require("crypto");
13
14
  class CliFilesystem {
14
15
  constructor(_host, base) {
@@ -50,7 +51,8 @@ class CliFilesystem {
50
51
  return items;
51
52
  }
52
53
  }
53
- async function augmentAppWithServiceWorker(host, projectRoot, appRoot, outputPath, baseHref, ngswConfigPath) {
54
+ async function augmentAppWithServiceWorker(projectRoot, appRoot, outputPath, baseHref, ngswConfigPath) {
55
+ const host = new node_1.NodeJsSyncHost();
54
56
  const distPath = core_1.normalize(outputPath);
55
57
  const systemProjectRoot = core_1.getSystemPath(projectRoot);
56
58
  // Find the service worker package
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  /**
3
2
  * @license
4
3
  * Copyright Google Inc. All Rights Reserved.
@@ -7,8 +6,7 @@
7
6
  * found in the LICENSE file at https://angular.io/license
8
7
  */
9
8
  import { BuilderContext } from '@angular-devkit/architect';
10
- import { logging, virtualFs } from '@angular-devkit/core';
11
- import * as fs from 'fs';
9
+ import { logging } from '@angular-devkit/core';
12
10
  import * as webpack from 'webpack';
13
11
  import { Schema as BrowserBuilderSchema } from '../browser/schema';
14
12
  import { NormalizedBrowserBuilderSchema } from '../utils';
@@ -16,13 +14,13 @@ import { WebpackConfigOptions } from '../utils/build-options';
16
14
  import { I18nOptions } from './i18n-options';
17
15
  export declare type BrowserWebpackConfigOptions = WebpackConfigOptions<NormalizedBrowserBuilderSchema>;
18
16
  export declare function generateWebpackConfig(workspaceRoot: string, projectRoot: string, sourceRoot: string | undefined, options: NormalizedBrowserBuilderSchema, webpackPartialGenerator: (wco: BrowserWebpackConfigOptions) => webpack.Configuration[], logger: logging.LoggerApi, extraBuildOptions: Partial<NormalizedBrowserBuilderSchema>): Promise<webpack.Configuration>;
19
- export declare function generateI18nBrowserWebpackConfigFromContext(options: BrowserBuilderSchema, context: BuilderContext, webpackPartialGenerator: (wco: BrowserWebpackConfigOptions) => webpack.Configuration[], host?: virtualFs.Host<fs.Stats>, extraBuildOptions?: Partial<NormalizedBrowserBuilderSchema>): Promise<{
17
+ export declare function generateI18nBrowserWebpackConfigFromContext(options: BrowserBuilderSchema, context: BuilderContext, webpackPartialGenerator: (wco: BrowserWebpackConfigOptions) => webpack.Configuration[], extraBuildOptions?: Partial<NormalizedBrowserBuilderSchema>): Promise<{
20
18
  config: webpack.Configuration;
21
19
  projectRoot: string;
22
20
  projectSourceRoot?: string;
23
21
  i18n: I18nOptions;
24
22
  }>;
25
- export declare function generateBrowserWebpackConfigFromContext(options: BrowserBuilderSchema, context: BuilderContext, webpackPartialGenerator: (wco: BrowserWebpackConfigOptions) => webpack.Configuration[], host?: virtualFs.Host<fs.Stats>, extraBuildOptions?: Partial<NormalizedBrowserBuilderSchema>): Promise<{
23
+ export declare function generateBrowserWebpackConfigFromContext(options: BrowserBuilderSchema, context: BuilderContext, webpackPartialGenerator: (wco: BrowserWebpackConfigOptions) => webpack.Configuration[], extraBuildOptions?: Partial<NormalizedBrowserBuilderSchema>): Promise<{
26
24
  config: webpack.Configuration;
27
25
  projectRoot: string;
28
26
  projectSourceRoot?: string;
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getIndexInputFile = exports.getIndexOutputFile = exports.generateBrowserWebpackConfigFromContext = exports.generateI18nBrowserWebpackConfigFromContext = exports.generateWebpackConfig = void 0;
4
4
  const core_1 = require("@angular-devkit/core");
5
- const node_1 = require("@angular-devkit/core/node");
6
5
  const path = require("path");
7
6
  const webpack_merge_1 = require("webpack-merge");
8
7
  const utils_1 = require("../utils");
@@ -28,7 +27,6 @@ async function generateWebpackConfig(workspaceRoot, projectRoot, sourceRoot, opt
28
27
  }
29
28
  const tsConfigPath = path.resolve(workspaceRoot, options.tsConfig);
30
29
  const tsConfig = read_tsconfig_1.readTsconfig(tsConfigPath);
31
- // tslint:disable-next-line:no-implicit-dependencies
32
30
  const ts = await Promise.resolve().then(() => require('typescript'));
33
31
  const scriptTarget = tsConfig.options.target || ts.ScriptTarget.ES5;
34
32
  const supportES2015 = scriptTarget !== ts.ScriptTarget.JSON && scriptTarget > ts.ScriptTarget.ES5;
@@ -74,9 +72,9 @@ async function generateWebpackConfig(workspaceRoot, projectRoot, sourceRoot, opt
74
72
  return webpackConfig;
75
73
  }
76
74
  exports.generateWebpackConfig = generateWebpackConfig;
77
- async function generateI18nBrowserWebpackConfigFromContext(options, context, webpackPartialGenerator, host = new node_1.NodeJsSyncHost(), extraBuildOptions = {}) {
75
+ async function generateI18nBrowserWebpackConfigFromContext(options, context, webpackPartialGenerator, extraBuildOptions = {}) {
78
76
  const { buildOptions, i18n } = await i18n_options_1.configureI18nBuild(context, options);
79
- const result = await generateBrowserWebpackConfigFromContext(buildOptions, context, webpackPartialGenerator, host, extraBuildOptions);
77
+ const result = await generateBrowserWebpackConfigFromContext(buildOptions, context, webpackPartialGenerator, extraBuildOptions);
80
78
  const config = result.config;
81
79
  if (i18n.shouldInline) {
82
80
  // Remove localize "polyfill" if in AOT mode
@@ -122,7 +120,7 @@ async function generateI18nBrowserWebpackConfigFromContext(options, context, web
122
120
  return { ...result, i18n };
123
121
  }
124
122
  exports.generateI18nBrowserWebpackConfigFromContext = generateI18nBrowserWebpackConfigFromContext;
125
- async function generateBrowserWebpackConfigFromContext(options, context, webpackPartialGenerator, host = new node_1.NodeJsSyncHost(), extraBuildOptions = {}) {
123
+ async function generateBrowserWebpackConfigFromContext(options, context, webpackPartialGenerator, extraBuildOptions = {}) {
126
124
  const projectName = context.target && context.target.project;
127
125
  if (!projectName) {
128
126
  throw new Error('The builder requires a target.');
@@ -134,7 +132,7 @@ async function generateBrowserWebpackConfigFromContext(options, context, webpack
134
132
  const sourceRoot = projectSourceRoot
135
133
  ? core_1.resolve(workspaceRoot, core_1.normalize(projectSourceRoot))
136
134
  : undefined;
137
- const normalizedOptions = utils_1.normalizeBrowserSchema(host, workspaceRoot, projectRoot, sourceRoot, options);
135
+ const normalizedOptions = utils_1.normalizeBrowserSchema(workspaceRoot, projectRoot, sourceRoot, options);
138
136
  const config = await generateWebpackConfig(core_1.getSystemPath(workspaceRoot), core_1.getSystemPath(projectRoot), sourceRoot && core_1.getSystemPath(sourceRoot), normalizedOptions, webpackPartialGenerator, context.logger, extraBuildOptions);
139
137
  // If builder watch support is present in the context, add watch plugin
140
138
  // This is internal only and currently only used for testing
@@ -269,15 +269,6 @@ 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 (buildOptions.budgets.length && !differentialLoadingMode) {
273
- // Budgets are computed after differential builds, not via a plugin.
274
- // https://github.com/angular/angular-cli/blob/master/packages/angular_devkit/build_angular/src/browser/index.ts
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 }));
280
- }
281
272
  if ((scriptsSourceMap || stylesSourceMap)) {
282
273
  extraRules.push({
283
274
  test: /\.m?js$/,
@@ -443,16 +434,13 @@ function getCommonConfig(wco) {
443
434
  sideEffects: true,
444
435
  },
445
436
  {
446
- test: /\.[cm]?js$/,
437
+ test: /\.[cm]?js$|\.tsx?$/,
447
438
  exclude: [/[\/\\](?:core-js|\@babel|tslib|web-animations-js)[\/\\]/, /(ngfactory|ngstyle)\.js$/],
448
439
  use: [
449
440
  {
450
441
  loader: require.resolve('../../babel/webpack-loader'),
451
442
  options: {
452
443
  cacheDirectory: cache_path_1.findCachePath('babel-webpack'),
453
- cacheIdentifier: JSON.stringify({
454
- buildAngular: require('../../../package.json').version,
455
- }),
456
444
  scriptTarget: wco.scriptTarget,
457
445
  },
458
446
  },
@@ -7,10 +7,10 @@
7
7
  */
8
8
  export * from './browser';
9
9
  export * from './common';
10
+ export * from './dev-server';
10
11
  export * from './server';
11
12
  export * from './styles';
12
13
  export * from './test';
13
14
  export * from './typescript';
14
- export * from '../utils/helpers';
15
15
  export * from './stats';
16
16
  export * from './worker';
@@ -19,10 +19,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
19
19
  */
20
20
  __exportStar(require("./browser"), exports);
21
21
  __exportStar(require("./common"), exports);
22
+ __exportStar(require("./dev-server"), exports);
22
23
  __exportStar(require("./server"), exports);
23
24
  __exportStar(require("./styles"), exports);
24
25
  __exportStar(require("./test"), exports);
25
26
  __exportStar(require("./typescript"), exports);
26
- __exportStar(require("../utils/helpers"), exports);
27
27
  __exportStar(require("./stats"), exports);
28
28
  __exportStar(require("./worker"), exports);
@@ -137,6 +137,36 @@ function getStylesConfig(wco) {
137
137
  },
138
138
  ];
139
139
  const assetNameTemplate = helpers_1.assetNameTemplateFactory(hashFormat);
140
+ const extraPostcssPlugins = [];
141
+ // Attempt to setup Tailwind CSS
142
+ // A configuration file can exist in the project or workspace root
143
+ const tailwindConfigFile = 'tailwind.config.js';
144
+ let tailwindConfigPath;
145
+ for (const basePath of [wco.projectRoot, wco.root]) {
146
+ const fullPath = path.join(basePath, tailwindConfigFile);
147
+ if (fs.existsSync(fullPath)) {
148
+ tailwindConfigPath = fullPath;
149
+ break;
150
+ }
151
+ }
152
+ // Only load Tailwind CSS plugin if configuration file was found.
153
+ // This acts as a guard to ensure the project actually wants to use Tailwind CSS.
154
+ // The package may be unknowningly present due to a third-party transitive package dependency.
155
+ if (tailwindConfigPath) {
156
+ let tailwindPackagePath;
157
+ try {
158
+ tailwindPackagePath = require.resolve('tailwindcss', { paths: [wco.root] });
159
+ }
160
+ catch (_e) {
161
+ const relativeTailwindConfigPath = path.relative(wco.root, tailwindConfigPath);
162
+ wco.logger.warn(`Tailwind CSS configuration file found (${relativeTailwindConfigPath})` +
163
+ ` but the 'tailwindcss' package is not installed.` +
164
+ ` To enable Tailwind CSS, please install the 'tailwindcss' package.`);
165
+ }
166
+ if (tailwindPackagePath) {
167
+ extraPostcssPlugins.push(require(tailwindPackagePath)({ config: tailwindConfigPath }));
168
+ }
169
+ }
140
170
  const postcssOptionsCreator = (sourceMap, extracted) => {
141
171
  return (loader) => ({
142
172
  map: sourceMap && {
@@ -168,6 +198,7 @@ function getStylesConfig(wco) {
168
198
  emitFile: buildOptions.platform !== 'server',
169
199
  extracted,
170
200
  }),
201
+ ...extraPostcssPlugins,
171
202
  autoprefixer(),
172
203
  ],
173
204
  });
@@ -47,6 +47,7 @@ function createIvyPlugin(wco, aot, tsconfig) {
47
47
  fileReplacements,
48
48
  jitMode: !aot,
49
49
  emitNgModuleScope: !optimize,
50
+ suppressZoneJsIncompatibilityWarning: true,
50
51
  });
51
52
  }
52
53
  function _pluginOptionsOverrides(buildOptions, pluginOptions) {
@@ -107,6 +108,7 @@ function _createAotPlugin(wco, options, i18nExtract = false) {
107
108
  directTemplateLoading: true,
108
109
  ...options,
109
110
  compilerOptions,
111
+ suppressZoneJsIncompatibilityWarning: true,
110
112
  };
111
113
  pluginOptions = _pluginOptionsOverrides(buildOptions, pluginOptions);
112
114
  return new webpack_1.AngularCompilerPlugin(pluginOptions);
@@ -7,7 +7,6 @@
7
7
  */
8
8
  export { AnyComponentStyleBudgetChecker } from './any-component-style-budget-checker';
9
9
  export { OptimizeCssWebpackPlugin, OptimizeCssWebpackPluginOptions } from './optimize-css-webpack-plugin';
10
- export { BundleBudgetPlugin, BundleBudgetPluginOptions } from './bundle-budget';
11
10
  export { ScriptsWebpackPlugin, ScriptsWebpackPluginOptions } from './scripts-webpack-plugin';
12
11
  export { SuppressExtractedTextChunksWebpackPlugin } from './suppress-entry-chunks-webpack-plugin';
13
12
  export { RemoveHashPlugin, RemoveHashPluginOptions } from './remove-hash-plugin';
@@ -7,14 +7,12 @@
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.WebpackRollupLoader = exports.PostcssCliResources = exports.CommonJsUsageWarnPlugin = exports.DedupeModuleResolvePlugin = exports.NamedLazyChunksPlugin = exports.RemoveHashPlugin = exports.SuppressExtractedTextChunksWebpackPlugin = exports.ScriptsWebpackPlugin = exports.BundleBudgetPlugin = exports.OptimizeCssWebpackPlugin = exports.AnyComponentStyleBudgetChecker = void 0;
10
+ exports.WebpackRollupLoader = exports.PostcssCliResources = exports.CommonJsUsageWarnPlugin = exports.DedupeModuleResolvePlugin = exports.NamedLazyChunksPlugin = exports.RemoveHashPlugin = exports.SuppressExtractedTextChunksWebpackPlugin = exports.ScriptsWebpackPlugin = exports.OptimizeCssWebpackPlugin = exports.AnyComponentStyleBudgetChecker = void 0;
11
11
  // Exports the webpack plugins we use internally.
12
12
  var any_component_style_budget_checker_1 = require("./any-component-style-budget-checker");
13
13
  Object.defineProperty(exports, "AnyComponentStyleBudgetChecker", { enumerable: true, get: function () { return any_component_style_budget_checker_1.AnyComponentStyleBudgetChecker; } });
14
14
  var optimize_css_webpack_plugin_1 = require("./optimize-css-webpack-plugin");
15
15
  Object.defineProperty(exports, "OptimizeCssWebpackPlugin", { enumerable: true, get: function () { return optimize_css_webpack_plugin_1.OptimizeCssWebpackPlugin; } });
16
- var bundle_budget_1 = require("./bundle-budget");
17
- Object.defineProperty(exports, "BundleBudgetPlugin", { enumerable: true, get: function () { return bundle_budget_1.BundleBudgetPlugin; } });
18
16
  var scripts_webpack_plugin_1 = require("./scripts-webpack-plugin");
19
17
  Object.defineProperty(exports, "ScriptsWebpackPlugin", { enumerable: true, get: function () { return scripts_webpack_plugin_1.ScriptsWebpackPlugin; } });
20
18
  var suppress_entry_chunks_webpack_plugin_1 = require("./suppress-entry-chunks-webpack-plugin");
@@ -5,10 +5,10 @@ const glob = require("glob");
5
5
  const webpack = require("webpack");
6
6
  const webpackDevMiddleware = require('webpack-dev-middleware');
7
7
  const karma_webpack_failure_cb_1 = require("./karma-webpack-failure-cb");
8
- const stats_1 = require("../utils/stats");
9
- const stats_2 = require("../configs/stats");
8
+ const stats_1 = require("../../utils/stats");
9
+ const stats_2 = require("../../configs/stats");
10
10
  const node_1 = require("@angular-devkit/core/node");
11
- const index_1 = require("../../utils/index");
11
+ const index_1 = require("../../../utils/index");
12
12
  /**
13
13
  * Enumerate needed (but not require/imported) dependencies from this file
14
14
  * to let the dependency validator know they are used.
@@ -43,7 +43,7 @@ function addKarmaFiles(files, newFiles, prepend = false) {
43
43
  files.push(...processedFiles);
44
44
  }
45
45
  }
46
- const init = (config, emitter, customFileHandlers) => {
46
+ const init = (config, emitter) => {
47
47
  if (!config.buildWebpack) {
48
48
  throw new Error(`The '@angular-devkit/build-angular/plugins/karma' karma plugin is meant to` +
49
49
  ` be used from within Angular CLI and will not work correctly outside of it.`);
@@ -180,38 +180,12 @@ const init = (config, emitter, customFileHandlers) => {
180
180
  unblock();
181
181
  });
182
182
  webpackMiddleware = new webpackDevMiddleware(compiler, webpackMiddlewareConfig);
183
- // Forward requests to webpack server.
184
- customFileHandlers.push({
185
- urlRegex: new RegExp(`\\/${KARMA_APPLICATION_PATH}\\/.*`),
186
- handler: function handler(req, res) {
187
- webpackMiddleware(req, res, function () {
188
- // Ensure script and style bundles are served.
189
- // They are mentioned in the custom karma context page and we don't want them to 404.
190
- const alwaysServe = [
191
- `/${KARMA_APPLICATION_PATH}/runtime.js`,
192
- `/${KARMA_APPLICATION_PATH}/polyfills.js`,
193
- `/${KARMA_APPLICATION_PATH}/polyfills-es5.js`,
194
- `/${KARMA_APPLICATION_PATH}/scripts.js`,
195
- `/${KARMA_APPLICATION_PATH}/styles.js`,
196
- `/${KARMA_APPLICATION_PATH}/vendor.js`,
197
- ];
198
- if (alwaysServe.indexOf(req.url) != -1) {
199
- res.statusCode = 200;
200
- res.end();
201
- }
202
- else {
203
- res.statusCode = 404;
204
- res.end('Not found');
205
- }
206
- });
207
- }
208
- });
209
183
  emitter.on('exit', (done) => {
210
184
  webpackMiddleware.close();
211
185
  done();
212
186
  });
213
187
  };
214
- init.$inject = ['config', 'emitter', 'customFileHandlers'];
188
+ init.$inject = ['config', 'emitter'];
215
189
  // Block requests until the Webpack compilation is done.
216
190
  function requestBlocker() {
217
191
  return function (_request, _response, next) {
@@ -274,8 +248,26 @@ sourceMapReporter.$inject = ['baseReporterDecorator', 'config'];
274
248
  function fallbackMiddleware() {
275
249
  return function (request, response, next) {
276
250
  if (webpackMiddleware) {
277
- request.url = '/' + KARMA_APPLICATION_PATH + request.url;
278
- webpackMiddleware(request, response, next);
251
+ if (request.url && !new RegExp(`\\/${KARMA_APPLICATION_PATH}\\/.*`).test(request.url)) {
252
+ request.url = '/' + KARMA_APPLICATION_PATH + request.url;
253
+ }
254
+ webpackMiddleware(request, response, () => {
255
+ const alwaysServe = [
256
+ `/${KARMA_APPLICATION_PATH}/runtime.js`,
257
+ `/${KARMA_APPLICATION_PATH}/polyfills.js`,
258
+ `/${KARMA_APPLICATION_PATH}/polyfills-es5.js`,
259
+ `/${KARMA_APPLICATION_PATH}/scripts.js`,
260
+ `/${KARMA_APPLICATION_PATH}/styles.js`,
261
+ `/${KARMA_APPLICATION_PATH}/vendor.js`,
262
+ ];
263
+ if (request.url && alwaysServe.includes(request.url)) {
264
+ response.statusCode = 200;
265
+ response.end();
266
+ }
267
+ else {
268
+ next();
269
+ }
270
+ });
279
271
  }
280
272
  else {
281
273
  next();
@@ -292,7 +284,18 @@ function fallbackMiddleware() {
292
284
  function isPlugin(moduleId, pluginName) {
293
285
  return (plugin) => {
294
286
  if (typeof plugin === 'string') {
295
- return plugin === moduleId;
287
+ if (!plugin.includes('*')) {
288
+ return plugin === moduleId;
289
+ }
290
+ const regexp = new RegExp(`^${plugin.replace('*', '.*')}`);
291
+ if (regexp.test(moduleId)) {
292
+ try {
293
+ require.resolve(moduleId);
294
+ return true;
295
+ }
296
+ catch (_a) { }
297
+ }
298
+ return false;
296
299
  }
297
300
  return pluginName in plugin;
298
301
  };
@@ -1,19 +0,0 @@
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
- import { Compiler } from 'webpack';
9
- import { Budget } from '../../browser/schema';
10
- import { NormalizedEntryPoint } from '../utils/helpers';
11
- export interface BundleBudgetPluginOptions {
12
- budgets: Budget[];
13
- extraEntryPoints: NormalizedEntryPoint[];
14
- }
15
- export declare class BundleBudgetPlugin {
16
- private options;
17
- constructor(options: BundleBudgetPluginOptions);
18
- apply(compiler: Compiler): void;
19
- }
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BundleBudgetPlugin = void 0;
4
- const bundle_calculator_1 = require("../../utils/bundle-calculator");
5
- const webpack_diagnostics_1 = require("../../utils/webpack-diagnostics");
6
- const async_chunks_1 = require("../utils/async-chunks");
7
- class BundleBudgetPlugin {
8
- constructor(options) {
9
- this.options = options;
10
- }
11
- apply(compiler) {
12
- const { budgets } = this.options;
13
- if (!budgets || budgets.length === 0) {
14
- return;
15
- }
16
- compiler.hooks.afterEmit.tap('BundleBudgetPlugin', (compilation) => {
17
- // No process bundle results because this plugin is only used when differential
18
- // builds are disabled.
19
- const processResults = [];
20
- // Fix incorrectly set `initial` value on chunks.
21
- const stats = compilation.getStats().toJson();
22
- stats.chunks = async_chunks_1.markAsyncChunksNonInitial(stats, this.options.extraEntryPoints);
23
- for (const { severity, message } of bundle_calculator_1.checkBudgets(budgets, stats, processResults)) {
24
- switch (severity) {
25
- case bundle_calculator_1.ThresholdSeverity.Warning:
26
- webpack_diagnostics_1.addWarning(compilation, `budgets: ${message}`);
27
- break;
28
- case bundle_calculator_1.ThresholdSeverity.Error:
29
- webpack_diagnostics_1.addError(compilation, `budgets: ${message}`);
30
- break;
31
- }
32
- }
33
- });
34
- }
35
- }
36
- exports.BundleBudgetPlugin = BundleBudgetPlugin;