@angular-devkit/build-angular 19.1.0-next.0 → 19.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.
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@angular-devkit/build-angular",
3
- "version": "19.1.0-next.0",
3
+ "version": "19.1.0-next.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": "2.3.0",
10
- "@angular-devkit/architect": "0.1901.0-next.0",
11
- "@angular-devkit/build-webpack": "0.1901.0-next.0",
12
- "@angular-devkit/core": "19.1.0-next.0",
13
- "@angular/build": "19.1.0-next.0",
10
+ "@angular-devkit/architect": "0.1901.0-next.2",
11
+ "@angular-devkit/build-webpack": "0.1901.0-next.2",
12
+ "@angular-devkit/core": "19.1.0-next.2",
13
+ "@angular/build": "19.1.0-next.2",
14
14
  "@babel/core": "7.26.0",
15
15
  "@babel/generator": "7.26.3",
16
16
  "@babel/helper-annotate-as-pure": "7.25.9",
@@ -21,7 +21,7 @@
21
21
  "@babel/preset-env": "7.26.0",
22
22
  "@babel/runtime": "7.26.0",
23
23
  "@discoveryjs/json-ext": "0.6.3",
24
- "@ngtools/webpack": "19.1.0-next.0",
24
+ "@ngtools/webpack": "19.1.0-next.2",
25
25
  "@vitejs/plugin-basic-ssl": "1.2.0",
26
26
  "ansi-colors": "4.1.3",
27
27
  "autoprefixer": "10.4.20",
@@ -48,17 +48,17 @@
48
48
  "postcss-loader": "8.1.1",
49
49
  "resolve-url-loader": "5.0.0",
50
50
  "rxjs": "7.8.1",
51
- "sass": "1.82.0",
51
+ "sass": "1.83.0",
52
52
  "sass-loader": "16.0.4",
53
53
  "semver": "7.6.3",
54
54
  "source-map-loader": "5.0.0",
55
55
  "source-map-support": "0.5.21",
56
- "terser": "5.36.0",
56
+ "terser": "5.37.0",
57
57
  "tree-kill": "1.2.2",
58
58
  "tslib": "2.8.1",
59
- "webpack": "5.97.0",
59
+ "webpack": "5.97.1",
60
60
  "webpack-dev-middleware": "7.4.2",
61
- "webpack-dev-server": "5.1.0",
61
+ "webpack-dev-server": "5.2.0",
62
62
  "webpack-merge": "6.0.1",
63
63
  "webpack-subresource-integrity": "5.1.0"
64
64
  },
@@ -70,7 +70,7 @@
70
70
  "@angular/localize": "^19.0.0 || ^19.1.0-next.0",
71
71
  "@angular/platform-server": "^19.0.0 || ^19.1.0-next.0",
72
72
  "@angular/service-worker": "^19.0.0 || ^19.1.0-next.0",
73
- "@angular/ssr": "^19.1.0-next.0",
73
+ "@angular/ssr": "^19.1.0-next.2",
74
74
  "@web/test-runner": "^0.19.0",
75
75
  "browser-sync": "^3.0.2",
76
76
  "jest": "^29.5.0",
@@ -126,7 +126,6 @@
126
126
  "devkit",
127
127
  "sdk"
128
128
  ],
129
- "packageManager": "yarn@4.5.0",
130
129
  "repository": {
131
130
  "type": "git",
132
131
  "url": "https://github.com/angular/angular-cli.git"
@@ -149,5 +148,8 @@
149
148
  "puppeteer": {
150
149
  "built": true
151
150
  }
151
+ },
152
+ "pnpm": {
153
+ "onlyBuiltDependencies": []
152
154
  }
153
155
  }
@@ -316,10 +316,15 @@ function buildWebpackBrowser(options, context, transforms = {}) {
316
316
  })));
317
317
  }));
