@angular-devkit/build-angular 13.0.2 → 13.1.0-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/package.json +30 -30
  2. package/src/builders/browser/index.js +4 -7
  3. package/src/builders/dev-server/index.js +0 -4
  4. package/src/builders/extract-i18n/index.js +1 -4
  5. package/src/builders/karma/index.d.ts +2 -2
  6. package/src/builders/karma/index.js +1 -7
  7. package/src/builders/server/index.js +1 -7
  8. package/src/utils/build-options.d.ts +1 -2
  9. package/src/utils/i18n-inlining.js +18 -2
  10. package/src/utils/index.d.ts +0 -1
  11. package/src/utils/index.js +0 -1
  12. package/src/utils/normalize-builder-schema.js +2 -0
  13. package/src/{webpack/configs/worker.d.ts → utils/supported-browsers.d.ts} +1 -3
  14. package/src/utils/supported-browsers.js +26 -0
  15. package/src/webpack/configs/common.d.ts +2 -2
  16. package/src/webpack/configs/common.js +132 -158
  17. package/src/webpack/configs/dev-server.d.ts +2 -2
  18. package/src/webpack/configs/dev-server.js +74 -19
  19. package/src/webpack/configs/index.d.ts +0 -6
  20. package/src/webpack/configs/index.js +0 -6
  21. package/src/webpack/configs/styles.d.ts +2 -2
  22. package/src/webpack/configs/styles.js +2 -4
  23. package/src/webpack/plugins/index.d.ts +2 -0
  24. package/src/webpack/plugins/index.js +5 -1
  25. package/src/webpack/plugins/json-stats-plugin.d.ts +13 -0
  26. package/src/webpack/plugins/json-stats-plugin.js +54 -0
  27. package/src/webpack/plugins/progress-plugin.d.ts +11 -0
  28. package/src/webpack/plugins/progress-plugin.js +38 -0
  29. package/src/webpack/plugins/transfer-size-plugin.d.ts +12 -0
  30. package/src/webpack/plugins/transfer-size-plugin.js +47 -0
  31. package/src/webpack/{configs/browser.d.ts → plugins/typescript.d.ts} +2 -2
  32. package/src/webpack/{configs → plugins}/typescript.js +5 -24
  33. package/src/webpack/utils/helpers.d.ts +15 -5
  34. package/src/webpack/utils/helpers.js +159 -34
  35. package/src/webpack/utils/stats.d.ts +8 -2
  36. package/src/webpack/utils/stats.js +66 -21
  37. package/src/utils/build-browser-features.d.ts +0 -16
  38. package/src/utils/build-browser-features.js +0 -54
  39. package/src/webpack/configs/browser.js +0 -81
  40. package/src/webpack/configs/server.d.ts +0 -14
  41. package/src/webpack/configs/server.js +0 -73
  42. package/src/webpack/configs/stats.d.ts +0 -38
  43. package/src/webpack/configs/stats.js +0 -53
  44. package/src/webpack/configs/test.d.ts +0 -10
  45. package/src/webpack/configs/test.js +0 -77
  46. package/src/webpack/configs/typescript.d.ts +0 -12
  47. package/src/webpack/configs/worker.js +0 -22
