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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/package.json +25 -26
  2. package/src/babel/presets/application.d.ts +1 -0
  3. package/src/babel/presets/application.js +5 -2
  4. package/src/babel/webpack-loader.js +2 -1
  5. package/src/builders/browser/index.js +4 -7
  6. package/src/builders/dev-server/index.js +0 -4
  7. package/src/builders/extract-i18n/index.js +1 -4
  8. package/src/builders/karma/index.d.ts +2 -2
  9. package/src/builders/karma/index.js +1 -7
  10. package/src/builders/server/index.js +1 -7
  11. package/src/utils/build-options.d.ts +1 -2
  12. package/src/utils/i18n-inlining.js +18 -2
  13. package/src/utils/index.d.ts +0 -1
  14. package/src/utils/index.js +0 -1
  15. package/src/utils/normalize-builder-schema.js +2 -0
  16. package/src/{webpack/configs/worker.d.ts → utils/supported-browsers.d.ts} +1 -3
  17. package/src/utils/supported-browsers.js +26 -0
  18. package/src/webpack/configs/common.d.ts +2 -2
  19. package/src/webpack/configs/common.js +130 -158
  20. package/src/webpack/configs/dev-server.d.ts +2 -2
  21. package/src/webpack/configs/index.d.ts +0 -6
  22. package/src/webpack/configs/index.js +0 -6
  23. package/src/webpack/configs/styles.d.ts +2 -2
  24. package/src/webpack/configs/styles.js +2 -4
  25. package/src/webpack/plugins/hmr/hmr-accept.js +4 -1
  26. package/src/webpack/plugins/index.d.ts +2 -0
  27. package/src/webpack/plugins/index.js +5 -1
  28. package/src/webpack/plugins/json-stats-plugin.d.ts +13 -0
  29. package/src/webpack/plugins/json-stats-plugin.js +54 -0
  30. package/src/webpack/plugins/progress-plugin.d.ts +11 -0
  31. package/src/webpack/plugins/progress-plugin.js +38 -0
  32. package/src/webpack/{configs/browser.d.ts → plugins/typescript.d.ts} +2 -2
  33. package/src/webpack/{configs → plugins}/typescript.js +5 -24
  34. package/src/webpack/utils/helpers.d.ts +15 -5
  35. package/src/webpack/utils/helpers.js +159 -34
  36. package/src/webpack/utils/stats.js +1 -2
  37. package/src/utils/build-browser-features.d.ts +0 -16
  38. package/src/utils/build-browser-features.js +0 -54
  39. package/src/webpack/configs/browser.js +0 -81
  40. package/src/webpack/configs/server.d.ts +0 -14
  41. package/src/webpack/configs/server.js +0 -73
  42. package/src/webpack/configs/stats.d.ts +0 -38
  43. package/src/webpack/configs/stats.js +0 -53
  44. package/src/webpack/configs/test.d.ts +0 -10
  45. package/src/webpack/configs/test.js +0 -77
  46. package/src/webpack/configs/typescript.d.ts +0 -12
  47. package/src/webpack/configs/worker.js +0 -22
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ * Copyright Google LLC All Rights Reserved.
5
+ *
6
+ * Use of this source code is governed by an MIT-style license that can be
7
+ * found in the LICENSE file at https://angular.io/license
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.ProgressPlugin = void 0;
11
+ const webpack_1 = require("webpack");
12
+ const spinner_1 = require("../../utils/spinner");
13
+ class ProgressPlugin extends webpack_1.ProgressPlugin {
14
+ constructor(platform) {
15
+ const platformCapitalFirst = platform.replace(/^\w/, (s) => s.toUpperCase());
16
+ const spinner = new spinner_1.Spinner();
17
+ spinner.start(`Generating ${platform} application bundles (phase: setup)...`);
18
+ super({
19
+ handler: (percentage, message) => {
20
+ const phase = message ? ` (phase: ${message})` : '';
21
+ spinner.text = `Generating ${platform} application bundles${phase}...`;
22
+ switch (percentage) {
23
+ case 1:
24
+ if (spinner.isSpinning) {
25
+ spinner.succeed(`${platformCapitalFirst} application bundle generation complete.`);
26
+ }
27
+ break;
28
+ case 0:
29
+ if (!spinner.isSpinning) {
30
+ spinner.start();
31
+ }
32
+ break;
33
+ }
34
+ },
35
+ });
36
+ }
37
+ }
38
+ exports.ProgressPlugin = ProgressPlugin;
@@ -5,6 +5,6 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
- import * as webpack from 'webpack';
8
+ import { AngularWebpackPlugin } from '@ngtools/webpack';
9
9
  import { WebpackConfigOptions } from '../../utils/build-options';
