@angular-devkit/build-angular 13.1.0-next.3 → 13.1.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.
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@angular-devkit/build-angular",
3
- "version": "13.1.0-next.3",
3
+ "version": "13.1.2",
4
4
  "description": "Angular Webpack Build Facade",
5
5
  "main": "src/index.js",
6
6
  "typings": "src/index.d.ts",
7
7
  "builders": "builders.json",
8
8
  "dependencies": {
9
9
  "@ampproject/remapping": "1.0.2",
10
- "@angular-devkit/architect": "0.1301.0-next.3",
11
- "@angular-devkit/build-webpack": "0.1301.0-next.3",
12
- "@angular-devkit/core": "13.1.0-next.3",
10
+ "@angular-devkit/architect": "0.1301.2",
11
+ "@angular-devkit/build-webpack": "0.1301.2",
12
+ "@angular-devkit/core": "13.1.2",
13
13
  "@babel/core": "7.16.0",
14
14
  "@babel/generator": "7.16.0",
15
15
  "@babel/helper-annotate-as-pure": "7.16.0",
@@ -20,7 +20,7 @@
20
20
  "@babel/runtime": "7.16.3",
21
21
  "@babel/template": "7.16.0",
22
22
  "@discoveryjs/json-ext": "0.5.6",
23
- "@ngtools/webpack": "13.1.0-next.3",
23
+ "@ngtools/webpack": "13.1.2",
24
24
  "ansi-colors": "4.1.1",
25
25
  "babel-loader": "8.2.3",
26
26
  "babel-plugin-istanbul": "6.1.1",
@@ -28,10 +28,10 @@
28
28
  "cacache": "15.3.0",
29
29
  "circular-dependency-plugin": "5.2.2",
30
30
  "copy-webpack-plugin": "10.0.0",
31
- "core-js": "3.19.2",
31
+ "core-js": "3.19.3",
32
32
  "critters": "0.0.15",
33
33
  "css-loader": "6.5.1",
34
- "esbuild-wasm": "0.14.1",
34
+ "esbuild-wasm": "0.14.2",
35
35
  "glob": "7.2.0",
36
36
  "https-proxy-agent": "5.0.0",
37
37
  "inquirer": "8.2.0",
@@ -55,7 +55,7 @@
55
55
  "resolve-url-loader": "4.0.0",
56
56
  "rxjs": "6.6.7",
57
57
  "sass": "1.44.0",
58
- "sass-loader": "12.3.0",
58
+ "sass-loader": "12.4.0",
59
59
  "semver": "7.3.5",
60
60
  "source-map-loader": "3.0.0",
61
61
  "source-map-support": "0.5.21",
@@ -65,14 +65,14 @@
65
65
  "text-table": "0.2.0",
66
66
  "tree-kill": "1.2.2",
67
67
  "tslib": "2.3.1",
68
- "webpack": "5.64.4",
68
+ "webpack": "5.65.0",
69
69
  "webpack-dev-middleware": "5.2.2",
70
70
  "webpack-dev-server": "4.6.0",
71
71
  "webpack-merge": "5.8.0",
72
72
  "webpack-subresource-integrity": "5.0.0"
73
73
  },
74
74
  "optionalDependencies": {
75
- "esbuild": "0.14.1"
75
+ "esbuild": "0.14.2"
76
76
  },
77
77
  "peerDependencies": {
78
78
  "@angular/compiler-cli": "^13.0.0 || ^13.1.0-next",
@@ -81,8 +81,8 @@
81
81
  "karma": "^6.3.0",
82
82
  "ng-packagr": "^13.0.0 || ^13.1.0-next",
83
83
  "protractor": "^7.0.0",
84
- "tailwindcss": "^2.0.0",
85
- "typescript": "~4.4.3"
84
+ "tailwindcss": "^2.0.0 || ^3.0.0",
85
+ "typescript": ">=4.4.3 <4.6"
86
86
  },