@@ -1,16 +0,0 @@
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
- export declare class BuildBrowserFeatures {
9
- private projectRoot;
10
- readonly supportedBrowsers: string[];
11
- constructor(projectRoot: string);
12
- /**
13
- * True, when a browser feature is supported partially or fully.
14
- */
15
- isFeatureSupported(featureId: string): boolean;
16
- }
@@ -1,54 +0,0 @@
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 __importDefault = (this && this.__importDefault) || function (mod) {
10
- return (mod && mod.__esModule) ? mod : { "default": mod };
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.BuildBrowserFeatures = void 0;
14
- const browserslist_1 = __importDefault(require("browserslist"));
15
- const caniuse_lite_1 = require("caniuse-lite");
16
- class BuildBrowserFeatures {
17
- constructor(projectRoot) {
18
- // By default, browserslist defaults are too inclusive
19
- // https://github.com/browserslist/browserslist/blob/83764ea81ffaa39111c204b02c371afa44a4ff07/index.js#L516-L522
20
- this.projectRoot = projectRoot;
21
- // We change the default query to browsers that Angular support.
22
- // https://angular.io/guide/browser-support
23
- browserslist_1.default.defaults = [
24
- 'last 1 Chrome version',
25
- 'last 1 Firefox version',
26
- 'last 2 Edge major versions',
27
- 'last 2 Safari major versions',
28
- 'last 2 iOS major versions',
29
- 'Firefox ESR',
30
- ];
31
- this.supportedBrowsers = (0, browserslist_1.default)(undefined, { path: this.projectRoot });
32
- }
33
- /**
34
- * True, when a browser feature is supported partially or fully.
35
- */
36
- isFeatureSupported(featureId) {
37
- // y: feature is fully available
38
- // n: feature is unavailable
39
- // a: feature is partially supported
40
- // x: feature is prefixed
41
- const criteria = ['y', 'a'];
42
- const data = (0, caniuse_lite_1.feature)(caniuse_lite_1.features[featureId]);
43
- return !this.supportedBrowsers.some((browser) => {
44
- const [agentId, version] = browser.split(' ');
45
- const browserData = data.stats[agentId];
46
- const featureStatus = (browserData && browserData[version]);
47
- // We are only interested in the first character
48
- // Ex: when 'a #4 #5', we only need to check for 'a'
49
- // as for such cases we should polyfill these features as needed
50
- return !featureStatus || !criteria.includes(featureStatus.charAt(0));
51
- });
52
- }
53
- }
54
- exports.BuildBrowserFeatures = BuildBrowserFeatures;
@@ -1,81 +0,0 @@
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.getBrowserConfig = void 0;
11
- const webpack_subresource_integrity_1 = require("webpack-subresource-integrity");
12
- const plugins_1 = require("../plugins");
13
- const helpers_1 = require("../utils/helpers");
14
- function getBrowserConfig(wco) {
15
- const { buildOptions } = wco;
16
- const { crossOrigin = 'none', subresourceIntegrity, vendorChunk, commonChunk, allowedCommonJsDependencies, } = buildOptions;
17
- const extraPlugins = [];
18
- const { styles: stylesSourceMap, scripts: scriptsSourceMap, hidden: hiddenSourceMap, } = buildOptions.sourceMap;
19
- if (subresourceIntegrity) {
20
- extraPlugins.push(new webpack_subresource_integrity_1.SubresourceIntegrityPlugin({
21
- hashFuncNames: ['sha384'],
22
- }));
23
- }
24
- if (scriptsSourceMap || stylesSourceMap) {
25
- extraPlugins.push((0, helpers_1.getSourceMapDevTool)(scriptsSourceMap, stylesSourceMap, hiddenSourceMap, false));
26
- }
27
- let crossOriginLoading = false;
28
- if (subresourceIntegrity && crossOrigin === 'none') {
29
- crossOriginLoading = 'anonymous';
30
- }
31
- else if (crossOrigin !== 'none') {
32
- crossOriginLoading = crossOrigin;
33
- }
34
- return {
35
- devtool: false,
36
- resolve: {
37
- mainFields: ['es2020', 'es2015', 'browser', 'module', 'main'],
38
- conditionNames: ['es2020', 'es2015', '...'],
39
- },
40
- output: {
41
- crossOriginLoading,
42
- trustedTypes: 'angular#bundler',
43
- scriptType: 'module',
44
- },
45
- optimization: {
46
- runtimeChunk: 'single',
47
- splitChunks: {
48
- maxAsyncRequests: Infinity,
49
- cacheGroups: {
50
- default: !!commonChunk && {
51
- chunks: 'async',
52
- minChunks: 2,
53
- priority: 10,
54
- },
55
- common: !!commonChunk && {
56
- name: 'common',
57
- chunks: 'async',
58
- minChunks: 2,
59
- enforce: true,
60
- priority: 5,
61
- },
62
- vendors: false,
63
- defaultVendors: !!vendorChunk && {
64
- name: 'vendor',
65
- chunks: (chunk) => chunk.name === 'main',
66
- enforce: true,
67
- test: /[\\/]node_modules[\\/]/,
68
- },
69
- },
70
- },
71
- },
72
- plugins: [
73
- new plugins_1.CommonJsUsageWarnPlugin({
74
- allowedDependencies: allowedCommonJsDependencies,
75
- }),
76
- ...extraPlugins,
77
- ],
78
- node: false,
79
- };
80
- }
81
- exports.getBrowserConfig = getBrowserConfig;
@@ -1,14 +0,0 @@
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 { Configuration } from 'webpack';
9
- import { WebpackConfigOptions } from '../../utils/build-options';
10
- /**
11
- * Returns a partial Webpack configuration specific to creating a bundle for node
12
- * @param wco Options which include the build options and app config
13
- */
14
- export declare function getServerConfig(wco: WebpackConfigOptions): Configuration;
@@ -1,73 +0,0 @@
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.getServerConfig = void 0;
11
- const path_1 = require("path");
12
- const webpack_1 = require("webpack");
13
- const helpers_1 = require("../utils/helpers");
14
- /**
15
- * Returns a partial Webpack configuration specific to creating a bundle for node
16
- * @param wco Options which include the build options and app config
17
- */
18
- function getServerConfig(wco) {
19
- const { sourceMap, bundleDependencies, externalDependencies = [] } = wco.buildOptions;
20
- const extraPlugins = [];
21
- const { scripts, styles, hidden } = sourceMap;
22
- if (scripts || styles) {
23
- extraPlugins.push((0, helpers_1.getSourceMapDevTool)(scripts, styles, hidden));
24
- }
25
- const externals = [...externalDependencies];
26
- if (!bundleDependencies) {
27
- externals.push(({ context, request }, callback) => externalizePackages(context !== null && context !== void 0 ? context : wco.projectRoot, request, callback));
28
- }
29
- return {
30
- resolve: {
31
- mainFields: ['es2015', 'main', 'module'],
32
- conditionNames: ['es2015', '...'],
33
- },
34
- output: {
35
- libraryTarget: 'commonjs',
36
- },
37
- module: {
38
- parser: {
39
- javascript: {
40
- worker: false,
41
- url: false,
42
- },
43
- },
44
- },
45
- plugins: [
46
- // Fixes Critical dependency: the request of a dependency is an expression
47
- new webpack_1.ContextReplacementPlugin(/@?hapi(\\|\/)/),
48
- new webpack_1.ContextReplacementPlugin(/express(\\|\/)/),
49
- ...extraPlugins,
50
- ],
51
- node: false,
52
- externals,
53
- };
54
- }
55
- exports.getServerConfig = getServerConfig;
56
- function externalizePackages(context, request, callback) {
57
- if (!request) {
58
- return;
59
- }
60
- // Absolute & Relative paths are not externals
61
- if (request.startsWith('.') || (0, path_1.isAbsolute)(request)) {
62
- callback();
63
- return;
64
- }
65
- try {
66
- require.resolve(request, { paths: [context] });
67
- callback(undefined, request);
68
- }
69
- catch {
70
- // Node couldn't find it, so it must be user-aliased
71
- callback();
72
- }
73
- }
@@ -1,38 +0,0 @@
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 { WebpackConfigOptions } from '../../utils/build-options';
9
- export declare function getWebpackStatsConfig(verbose?: boolean): {
10
- all: boolean;
11
- colors: boolean;
12
- hash: boolean;
13
- timings: boolean;
14
- chunks: boolean;
15
- builtAt: boolean;
16
- warnings: boolean;
17
- errors: boolean;
18
- assets: boolean;
19
- cachedAssets: boolean;
20
- ids: boolean;
21
- entrypoints: boolean;
22
- };
23
- export declare function getStatsConfig(wco: WebpackConfigOptions): {
24
- stats: {
25
- all: boolean;
26
- colors: boolean;
27
- hash: boolean;
28
- timings: boolean;
29
- chunks: boolean;
30
- builtAt: boolean;
31
- warnings: boolean;
32
- errors: boolean;
33
- assets: boolean;
34
- cachedAssets: boolean;
35
- ids: boolean;
36
- entrypoints: boolean;
37
- };
38
- };
@@ -1,53 +0,0 @@
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.getStatsConfig = exports.getWebpackStatsConfig = void 0;
11
- const webpackOutputOptions = {
12
- all: false,
13
- colors: true,
14
- hash: true,
15
- timings: true,
16
- chunks: true,
17
- builtAt: true,
18
- warnings: true,
19
- errors: true,
20
- assets: true,
21
- cachedAssets: true,
22
- // Needed for markAsyncChunksNonInitial.
23
- ids: true,
24
- entrypoints: true,
25
- };
26
- const verboseWebpackOutputOptions = {
27
- // The verbose output will most likely be piped to a file, so colors just mess it up.
28
- colors: false,
29
- usedExports: true,
30
- optimizationBailout: true,
31
- reasons: true,
32
- children: true,
33
- assets: true,
34
- version: true,
35
- chunkModules: true,
36
- errorDetails: true,
37
- moduleTrace: true,
38
- logging: 'verbose',
39
- modulesSpace: Infinity,
40
- };
41
- function getWebpackStatsConfig(verbose = false) {
42
- return verbose
43
- ? { ...webpackOutputOptions, ...verboseWebpackOutputOptions }
44
- : webpackOutputOptions;
45
- }
46
- exports.getWebpackStatsConfig = getWebpackStatsConfig;
47
- function getStatsConfig(wco) {
48
- const verbose = !!wco.buildOptions.verbose;
49
- return {
50
- stats: getWebpackStatsConfig(verbose),
51
- };
52
- }
53
- exports.getStatsConfig = getStatsConfig;
@@ -1,10 +0,0 @@
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 * as webpack from 'webpack';
9
- import { WebpackConfigOptions, WebpackTestOptions } from '../../utils/build-options';
10
- export declare function getTestConfig(wco: WebpackConfigOptions<WebpackTestOptions>): webpack.Configuration;
@@ -1,77 +0,0 @@
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.getTestConfig = void 0;
30
- const path = __importStar(require("path"));
31
- const typescript_1 = require("typescript");
32
- const helpers_1 = require("../utils/helpers");
33
- function getTestConfig(wco) {
34
- const { buildOptions: { main, sourceMap, webWorkerTsConfig }, root, } = wco;
35
- const extraPlugins = [];
36
- if (sourceMap.scripts || sourceMap.styles) {
37
- extraPlugins.push((0, helpers_1.getSourceMapDevTool)(sourceMap.scripts, sourceMap.styles, false, true));
38
- }
39
- return {
40
- mode: 'development',
41
- target: wco.tsConfig.options.target === typescript_1.ScriptTarget.ES5 ? ['web', 'es5'] : 'web',
42
- resolve: {
43
- mainFields: ['es2020', 'es2015', 'browser', 'module', 'main'],
44
- conditionNames: ['es2020', 'es2015', '...'],
45
- },
46
- devtool: false,
47
- entry: {
48
- main: path.resolve(root, main),
49
- },
50
- module: {
51
- parser: webWorkerTsConfig === undefined
52
- ? {
53
- javascript: {
54
- worker: false,
55
- url: false,
56
- },
57
- }
58
- : undefined,
59
- },
60
- plugins: extraPlugins,
61
- optimization: {
62
- splitChunks: {
63
- chunks: (chunk) => !(0, helpers_1.isPolyfillsEntry)(chunk.name),
64
- cacheGroups: {
65
- vendors: false,
66
- defaultVendors: {
67
- name: 'vendor',
68
- chunks: (chunk) => chunk.name === 'main',
69
- enforce: true,
70
- test: /[\\/]node_modules[\\/]/,
71
- },
72
- },
73
- },
74
- },
75
- };
76
- }
77
- exports.getTestConfig = getTestConfig;
@@ -1,12 +0,0 @@
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 { AngularWebpackPlugin } from '@ngtools/webpack';
9
- import { Configuration } from 'webpack';
10
- import { WebpackConfigOptions } from '../../utils/build-options';
11
- export declare function getTypeScriptConfig(wco: WebpackConfigOptions): Configuration;
12
- export declare function getTypescriptWorkerPlugin(wco: WebpackConfigOptions, workerTsConfigPath: string): AngularWebpackPlugin;
@@ -1,22 +0,0 @@
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.getWorkerConfig = void 0;
11
- const path_1 = require("path");
12
- const typescript_1 = require("./typescript");
13
- function getWorkerConfig(wco) {
14
- const { webWorkerTsConfig } = wco.buildOptions;
15
- if (!webWorkerTsConfig) {
16
- return {};
17
- }
18
- return {
19
- plugins: [(0, typescript_1.getTypescriptWorkerPlugin)(wco, (0, path_1.resolve)(wco.root, webWorkerTsConfig))],
20
- };
21
- }
22
- exports.getWorkerConfig = getWorkerConfig;