318
318
  function getLocaleBaseHref(i18n, locale) {
319
- if (i18n.locales[locale] && i18n.locales[locale]?.baseHref !== '') {
320
- return (0, utils_1.urlJoin)(options.baseHref || '', i18n.locales[locale].baseHref ?? `/${locale}/`);
319
+ if (i18n.flatOutput) {
320
+ return undefined;
321
321
  }
322
- return undefined;
322
+ const localeData = i18n.locales[locale];
323
+ if (!localeData) {
324
+ return undefined;
325
+ }
326
+ const baseHrefSuffix = localeData.baseHref ?? localeData.subPath + '/';
327
+ return baseHrefSuffix !== '' ? (0, utils_1.urlJoin)(options.baseHref || '', baseHrefSuffix) : undefined;
323
328
  }
324
329
  }
325
330
  function assertNever(input) {
@@ -33,7 +33,7 @@ async function normalizeOptions(context, projectName, options) {
33
33
  // Target specifier defaults to the current project's build target with no specified configuration
34
34
  const buildTargetSpecifier = options.buildTarget ?? ':';
35
35
  const buildTarget = (0, architect_1.targetFromTargetString)(buildTargetSpecifier, projectName, 'build');
36
- const i18nOptions = (0, private_1.createI18nOptions)(projectMetadata);
36
+ const i18nOptions = (0, private_1.createI18nOptions)(projectMetadata, /** inline */ false, context.logger);
37
37
  // Normalize xliff format extensions
38
38
  let format = options.format;
39
39
  switch (format) {
@@ -103,6 +103,57 @@ class AngularAssetsMiddleware {
103
103
  };
104
104
  }
105
105
  }
106
+ class AngularPolyfillsPlugin {
107
+ static $inject = ['config.files'];
108
+ static NAME = 'angular-polyfills';
109
+ static createPlugin(polyfillsFile, jasmineCleanupFiles) {
110
+ return {
111
+ // This has to be a "reporter" because reporters run _after_ frameworks
112
+ // and karma-jasmine-html-reporter injects additional scripts that may
113
+ // depend on Jasmine but aren't modules - which means that they would run
114
+ // _before_ all module code (including jasmine).
115
+ [`reporter:${AngularPolyfillsPlugin.NAME}`]: [
116
+ 'factory',
117
+ Object.assign((files) => {
118
+ // The correct order is zone.js -> jasmine -> zone.js/testing.
119
+ // Jasmine has to see the patched version of the global `setTimeout`
120
+ // function so it doesn't cache the unpatched version. And /testing
121
+ // needs to see the global `jasmine` object so it can patch it.
122
+ const polyfillsIndex = 0;
123
+ files.splice(polyfillsIndex, 0, polyfillsFile);
124
+ // Insert just before test_main.js.
125
+ const zoneTestingIndex = files.findIndex((f) => {
126
+ if (typeof f === 'string') {
127
+ return false;
128
+ }
129
+ return f.pattern.endsWith('/test_main.js');
130
+ });
131
+ if (zoneTestingIndex === -1) {
132
+ throw new Error('Could not find test entrypoint file.');
133
+ }
134
+ files.splice(zoneTestingIndex, 0, jasmineCleanupFiles);
135
+ // We need to ensure that all files are served as modules, otherwise
136
+ // the order in the files list gets really confusing: Karma doesn't
137
+ // set defer on scripts, so all scripts with type=js will run first,
138
+ // even if type=module files appeared earlier in `files`.
139
+ for (const f of files) {
140
+ if (typeof f === 'string') {
141
+ throw new Error(`Unexpected string-based file: "${f}"`);
142
+ }
143
+ if (f.included === false) {
144
+ // Don't worry about files that aren't included on the initial
145
+ // page load. `type` won't affect them.
146
+ continue;
147
+ }
148
+ if ('js' === (f.type ?? 'js')) {
149
+ f.type = 'module';
150
+ }
151
+ }
152
+ }, AngularPolyfillsPlugin),
153
+ ],
154
+ };
155
+ }
156
+ }
106
157
  function injectKarmaReporter(buildOptions, buildIterator, karmaConfig, subscriber) {
107
158
  const reporterName = 'angular-progress-notifier';
108
159
  class ProgressNotifierReporter {
@@ -199,28 +250,26 @@ async function getProjectSourceRoot(context) {
199
250
  }
200
251
  function normalizePolyfills(polyfills) {
201
252
  if (typeof polyfills === 'string') {
202
- return [polyfills];
253
+ polyfills = [polyfills];
254
+ }
255
+ else if (!polyfills) {
256
+ polyfills = [];
203
257
  }
204
- return polyfills ?? [];
258
+ const jasmineGlobalEntryPoint = '@angular-devkit/build-angular/src/builders/karma/jasmine_global.js';
259
+ const jasmineGlobalCleanupEntrypoint = '@angular-devkit/build-angular/src/builders/karma/jasmine_global_cleanup.js';
260
+ const zoneTestingEntryPoint = 'zone.js/testing';
261
+ const polyfillsExludingZoneTesting = polyfills.filter((p) => p !== zoneTestingEntryPoint);
262
+ return [
263
+ polyfillsExludingZoneTesting.concat([jasmineGlobalEntryPoint]),
264
+ polyfillsExludingZoneTesting.length === polyfills.length
265
+ ? [jasmineGlobalCleanupEntrypoint]
266
+ : [jasmineGlobalCleanupEntrypoint, zoneTestingEntryPoint],
267
+ ];
205
268
  }
206
269
  async function collectEntrypoints(options, context, projectSourceRoot) {
207
270
  // Glob for files to test.
208
271
  const testFiles = await (0, find_tests_1.findTests)(options.include ?? [], options.exclude ?? [], context.workspaceRoot, projectSourceRoot);
209
- const seen = new Set();
210
- return new Map(Array.from(testFiles, (testFile) => {
211
- const relativePath = path
212
- .relative(testFile.startsWith(projectSourceRoot) ? projectSourceRoot : context.workspaceRoot, testFile)
213
- .replace(/^[./]+/, '_')
214
- .replace(/\//g, '-');
215
- let uniqueName = `spec-${path.basename(relativePath, path.extname(relativePath))}`;
216
- let suffix = 2;
217
- while (seen.has(uniqueName)) {
218
- uniqueName = `${relativePath}-${suffix}`;
219
- ++suffix;
220
- }
221
- seen.add(uniqueName);
222
- return [uniqueName, testFile];
223
- }));
272
+ return (0, find_tests_1.getTestEntrypoints)(testFiles, { projectSourceRoot, workspaceRoot: context.workspaceRoot });
224
273
  }
225
274
  async function initializeApplication(options, context, karmaOptions, transforms = {}) {
226
275
  if (transforms.webpackConfiguration) {
@@ -243,6 +292,10 @@ async function initializeApplication(options, context, karmaOptions, transforms
243
292
  const instrumentForCoverage = options.codeCoverage
244
293
  ? createInstrumentationFilter(projectSourceRoot, getInstrumentationExcludedPaths(context.workspaceRoot, options.codeCoverageExclude ?? []))
245
294
  : undefined;
295
+ const [polyfills, jasmineCleanup] = normalizePolyfills(options.polyfills);
296
+ for (let idx = 0; idx < jasmineCleanup.length; ++idx) {
297
+ entryPoints.set(`jasmine-cleanup-${idx}`, jasmineCleanup[idx]);
298
+ }
246
299
  const buildOptions = {
247
300
  assets: options.assets,
248
301
  entryPoints,
@@ -259,7 +312,7 @@ async function initializeApplication(options, context, karmaOptions, transforms
259
312
  },
260
313
  instrumentForCoverage,
261
314
  styles: options.styles,
262
- polyfills: normalizePolyfills(options.polyfills),
315
+ polyfills,
263
316
  webWorkerTsConfig: options.webWorkerTsConfig,
264
317
  watch: options.watch ?? !karmaOptions.singleRun,
265
318
  stylePreprocessorOptions: options.stylePreprocessorOptions,
@@ -274,10 +327,24 @@ async function initializeApplication(options, context, karmaOptions, transforms
274
327
  }
275
328
  // Write test files
276
329
  await writeTestFiles(buildOutput.files, buildOptions.outputPath);
330
+ // We need to add this to the beginning *after* the testing framework has
331
+ // prepended its files.
332
+ const polyfillsFile = {
333
+ pattern: `${outputPath}/polyfills.js`,
334
+ included: true,
335
+ served: true,
336
+ type: 'module',
337
+ watched: false,
338
+ };
339
+ const jasmineCleanupFiles = {
340
+ pattern: `${outputPath}/jasmine-cleanup-*.js`,
341
+ included: true,
342
+ served: true,
343
+ type: 'module',
344
+ watched: false,
345
+ };
277
346
  karmaOptions.files ??= [];
278
347
  karmaOptions.files.push(
279
- // Serve polyfills first.
280
- { pattern: `${outputPath}/polyfills.js`, type: 'module', watched: false },
281
348
  // Serve global setup script.
282
349
  { pattern: `${outputPath}/${mainName}.js`, type: 'module', watched: false },
283
350
  // Serve all source maps.
@@ -319,6 +386,9 @@ async function initializeApplication(options, context, karmaOptions, transforms
319
386
  parsedKarmaConfig.plugins.push(AngularAssetsMiddleware.createPlugin(buildOutput));
320
387
  parsedKarmaConfig.middleware ??= [];
321
388
  parsedKarmaConfig.middleware.push(AngularAssetsMiddleware.NAME);
389
+ parsedKarmaConfig.plugins.push(AngularPolyfillsPlugin.createPlugin(polyfillsFile, jasmineCleanupFiles));
390
+ parsedKarmaConfig.reporters ??= [];
391
+ parsedKarmaConfig.reporters.push(AngularPolyfillsPlugin.NAME);
322
392
  // When using code-coverage, auto-add karma-coverage.
323
393
  // This was done as part of the karma plugin for webpack.
324
394
  if (options.codeCoverage &&
@@ -49,7 +49,7 @@ const webpack_browser_config_1 = require("../../utils/webpack-browser-config");
49
49
  const schema_1 = require("../browser/schema");
50
50
  const find_tests_plugin_1 = require("./find-tests-plugin");
51
51
  function execute(options, context, karmaOptions, transforms = {}) {
52
- return (0, rxjs_1.from)(initializeBrowser(options, context)).pipe((0, rxjs_1.switchMap)(async ([karma, webpackConfig]) => {
52
+ return (0, rxjs_1.from)(initializeBrowser(options, context, transforms.webpackConfiguration)).pipe((0, rxjs_1.switchMap)(async ([karma, webpackConfig]) => {
53
53
  const projectName = context.target?.project;
54
54
  if (!projectName) {
55
55
  throw new Error(`The 'karma' builder requires a target to be specified.`);
@@ -6,3 +6,10 @@
6
6
  * found in the LICENSE file at https://angular.dev/license
7
7
  */
8
8
  export declare function findTests(include: string[], exclude: string[], workspaceRoot: string, projectSourceRoot: string): Promise<string[]>;
9
+ interface TestEntrypointsOptions {
10
+ projectSourceRoot: string;
11
+ workspaceRoot: string;
12
+ }
13
+ /** Generate unique bundle names for a set of test files. */
14
+ export declare function getTestEntrypoints(testFiles: string[], { projectSourceRoot, workspaceRoot }: TestEntrypointsOptions): Map<string, string>;
15
+ export {};
@@ -41,6 +41,7 @@ var __importStar = (this && this.__importStar) || (function () {
41
41
  })();
42
42
  Object.defineProperty(exports, "__esModule", { value: true });
43
43
  exports.findTests = findTests;
44
+ exports.getTestEntrypoints = getTestEntrypoints;
44
45
  const fast_glob_1 = __importStar(require("fast-glob"));
45
46
  const fs_1 = require("fs");
46
47
  const path_1 = require("path");
@@ -51,6 +52,26 @@ async function findTests(include, exclude, workspaceRoot, projectSourceRoot) {
51
52
  // Unique file names
52
53
  return [...new Set(files.flat())];
53
54
  }
55
+ /** Generate unique bundle names for a set of test files. */
56
+ function getTestEntrypoints(testFiles, { projectSourceRoot, workspaceRoot }) {
57
+ const seen = new Set();
58
+ return new Map(Array.from(testFiles, (testFile) => {
59
+ const relativePath = removeRoots(testFile, [projectSourceRoot, workspaceRoot])
60
+ // Strip leading dots and path separators.
61
+ .replace(/^[./\\]+/, '')
62
+ // Replace any path separators with dashes.
63
+ .replace(/[/\\]/g, '-');
64
+ const baseName = `spec-${(0, path_1.basename)(relativePath, (0, path_1.extname)(relativePath))}`;
65
+ let uniqueName = baseName;
66
+ let suffix = 2;
67
+ while (seen.has(uniqueName)) {
68
+ uniqueName = `${baseName}-${suffix}`.replace(/([^\w](?:spec|test))-([\d]+)$/, '-$2$1');
69
+ ++suffix;
70
+ }
71
+ seen.add(uniqueName);
72
+ return [uniqueName, testFile];
73
+ }));
74
+ }
54
75
  const normalizePath = (path) => path.replace(/\\/g, '/');
55
76
  const removeLeadingSlash = (pattern) => {
56
77
  if (pattern.charAt(0) === '/') {
@@ -64,6 +85,14 @@ const removeRelativeRoot = (path, root) => {
64
85
  }
65
86
  return path;
66
87
  };
88
+ function removeRoots(path, roots) {
89
+ for (const root of roots) {
90
+ if (path.startsWith(root)) {
91
+ return path.substring(root.length);
92
+ }
93
+ }
94
+ return (0, path_1.basename)(path);
95
+ }
67
96
  async function findMatchingTests(pattern, ignore, workspaceRoot, projectSourceRoot) {
68
97
  // normalize pattern, glob lib only accepts forward slashes
69
98
  let normalizedPattern = normalizePath(pattern);
@@ -0,0 +1,18 @@
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.dev/license
7
+ */
8
+
9
+ // See: https://github.com/jasmine/jasmine/issues/2015
10
+ (function () {
11
+ 'use strict';
12
+
13
+ // jasmine will ignore `window` unless it returns this specific (but uncommon)
14
+ // value from toString().
15
+ window.toString = function () {
16
+ return '[object GjsGlobal]';
17
+ };
18
+ })();
@@ -0,0 +1,14 @@
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.dev/license
7
+ */
8
+
9
+ // See: https://github.com/jasmine/jasmine/issues/2015
10
+ (function () {
11
+ 'use strict';
12
+
13
+ delete window.toString;
14
+ })();
@@ -30,7 +30,7 @@ async function configureI18nBuild(context, options) {
30
30
  const buildOptions = { ...options };
31
31
  const tsConfig = await (0, read_tsconfig_1.readTsconfig)(buildOptions.tsConfig, context.workspaceRoot);
32
32
  const metadata = await context.getProjectMetadata(context.target);
33
- const i18n = (0, private_1.createI18nOptions)(metadata, buildOptions.localize);
33
+ const i18n = (0, private_1.createI18nOptions)(metadata, buildOptions.localize, context.logger);
34
34
  // No additional processing needed if no inlining requested and no source locale defined.
35
35
  if (!i18n.shouldInline && !i18n.hasDefinedSourceLocale) {
36
36
  return { buildOptions, i18n };
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.normalizeCacheOptions = normalizeCacheOptions;
11
11
  const node_path_1 = require("node:path");
12
12
  /** Version placeholder is replaced during the build process with actual package version */
13
- const VERSION = '19.1.0-next.0';
13
+ const VERSION = '19.1.0-next.2';
14
14
  function hasCacheMetadata(value) {
15
15
  return (!!value &&
16
16
  typeof value === 'object' &&
@@ -14,7 +14,7 @@ function ensureOutputPaths(baseOutputPath, i18n) {
14
14
  const outputPaths = i18n.shouldInline
15
15
  ? [...i18n.inlineLocales].map((l) => [
16
16
  l,
17
- i18n.flatOutput ? baseOutputPath : (0, path_1.join)(baseOutputPath, l),
17
+ i18n.flatOutput ? baseOutputPath : (0, path_1.join)(baseOutputPath, i18n.locales[l].subPath),
18
18
  ])
19
19
  : [['', baseOutputPath]];
20
20
  for (const [, outputPath] of outputPaths) {
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "types": ["node"]
5
+ }
6
+ }