87
87
  "peerDependenciesMeta": {
88
88
  "@angular/localize": {
@@ -5,6 +5,7 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
+ import type { ɵParsedTranslation } from '@angular/localize/private';
8
9
  import type { makeEs2015TranslatePlugin, makeEs5TranslatePlugin, makeLocalePlugin } from '@angular/localize/tools';
9
10
  export declare type DiagnosticReporter = (type: 'error' | 'warning' | 'info', message: string) => void;
10
11
  /**
@@ -22,9 +23,9 @@ export interface ApplicationPresetOptions {
22
23
  i18n?: {
23
24
  locale: string;
24
25
  missingTranslationBehavior?: 'error' | 'warning' | 'ignore';
25
- translation?: unknown;
26
+ translation?: Record<string, ɵParsedTranslation>;
26
27
  translationFiles?: string[];
27
- pluginCreators?: I18nPluginCreators;
28
+ pluginCreators: I18nPluginCreators;
28
29
  };
29
30
  angularLinker?: {
30
31
  shouldLink: boolean;
@@ -60,28 +60,18 @@ function createI18nDiagnostics(reporter) {
60
60
  })();
61
61
  return diagnostics;
62
62
  }
63
- function createI18nPlugins(locale, translation, missingTranslationBehavior, diagnosticReporter,
64
- // TODO_ESM: Make `pluginCreators` required once `@angular/localize` is published with the `tools` entry point
65
- pluginCreators) {
63
+ function createI18nPlugins(locale, translation, missingTranslationBehavior, diagnosticReporter, pluginCreators) {
66
64
  const diagnostics = createI18nDiagnostics(diagnosticReporter);
67
65
  const plugins = [];
66
+ const { makeEs5TranslatePlugin, makeEs2015TranslatePlugin, makeLocalePlugin } = pluginCreators;
68
67
  if (translation) {
69
- const { makeEs2015TranslatePlugin,
70
- // TODO_ESM: Remove all deep imports once `@angular/localize` is published with the `tools` entry point
71
- } = pluginCreators !== null && pluginCreators !== void 0 ? pluginCreators : require('@angular/localize/src/tools/src/translate/source_files/es2015_translate_plugin');
72
68
  plugins.push(makeEs2015TranslatePlugin(diagnostics, translation, {
73
69
  missingTranslation: missingTranslationBehavior,
74
70
  }));
75
- const { makeEs5TranslatePlugin,
76
- // TODO_ESM: Remove all deep imports once `@angular/localize` is published with the `tools` entry point
77
- } = pluginCreators !== null && pluginCreators !== void 0 ? pluginCreators : require('@angular/localize/src/tools/src/translate/source_files/es5_translate_plugin');
78
71
  plugins.push(makeEs5TranslatePlugin(diagnostics, translation, {
79
72
  missingTranslation: missingTranslationBehavior,
80
73
  }));
81
74
  }
82
- const { makeLocalePlugin,
83
- // TODO_ESM: Remove all deep imports once `@angular/localize` is published with the `tools` entry point
84
- } = pluginCreators !== null && pluginCreators !== void 0 ? pluginCreators : require('@angular/localize/src/tools/src/translate/source_files/locale_plugin');
85
75
  plugins.push(makeLocalePlugin(locale));
86
76
  return plugins;
87
77
  }
@@ -66,13 +66,10 @@ exports.default = (0, babel_loader_1.custom)(() => {
66
66
  };
67
67
  // Analyze file for linking
68
68
  if (await requiresLinking(this.resourcePath, source)) {
69
- if (!linkerPluginCreator) {
70
- // Load ESM `@angular/compiler-cli/linker/babel` using the TypeScript dynamic import workaround.
71
- // Once TypeScript provides support for keeping the dynamic import this workaround can be
72
- // changed to a direct dynamic import.
73
- const linkerBabelModule = await (0, load_esm_1.loadEsmModule)('@angular/compiler-cli/linker/babel');
74
- linkerPluginCreator = linkerBabelModule.createEs2015LinkerPlugin;
75
- }
69
+ // Load ESM `@angular/compiler-cli/linker/babel` using the TypeScript dynamic import workaround.
70
+ // Once TypeScript provides support for keeping the dynamic import this workaround can be
71
+ // changed to a direct dynamic import.
72
+ linkerPluginCreator !== null && linkerPluginCreator !== void 0 ? linkerPluginCreator : (linkerPluginCreator = (await (0, load_esm_1.loadEsmModule)('@angular/compiler-cli/linker/babel')).createEs2015LinkerPlugin);
76
73
  customOptions.angularLinker = {
77
74
  shouldLink: true,
78
75
  jitMode: aot !== true,
@@ -105,15 +102,11 @@ exports.default = (0, babel_loader_1.custom)(() => {
105
102
  // During the transition, this will always attempt to load the entry point for each file.
106
103
  // This will only occur during prerelease and will be automatically corrected once the new
107
104
  // entry point exists.
108
- // TODO_ESM: Make import failure an error once the `tools` entry point exists.
109
105
  if (i18nPluginCreators === undefined) {
110
106
  // Load ESM `@angular/localize/tools` using the TypeScript dynamic import workaround.
111
107
  // Once TypeScript provides support for keeping the dynamic import this workaround can be
112
108
  // changed to a direct dynamic import.
113
- try {
114
- i18nPluginCreators = await (0, load_esm_1.loadEsmModule)('@angular/localize/tools');
115
- }
116
- catch { }
109
+ i18nPluginCreators = await (0, load_esm_1.loadEsmModule)('@angular/localize/tools');
117
110
  }
118
111
  customOptions.i18n = {
119
112
  ...i18n,
@@ -47,7 +47,6 @@ async function extract(loaderContext, content, map, options) {
47
47
  // Try to load the `@angular/localize` message extractor.
48
48
  // All the localize usages are setup to first try the ESM entry point then fallback to the deep imports.
49
49
  // This provides interim compatibility while the framework is transitioned to bundled ESM packages.
50
- // TODO_ESM: Remove all deep imports once `@angular/localize` is published with the `tools` entry point
51
50
  let MessageExtractor;
52
51
  try {
53
52
  // Load ESM `@angular/localize/tools` using the TypeScript dynamic import workaround.
@@ -8,6 +8,5 @@
8
8
  export declare const allowMangle: boolean;
9
9
  export declare const shouldBeautify: boolean;
10
10
  export declare const allowMinify: boolean;
11
- export declare const profilingEnabled: boolean;
12
11
  export declare const maxWorkers: number;
13
12
  export declare const cachingDisabled: boolean | null;
@@ -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.cachingDisabled = exports.maxWorkers = exports.profilingEnabled = exports.allowMinify = exports.shouldBeautify = exports.allowMangle = void 0;
10
+ exports.cachingDisabled = exports.maxWorkers = exports.allowMinify = exports.shouldBeautify = exports.allowMangle = void 0;
11
11
  const color_1 = require("./color");
12
12
  function isDisabled(variable) {
13
13
  return variable === '0' || variable.toLowerCase() === 'false';
@@ -57,9 +57,6 @@ exports.allowMangle = isPresent(mangleVariable)
57
57
  : debugOptimize.mangle;
58
58
  exports.shouldBeautify = debugOptimize.beautify;
59
59
  exports.allowMinify = debugOptimize.minify;
60
- // Build profiling
61
- const profilingVariable = process.env['NG_BUILD_PROFILING'];
62
- exports.profilingEnabled = isPresent(profilingVariable) && isEnabled(profilingVariable);
63
60
  /**
64
61
  * Some environments, like CircleCI which use Docker report a number of CPUs by the host and not the count of available.
65
62
  * This cause `Error: Call retries were exceeded` errors when trying to use them.
@@ -158,9 +158,7 @@ async function configureI18nBuild(context, options) {
158
158
  if (!desc.files.length) {
159
159
  continue;
160
160
  }
161
- if (!loader) {
162
- loader = await (0, load_translations_1.createTranslationLoader)();
163
- }
161
+ loader !== null && loader !== void 0 ? loader : (loader = await (0, load_translations_1.createTranslationLoader)());
164
162
  loadTranslations(locale, desc, context.workspaceRoot, loader, {
165
163
  warn(message) {
166
164
  context.logger.warn(message);
@@ -154,13 +154,26 @@ function updateAttribute(tag, name, value) {
154
154
  function isString(value) {
155
155
  return typeof value === 'string';
156
156
  }
157
- async function getLanguageDirection(lang, warnings) {
157
+ async function getLanguageDirection(locale, warnings) {
158
+ const dir = await getLanguageDirectionFromLocales(locale);
159
+ if (!dir) {
160
+ warnings.push(`Locale data for '${locale}' cannot be found. 'dir' attribute will not be set for this locale.`);
161
+ }
162
+ return dir;
163
+ }
164
+ async function getLanguageDirectionFromLocales(locale) {
158
165
  try {
159
- const localeData = (await (0, load_esm_1.loadEsmModule)(`@angular/common/locales/${lang}`)).default;
166
+ const localeData = (await (0, load_esm_1.loadEsmModule)(`@angular/common/locales/${locale}`)).default;
160
167
  const dir = localeData[localeData.length - 2];
161
168
  return isString(dir) ? dir : undefined;
162
169
  }
163
170
  catch {
164
- warnings.push(`Locale data for '${lang}' cannot be found. 'dir' attribute will not be set for this locale.`);
171
+ // In some cases certain locales might map to files which are named only with language id.
172
+ // Example: `en-US` -> `en`.
173
+ const [languageId] = locale.split('-', 1);
174
+ if (languageId !== locale) {
175
+ return getLanguageDirectionFromLocales(languageId);
176
+ }
165
177
  }
178
+ return undefined;
166
179
  }
@@ -41,10 +41,7 @@ async function readTsconfig(tsconfigPath, workspaceRoot) {
41
41
  // Load ESM `@angular/compiler-cli` using the TypeScript dynamic import workaround.
42
42
  // Once TypeScript provides support for keeping the dynamic import this workaround can be
43
43
  // changed to a direct dynamic import.
44
- const compilerCliModule = await (0, load_esm_1.loadEsmModule)('@angular/compiler-cli');
45
- // If it is not ESM then the functions needed will be stored in the `default` property.
46
- // TODO_ESM: This can be removed once `@angular/compiler-cli` is ESM only.
47
- const { formatDiagnostics, readConfiguration } = (compilerCliModule.readConfiguration ? compilerCliModule : compilerCliModule.default);
44
+ const { formatDiagnostics, readConfiguration } = await (0, load_esm_1.loadEsmModule)('@angular/compiler-cli');
48
45
  const configResult = readConfiguration(tsConfigFullPath);
49
46
  if (configResult.errors && configResult.errors.length) {
50
47
  throw new Error(formatDiagnostics(configResult.errors));
@@ -47,7 +47,7 @@ const helpers_1 = require("../utils/helpers");
47
47
  // eslint-disable-next-line max-lines-per-function
48
48
  async function getCommonConfig(wco) {
49
49
  var _a, _b;
50
- const { root, projectRoot, buildOptions, tsConfig, projectName, sourceRoot, tsConfigPath } = wco;
50
+ const { root, projectRoot, buildOptions, tsConfig, projectName, sourceRoot, tsConfigPath, scriptTarget, } = wco;
51
51
  const { cache, codeCoverage, crossOrigin = 'none', platform = 'browser', aot = true, codeCoverageExclude = [], main, polyfills, sourceMap: { styles: stylesSourceMap, scripts: scriptsSourceMap, vendor: vendorSourceMap, hidden: hiddenSourceMap, }, optimization: { styles: stylesOptimization, scripts: scriptsOptimization }, commonChunk, vendorChunk, subresourceIntegrity, verbose, poll, webWorkerTsConfig, externalDependencies = [], allowedCommonJsDependencies, bundleDependencies, } = buildOptions;
52
52
  const isPlatformServer = buildOptions.platform === 'server';
53
53
  const extraPlugins = [];
@@ -56,10 +56,7 @@ async function getCommonConfig(wco) {
56
56
  // Load ESM `@angular/compiler-cli` using the TypeScript dynamic import workaround.
57
57
  // Once TypeScript provides support for keeping the dynamic import this workaround can be
58
58
  // changed to a direct dynamic import.
59
- const compilerCliModule = await (0, load_esm_1.loadEsmModule)('@angular/compiler-cli');
60
- // If it is not ESM then the values needed will be stored in the `default` property.
61
- // TODO_ESM: This can be removed once `@angular/compiler-cli` is ESM only.
62
- const { GLOBAL_DEFS_FOR_TERSER, GLOBAL_DEFS_FOR_TERSER_WITH_AOT, VERSION: NG_VERSION, } = (compilerCliModule.GLOBAL_DEFS_FOR_TERSER ? compilerCliModule : compilerCliModule.default);
59
+ const { GLOBAL_DEFS_FOR_TERSER, GLOBAL_DEFS_FOR_TERSER_WITH_AOT, VERSION: NG_VERSION, } = await (0, load_esm_1.loadEsmModule)('@angular/compiler-cli');
63
60
  // determine hashing format
64
61
  const hashFormat = (0, helpers_1.getOutputHashFormat)(buildOptions.outputHashing || 'none');
65
62
  if (buildOptions.progress) {
@@ -93,11 +90,6 @@ async function getCommonConfig(wco) {
93
90
  }
94
91
  }
95
92
  }
96
- if (environment_options_1.profilingEnabled) {
97
- extraPlugins.push(new webpack_2.debug.ProfilingPlugin({
98
- outputPath: path.resolve(root, 'chrome-profiler-events.json'),
99
- }));
100
- }
101
93
  if (allowedCommonJsDependencies) {
102
94
  // When this is not defined it means the builder doesn't support showing common js usages.
103
95
  // When it does it will be an array.
@@ -205,7 +197,7 @@ async function getCommonConfig(wco) {
205
197
  extraMinimizers.push(new plugins_1.JavaScriptOptimizerPlugin({
206
198
  define: buildOptions.aot ? GLOBAL_DEFS_FOR_TERSER_WITH_AOT : GLOBAL_DEFS_FOR_TERSER,
207
199
  sourcemap: scriptsSourceMap,
208
- target: wco.scriptTarget,
200
+ target: scriptTarget,
209
201
  keepNames: !environment_options_1.allowMangle || isPlatformServer,
210
202
  removeLicenses: buildOptions.extractLicenses,
211
203
  advanced: buildOptions.buildOptimizer,
@@ -230,7 +222,7 @@ async function getCommonConfig(wco) {
230
222
  devtool: false,
231
223
  target: [
232
224
  isPlatformServer ? 'node' : 'web',
233
- tsConfig.options.target === typescript_1.ScriptTarget.ES5 ? 'es5' : 'es2015',
225
+ scriptTarget === typescript_1.ScriptTarget.ES5 ? 'es5' : 'es2015',
234
226
  ],
235
227
  profile: buildOptions.statsJson,
236
228
  resolve: {
@@ -238,10 +230,7 @@ async function getCommonConfig(wco) {
238
230
  extensions: ['.ts', '.tsx', '.mjs', '.js'],
239
231
  symlinks: !buildOptions.preserveSymlinks,
240
232
  modules: [tsConfig.options.baseUrl || projectRoot, 'node_modules'],
241
- mainFields: isPlatformServer
242
- ? ['es2015', 'module', 'main']
243
- : ['es2020', 'es2015', 'browser', 'module', 'main'],
244
- conditionNames: isPlatformServer ? ['es2015', '...'] : ['es2020', 'es2015', '...'],
233
+ ...(0, helpers_1.getMainFieldsAndConditionNames)(scriptTarget, isPlatformServer),
245
234
  },
246
235
  resolveLoader: {
247
236
  symlinks: !buildOptions.preserveSymlinks,
@@ -291,6 +280,12 @@ async function getCommonConfig(wco) {
291
280
  }
292
281
  : undefined,
293
282
  rules: [
283
+ {
284
+ test: /\.?(svg|html)$/,
285
+ // Only process HTML and SVG which are known Angular component resources.
286
+ resourceQuery: /\?ngResource/,
287
+ type: 'asset/source',
288
+ },
294
289
  {
295
290
  // Mark files inside `rxjs/add` as containing side effects.
296
291
  // If this is fixed upstream and the fixed version becomes the minimum
@@ -308,7 +303,7 @@ async function getCommonConfig(wco) {
308
303
  loader: require.resolve('../../babel/webpack-loader'),
309
304
  options: {
310
305
  cacheDirectory: (cache.enabled && path.join(cache.path, 'babel-webpack')) || false,
311
- scriptTarget: wco.scriptTarget,
306
+ scriptTarget,
312
307
  aot: buildOptions.aot,
313
308
  optimize: buildOptions.buildOptimizer,
314
309
  instrumentCode: codeCoverage
@@ -30,7 +30,7 @@ exports.buildServePath = exports.getDevServerConfig = void 0;
30
30
  const core_1 = require("@angular-devkit/core");
31
31
  const fs_1 = require("fs");
32
32
  const path_1 = require("path");
33
- const url = __importStar(require("url"));
33
+ const url_1 = require("url");
34
34
  const load_esm_1 = require("../../utils/load-esm");
35
35
  const webpack_browser_config_1 = require("../../utils/webpack-browser-config");
36
36
  const hmr_loader_1 = require("../plugins/hmr/hmr-loader");
@@ -78,7 +78,7 @@ async function getDevServerConfig(wco) {
78
78
  rewrites: [
79
79
  {
80
80
  from: new RegExp(`^(?!${servePath})/.*`),
81
- to: (context) => url.format(context.parsedUrl),
81
+ to: (context) => context.parsedUrl.href,
82
82
  },
83
83
  ],
84
84
  },
@@ -186,7 +186,7 @@ async function addProxyConfig(root, proxyConfig) {
186
186
  // Load the ESM configuration file using the TypeScript dynamic import workaround.
187
187
  // Once TypeScript provides support for keeping the dynamic import this workaround can be
188
188
  // changed to a direct dynamic import.
189
- return (await (0, load_esm_1.loadEsmModule)(url.pathToFileURL(proxyPath))).default;
189
+ return (await (0, load_esm_1.loadEsmModule)((0, url_1.pathToFileURL)(proxyPath))).default;
190
190
  case '.cjs':
191
191
  return require(proxyPath);
192
192
  default:
@@ -200,7 +200,7 @@ async function addProxyConfig(root, proxyConfig) {
200
200
  // Load the ESM configuration file using the TypeScript dynamic import workaround.
201
201
  // Once TypeScript provides support for keeping the dynamic import this workaround can be
202
202
  // changed to a direct dynamic import.
203
- return (await (0, load_esm_1.loadEsmModule)(url.pathToFileURL(proxyPath))).default;
203
+ return (await (0, load_esm_1.loadEsmModule)((0, url_1.pathToFileURL)(proxyPath))).default;
204
204
  }
205
205
  throw e;
206
206
  }
@@ -274,10 +274,8 @@ function getAllowedHostsConfig(options) {
274
274
  function getPublicHostOptions(options, webSocketPath) {
275
275
  let publicHost = options.publicHost;
276
276
  if (publicHost) {
277
- if (!/^\w+:\/\//.test(publicHost)) {
278
- publicHost = `https://${publicHost}`;
279
- }
280
- publicHost = url.parse(publicHost).host;
277
+ const hostWithProtocol = !/^\w+:\/\//.test(publicHost) ? `https://${publicHost}` : publicHost;
278
+ publicHost = new url_1.URL(hostWithProtocol).host;
281
279
  }
282
280
  return `auto://${publicHost || '0.0.0.0:0'}${webSocketPath}`;
283
281
  }
@@ -91,14 +91,16 @@ function getStylesConfig(wco) {
91
91
  wco.logger.warn('Stylus usage is deprecated and will be removed in a future major version. ' +
92
92
  'To opt-out of the deprecated behaviour, please migrate to another stylesheet language.');
93
93
  }
94
- const sassImplementation = new sass_service_1.SassWorkerImplementation();
95
- extraPlugins.push({
96
- apply(compiler) {
97
- compiler.hooks.shutdown.tap('sass-worker', () => {
98
- sassImplementation === null || sassImplementation === void 0 ? void 0 : sassImplementation.close();
99
- });
100
- },
101
- });
94
+ const sassImplementation = getSassImplementation();
95
+ if (sassImplementation instanceof sass_service_1.SassWorkerImplementation) {
96
+ extraPlugins.push({
97
+ apply(compiler) {
98
+ compiler.hooks.shutdown.tap('sass-worker', () => {
99
+ sassImplementation === null || sassImplementation === void 0 ? void 0 : sassImplementation.close();
100
+ });
101
+ },
102
+ });
103
+ }
102
104
  const assetNameTemplate = (0, helpers_1.assetNameTemplateFactory)(hashFormat);
103
105
  const extraPostcssPlugins = [];
104
106
  // Attempt to setup Tailwind CSS
@@ -338,17 +340,17 @@ function getStylesConfig(wco) {
338
340
  // Setup processing rules for global and component styles
339
341
  {
340
342
  oneOf: [
343
+ // Global styles are only defined global styles
344
+ {
345
+ use: globalStyleLoaders,
346
+ include: globalStylePaths,
347
+ resourceQuery: { not: [/\?ngResource/] },
348
+ },
341
349
  // Component styles are all styles except defined global styles
342
350
  {
343
- exclude: globalStylePaths,
344
351
  use: componentStyleLoaders,
345
352
  type: 'asset/source',
346
353
  },
347
- // Global styles are only defined global styles
348
- {
349
- include: globalStylePaths,
350
- use: globalStyleLoaders,
351
- },
352
354
  ],
353
355
  },
354
356
  { use },
@@ -368,3 +370,12 @@ function getStylesConfig(wco) {
368
370
  };
369
371
  }
370
372
  exports.getStylesConfig = getStylesConfig;
373
+ function getSassImplementation() {
374
+ const { webcontainer } = process.versions;
375
+ // When `webcontainer` is a truthy it means that we are running in a StackBlitz webcontainer.
376
+ // `SassWorkerImplementation` uses `receiveMessageOnPort` Node.js `worker_thread` API to ensure sync behavior which is ~2x faster.
377
+ // However, it is non trivial to support this in a webcontainer and while slower we choose to use `dart-sass`
378
+ // which in Webpack uses the slower async path.
379
+ // We should periodically check with StackBlitz folks (Mark Whitfeld / Dominic Elm) to determine if this workaround is still needed.
380
+ return webcontainer ? require('sass') : new sass_service_1.SassWorkerImplementation();
381
+ }
@@ -6,6 +6,7 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  import type { ObjectPattern } from 'copy-webpack-plugin';
9
+ import { ScriptTarget } from 'typescript';
9
10
  import type { Configuration, WebpackOptionsNormalized } from 'webpack';
10
11
  import { AssetPatternClass, ExtraEntryPoint, ExtraEntryPointClass } from '../../builders/browser/schema';
11
12
  import { WebpackConfigOptions } from '../../utils/build-options';
@@ -30,4 +31,5 @@ export declare function assetPatterns(root: string, assets: AssetPatternClass[])
30
31
  export declare function externalizePackages(context: string, request: string | undefined, callback: (error?: Error, result?: string) => void): void;
31
32
  declare type WebpackStatsOptions = Exclude<Configuration['stats'], string | boolean>;
32
33
  export declare function getStatsOptions(verbose?: boolean): WebpackStatsOptions;
34
+ export declare function getMainFieldsAndConditionNames(target: ScriptTarget, platformServer: boolean): Pick<WebpackOptionsNormalized['resolve'], 'mainFields' | 'conditionNames'>;
33
35
  export {};
@@ -29,11 +29,12 @@ 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.getStatsOptions = exports.externalizePackages = exports.assetPatterns = exports.globalScriptsByBundleName = exports.getCacheSettings = exports.getInstrumentationExcludedPaths = exports.assetNameTemplateFactory = exports.normalizeExtraEntryPoints = exports.getOutputHashFormat = void 0;
32
+ exports.getMainFieldsAndConditionNames = exports.getStatsOptions = exports.externalizePackages = exports.assetPatterns = exports.globalScriptsByBundleName = exports.getCacheSettings = exports.getInstrumentationExcludedPaths = exports.assetNameTemplateFactory = exports.normalizeExtraEntryPoints = exports.getOutputHashFormat = void 0;
33
33
  const crypto_1 = require("crypto");
34
34
  const fs_1 = require("fs");
35
35
  const glob_1 = __importDefault(require("glob"));
36
36
  const path = __importStar(require("path"));
37
+ const typescript_1 = require("typescript");
37
38
  function getOutputHashFormat(option, length = 20) {
38
39
  const hashFormats = {
39
40
  none: { chunk: '', extract: '', file: '', script: '' },
@@ -115,6 +116,7 @@ function getCacheSettings(wco, angularVersion) {
115
116
  const packageVersion = require('../../../package.json').version;
116
117
  return {
117
118
  type: 'filesystem',
119
+ profile: wco.buildOptions.verbose,
118
120
  cacheDirectory: path.join(cacheDirectory, 'angular-webpack'),
119
121
  maxMemoryGenerations: 1,
120
122
  // We use the versions and build options as the cache name. The Webpack configurations are too
@@ -265,3 +267,18 @@ function getStatsOptions(verbose = false) {
265
267
  : webpackOutputOptions;
266
268
  }
267
269
  exports.getStatsOptions = getStatsOptions;
270
+ function getMainFieldsAndConditionNames(target, platformServer) {
271
+ const mainFields = platformServer
272
+ ? ['es2015', 'module', 'main']
273
+ : ['es2015', 'browser', 'module', 'main'];
274
+ const conditionNames = ['es2015', '...'];
275
+ if (target >= typescript_1.ScriptTarget.ES2020) {
276
+ mainFields.unshift('es2020');
277
+ conditionNames.unshift('es2020');
278
+ }
279
+ return {
280
+ mainFields,
281
+ conditionNames,
282
+ };
283
+ }
284
+ exports.getMainFieldsAndConditionNames = getMainFieldsAndConditionNames;