10
- export declare function getBrowserConfig(wco: WebpackConfigOptions): webpack.Configuration;
10
+ export declare function createIvyPlugin(wco: WebpackConfigOptions, aot: boolean, tsconfig: string): AngularWebpackPlugin;
@@ -7,7 +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
- exports.getTypescriptWorkerPlugin = exports.getTypeScriptConfig = void 0;
10
+ exports.createIvyPlugin = void 0;
11
11
  const core_1 = require("@angular-devkit/core");
12
12
  const webpack_1 = require("@ngtools/webpack");
13
13
  const typescript_1 = require("typescript");
@@ -22,6 +22,9 @@ function ensureIvy(wco) {
22
22
  wco.tsConfig.options.enableIvy = true;
23
23
  }
24
24
  function createIvyPlugin(wco, aot, tsconfig) {
25
+ if (aot) {
26
+ ensureIvy(wco);
27
+ }
25
28
  const { buildOptions } = wco;
26
29
  const optimize = buildOptions.optimization.scripts;
27
30
  const compilerOptions = {
@@ -69,26 +72,4 @@ function createIvyPlugin(wco, aot, tsconfig) {
69
72
  inlineStyleFileExtension,
70
73
  });
71
74
  }
72
- function getTypeScriptConfig(wco) {
73
- const { buildOptions: { aot = false, main, polyfills }, tsConfigPath, } = wco;
74
- if (main || polyfills) {
75
- ensureIvy(wco);
76
- return {
77
- module: {
78
- rules: [
79
- {
80
- test: /\.[jt]sx?$/,
81
- loader: webpack_1.AngularWebpackLoaderPath,
82
- },
83
- ],
84
- },
85
- plugins: [createIvyPlugin(wco, aot, tsConfigPath)],
86
- };
87
- }
88
- return {};
89
- }
90
- exports.getTypeScriptConfig = getTypeScriptConfig;
91
- function getTypescriptWorkerPlugin(wco, workerTsConfigPath) {
92
- return createIvyPlugin(wco, false, workerTsConfigPath);
93
- }
94
- exports.getTypescriptWorkerPlugin = getTypescriptWorkerPlugin;
75
+ exports.createIvyPlugin = createIvyPlugin;
@@ -5,8 +5,10 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
- import { Configuration, SourceMapDevToolPlugin } from 'webpack';
9
- import { ExtraEntryPoint, ExtraEntryPointClass } from '../../builders/browser/schema';
8
+ import type { ObjectPattern } from 'copy-webpack-plugin';
9
+ import type { Configuration, WebpackOptionsNormalized } from 'webpack';
10
+ import { AssetPatternClass, ExtraEntryPoint, ExtraEntryPointClass } from '../../builders/browser/schema';
11
+ import { WebpackConfigOptions } from '../../utils/build-options';
10
12
  export interface HashFormat {
11
13
  chunk: string;
12
14
  extract: string;
@@ -16,8 +18,16 @@ export interface HashFormat {
16
18
  export declare function getOutputHashFormat(option: string, length?: number): HashFormat;
17
19
  export declare type NormalizedEntryPoint = Required<ExtraEntryPointClass>;
18
20
  export declare function normalizeExtraEntryPoints(extraEntryPoints: ExtraEntryPoint[], defaultBundleName: string): NormalizedEntryPoint[];
19
- export declare function getSourceMapDevTool(scriptsSourceMap: boolean | undefined, stylesSourceMap: boolean | undefined, hiddenSourceMap?: boolean, inlineSourceMap?: boolean): SourceMapDevToolPlugin;
20
- export declare function isPolyfillsEntry(name: string): boolean;
21
- export declare function getWatchOptions(poll: number | undefined): NonNullable<Configuration['watchOptions']>;
22
21
  export declare function assetNameTemplateFactory(hashFormat: HashFormat): (resourcePath: string) => string;
23
22
  export declare function getInstrumentationExcludedPaths(sourceRoot: string, excludedPaths: string[]): Set<string>;
23
+ export declare function getCacheSettings(wco: WebpackConfigOptions, angularVersion: string): WebpackOptionsNormalized['cache'];
24
+ export declare function globalScriptsByBundleName(root: string, scripts: ExtraEntryPoint[]): {
25
+ bundleName: string;
26
+ inject: boolean;
27
+ paths: string[];
28
+ }[];
29
+ export declare function assetPatterns(root: string, assets: AssetPatternClass[]): ObjectPattern[];
30
+ export declare function externalizePackages(context: string, request: string | undefined, callback: (error?: Error, result?: string) => void): void;
31
+ declare type WebpackStatsOptions = Exclude<Configuration['stats'], string | boolean>;
32
+ export declare function getStatsOptions(verbose?: boolean): WebpackStatsOptions;
33
+ export {};
@@ -29,10 +29,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
29
29
  return (mod && mod.__esModule) ? mod : { "default": mod };
30
30
  };
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.getInstrumentationExcludedPaths = exports.assetNameTemplateFactory = exports.getWatchOptions = exports.isPolyfillsEntry = exports.getSourceMapDevTool = exports.normalizeExtraEntryPoints = exports.getOutputHashFormat = void 0;
32
+ exports.getStatsOptions = exports.externalizePackages = exports.assetPatterns = exports.globalScriptsByBundleName = exports.getCacheSettings = exports.getInstrumentationExcludedPaths = exports.assetNameTemplateFactory = exports.normalizeExtraEntryPoints = exports.getOutputHashFormat = void 0;
33
+ const crypto_1 = require("crypto");
34
+ const fs_1 = require("fs");
33
35
  const glob_1 = __importDefault(require("glob"));
34
36
  const path = __importStar(require("path"));
35
- const webpack_1 = require("webpack");
36
37
  function getOutputHashFormat(option, length = 20) {
37
38
  const hashFormats = {
38
39
  none: { chunk: '', extract: '', file: '', script: '' },
@@ -74,38 +75,6 @@ function normalizeExtraEntryPoints(extraEntryPoints, defaultBundleName) {
74
75
  });
75
76
  }
76
77
  exports.normalizeExtraEntryPoints = normalizeExtraEntryPoints;
77
- function getSourceMapDevTool(scriptsSourceMap, stylesSourceMap, hiddenSourceMap = false, inlineSourceMap = false) {
78
- const include = [];
79
- if (scriptsSourceMap) {
80
- include.push(/js$/);
81
- }
82
- if (stylesSourceMap) {
83
- include.push(/css$/);
84
- }
85
- return new webpack_1.SourceMapDevToolPlugin({
86
- filename: inlineSourceMap ? undefined : '[file].map',
87
- include,
88
- // We want to set sourceRoot to `webpack:///` for non
89
- // inline sourcemaps as otherwise paths to sourcemaps will be broken in browser
90
- // `webpack:///` is needed for Visual Studio breakpoints to work properly as currently
91
- // there is no way to set the 'webRoot'
92
- sourceRoot: 'webpack:///',
93
- moduleFilenameTemplate: '[resource-path]',
94
- append: hiddenSourceMap ? false : undefined,
95
- });
96
- }
97
- exports.getSourceMapDevTool = getSourceMapDevTool;
98
- function isPolyfillsEntry(name) {
99
- return name === 'polyfills';
100
- }
101
- exports.isPolyfillsEntry = isPolyfillsEntry;
102
- function getWatchOptions(poll) {
103
- return {
104
- poll,
105
- ignored: poll === undefined ? '**/$_lazy_route_resources' : 'node_modules/**',
106
- };
107
- }
108
- exports.getWatchOptions = getWatchOptions;
109
78
  function assetNameTemplateFactory(hashFormat) {
110
79
  const visitedFiles = new Map();
111
80
  return (resourcePath) => {
@@ -140,3 +109,159 @@ function getInstrumentationExcludedPaths(sourceRoot, excludedPaths) {
140
109
  return excluded;
141
110
  }
142
111
  exports.getInstrumentationExcludedPaths = getInstrumentationExcludedPaths;
112
+ function getCacheSettings(wco, angularVersion) {
113
+ const { enabled, path: cacheDirectory } = wco.buildOptions.cache;
114
+ if (enabled) {
115
+ const packageVersion = require('../../../package.json').version;
116
+ return {
117
+ type: 'filesystem',
118
+ cacheDirectory: path.join(cacheDirectory, 'angular-webpack'),
119
+ maxMemoryGenerations: 1,
120
+ // We use the versions and build options as the cache name. The Webpack configurations are too
121
+ // dynamic and shared among different build types: test, build and serve.
122
+ // None of which are "named".
123
+ name: (0, crypto_1.createHash)('sha1')
124
+ .update(angularVersion)
125
+ .update(packageVersion)
126
+ .update(wco.projectRoot)
127
+ .update(JSON.stringify(wco.tsConfig))
128
+ .update(JSON.stringify({
129
+ ...wco.buildOptions,
130
+ // Needed because outputPath changes on every build when using i18n extraction
131
+ // https://github.com/angular/angular-cli/blob/736a5f89deaca85f487b78aec9ff66d4118ceb6a/packages/angular_devkit/build_angular/src/utils/i18n-options.ts#L264-L265
132
+ outputPath: undefined,
133
+ }))
134
+ .digest('hex'),
135
+ };
136
+ }
137
+ if (wco.buildOptions.watch) {
138
+ return {
139
+ type: 'memory',
140
+ maxGenerations: 1,
141
+ };
142
+ }
143
+ return false;
144
+ }
145
+ exports.getCacheSettings = getCacheSettings;
146
+ function globalScriptsByBundleName(root, scripts) {
147
+ return normalizeExtraEntryPoints(scripts, 'scripts').reduce((prev, curr) => {
148
+ const { bundleName, inject, input } = curr;
149
+ let resolvedPath = path.resolve(root, input);
150
+ if (!(0, fs_1.existsSync)(resolvedPath)) {
151
+ try {
152
+ resolvedPath = require.resolve(input, { paths: [root] });
153
+ }
154
+ catch {
155
+ throw new Error(`Script file ${input} does not exist.`);
156
+ }
157
+ }
158
+ const existingEntry = prev.find((el) => el.bundleName === bundleName);
159
+ if (existingEntry) {
160
+ if (existingEntry.inject && !inject) {
161
+ // All entries have to be lazy for the bundle to be lazy.
162
+ throw new Error(`The ${bundleName} bundle is mixing injected and non-injected scripts.`);
163
+ }
164
+ existingEntry.paths.push(resolvedPath);
165
+ }
166
+ else {
167
+ prev.push({
168
+ bundleName,
169
+ inject,
170
+ paths: [resolvedPath],
171
+ });
172
+ }
173
+ return prev;
174
+ }, []);
175
+ }
176
+ exports.globalScriptsByBundleName = globalScriptsByBundleName;
177
+ function assetPatterns(root, assets) {
178
+ return assets.map((asset, index) => {
179
+ // Resolve input paths relative to workspace root and add slash at the end.
180
+ // eslint-disable-next-line prefer-const
181
+ let { input, output, ignore = [], glob } = asset;
182
+ input = path.resolve(root, input).replace(/\\/g, '/');
183
+ input = input.endsWith('/') ? input : input + '/';
184
+ output = output.endsWith('/') ? output : output + '/';
185
+ if (output.startsWith('..')) {
186
+ throw new Error('An asset cannot be written to a location outside of the output path.');
187
+ }
188
+ return {
189
+ context: input,
190
+ // Now we remove starting slash to make Webpack place it from the output root.
191
+ to: output.replace(/^\//, ''),
192
+ from: glob,
193
+ noErrorOnMissing: true,
194
+ force: true,
195
+ globOptions: {
196
+ dot: true,
197
+ followSymbolicLinks: !!asset.followSymlinks,
198
+ ignore: [
199
+ '.gitkeep',
200
+ '**/.DS_Store',
201
+ '**/Thumbs.db',
202
+ // Negate patterns needs to be absolute because copy-webpack-plugin uses absolute globs which
203
+ // causes negate patterns not to match.
204
+ // See: https://github.com/webpack-contrib/copy-webpack-plugin/issues/498#issuecomment-639327909
205
+ ...ignore,
206
+ ].map((i) => path.posix.join(input, i)),
207
+ },
208
+ priority: index,
209
+ };
210
+ });
211
+ }
212
+ exports.assetPatterns = assetPatterns;
213
+ function externalizePackages(context, request, callback) {
214
+ if (!request) {
215
+ return;
216
+ }
217
+ // Absolute & Relative paths are not externals
218
+ if (request.startsWith('.') || path.isAbsolute(request)) {
219
+ callback();
220
+ return;
221
+ }
222
+ try {
223
+ require.resolve(request, { paths: [context] });
224
+ callback(undefined, request);
225
+ }
226
+ catch {
227
+ // Node couldn't find it, so it must be user-aliased
228
+ callback();
229
+ }
230
+ }
231
+ exports.externalizePackages = externalizePackages;
232
+ function getStatsOptions(verbose = false) {
233
+ const webpackOutputOptions = {
234
+ all: false,
235
+ colors: true,
236
+ hash: true,
237
+ timings: true,
238
+ chunks: true,
239
+ builtAt: true,
240
+ warnings: true,
241
+ errors: true,
242
+ assets: true,
243
+ cachedAssets: true,
244
+ // Needed for markAsyncChunksNonInitial.
245
+ ids: true,
246
+ entrypoints: true,
247
+ };
248
+ const verboseWebpackOutputOptions = {
249
+ // The verbose output will most likely be piped to a file, so colors just mess it up.
250
+ colors: false,
251
+ usedExports: true,
252
+ optimizationBailout: true,
253
+ reasons: true,
254
+ children: true,
255
+ assets: true,
256
+ version: true,
257
+ chunkModules: true,
258
+ errorDetails: true,
259
+ moduleTrace: true,
260
+ logging: 'verbose',
261
+ modulesSpace: Infinity,
262
+ };
263
+ return verbose
264
+ ? { ...webpackOutputOptions, ...verboseWebpackOutputOptions }
265
+ : webpackOutputOptions;
266
+ }
267
+ exports.getStatsOptions = getStatsOptions;
@@ -34,7 +34,6 @@ const core_1 = require("@angular-devkit/core");
34
34
  const path = __importStar(require("path"));
35
35
  const text_table_1 = __importDefault(require("text-table"));
36
36
  const color_1 = require("../../utils/color");
37
- const stats_1 = require("../configs/stats");
38
37
  const async_chunks_1 = require("./async-chunks");
39
38
  const helpers_1 = require("./helpers");
40
39
  function formatSize(size) {
@@ -266,7 +265,7 @@ function createWebpackLoggingCallback(options, logger) {
266
265
  if (verbose) {
267
266
  logger.info(stats.toString(config.stats));
268
267
  }
269
- const rawStats = stats.toJson((0, stats_1.getWebpackStatsConfig)(false));
268
+ const rawStats = stats.toJson((0, helpers_1.getStatsOptions)(false));
270
269
  const webpackStats = {
271
270
  ...rawStats,
272
271
  chunks: (0, async_chunks_1.markAsyncChunksNonInitial)(rawStats, extraEntryPoints),
@@ -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
- };