@angular/build 19.2.0-next.2 → 19.2.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 (36) hide show
  1. package/builders.json +5 -0
  2. package/package.json +14 -9
  3. package/src/builders/application/execute-build.js +0 -4
  4. package/src/builders/application/options.d.ts +5 -1
  5. package/src/builders/application/options.js +9 -1
  6. package/src/builders/dev-server/vite-server.js +11 -0
  7. package/src/builders/karma/application_builder.d.ts +15 -0
  8. package/src/builders/karma/application_builder.js +490 -0
  9. package/src/builders/karma/find-tests.d.ts +15 -0
  10. package/src/builders/karma/find-tests.js +144 -0
  11. package/src/builders/karma/index.d.ts +23 -0
  12. package/src/builders/karma/index.js +135 -0
  13. package/src/builders/karma/polyfills/init_sourcemaps.js +10 -0
  14. package/src/builders/karma/polyfills/init_test_bed.js +19 -0
  15. package/src/builders/karma/polyfills/jasmine_global.js +18 -0
  16. package/src/builders/karma/polyfills/jasmine_global_cleanup.js +14 -0
  17. package/src/builders/karma/schema.d.ts +248 -0
  18. package/src/builders/karma/schema.js +15 -0
  19. package/src/builders/karma/schema.json +347 -0
  20. package/src/private.d.ts +2 -0
  21. package/src/private.js +6 -1
  22. package/src/tools/esbuild/angular/compiler-plugin.js +1 -1
  23. package/src/tools/esbuild/index-html-generator.js +1 -8
  24. package/src/tools/vite/middlewares/html-fallback-middleware.js +2 -1
  25. package/src/utils/error.js +2 -2
  26. package/src/utils/index-file/auto-csp.js +1 -1
  27. package/src/utils/index-file/index-html-generator.js +3 -2
  28. package/src/utils/index-file/inline-critical-css.d.ts +1 -0
  29. package/src/utils/index-file/inline-critical-css.js +11 -7
  30. package/src/utils/load-translations.js +3 -3
  31. package/src/utils/normalize-asset-patterns.js +3 -3
  32. package/src/utils/normalize-cache.js +1 -1
  33. package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.js +1 -2
  34. package/src/utils/server-rendering/render-worker.js +2 -2
  35. package/src/utils/server-rendering/routes-extractor-worker.js +2 -2
  36. package/src/utils/service-worker.js +2 -2
@@ -0,0 +1,347 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "title": "Karma Target",
4
+ "description": "Karma target options for Build Facade.",
5
+ "type": "object",
6
+ "properties": {
7
+ "main": {
8
+ "type": "string",
9
+ "description": "The name of the main entry-point file."
10
+ },
11
+ "tsConfig": {
12
+ "type": "string",
13
+ "description": "The name of the TypeScript configuration file."
14
+ },
15
+ "karmaConfig": {
16
+ "type": "string",
17
+ "description": "The name of the Karma configuration file."
18
+ },
19
+ "polyfills": {
20
+ "description": "A list of polyfills to include in the build. Can be a full path for a file, relative to the current workspace or module specifier. Example: 'zone.js'.",
21
+ "type": "array",
22
+ "items": {
23
+ "type": "string",
24
+ "uniqueItems": true
25
+ },
26
+ "default": []
27
+ },
28
+ "assets": {
29
+ "type": "array",
30
+ "description": "List of static application assets.",
31
+ "default": [],
32
+ "items": {
33
+ "$ref": "#/definitions/assetPattern"
34
+ }
35
+ },
36
+ "scripts": {
37
+ "description": "Global scripts to be included in the build.",
38
+ "type": "array",
39
+ "default": [],
40
+ "items": {
41
+ "oneOf": [
42
+ {
43
+ "type": "object",
44
+ "properties": {
45
+ "input": {
46
+ "type": "string",
47
+ "description": "The file to include.",
48
+ "pattern": "\\.[cm]?jsx?$"
49
+ },
50
+ "bundleName": {
51
+ "type": "string",
52
+ "pattern": "^[\\w\\-.]*$",
53
+ "description": "The bundle name for this extra entry point."
54
+ },
55
+ "inject": {
56
+ "type": "boolean",
57
+ "description": "If the bundle will be referenced in the HTML file.",
58
+ "default": true
59
+ }
60
+ },
61
+ "additionalProperties": false,
62
+ "required": ["input"]
63
+ },
64
+ {
65
+ "type": "string",
66
+ "description": "The file to include.",
67
+ "pattern": "\\.[cm]?jsx?$"
68
+ }
69
+ ]
70
+ }
71
+ },
72
+ "styles": {
73
+ "description": "Global styles to be included in the build.",
74
+ "type": "array",
75
+ "default": [],
76
+ "items": {
77
+ "oneOf": [
78
+ {
79
+ "type": "object",
80
+ "properties": {
81
+ "input": {
82
+ "type": "string",
83
+ "description": "The file to include.",
84
+ "pattern": "\\.(?:css|scss|sass|less)$"
85
+ },
86
+ "bundleName": {
87
+ "type": "string",
88
+ "pattern": "^[\\w\\-.]*$",
89
+ "description": "The bundle name for this extra entry point."
90
+ },
91
+ "inject": {
92
+ "type": "boolean",
93
+ "description": "If the bundle will be referenced in the HTML file.",
94
+ "default": true
95
+ }
96
+ },
97
+ "additionalProperties": false,
98
+ "required": ["input"]
99
+ },
100
+ {
101
+ "type": "string",
102
+ "description": "The file to include.",
103
+ "pattern": "\\.(?:css|scss|sass|less)$"
104
+ }
105
+ ]
106
+ }
107
+ },
108
+ "inlineStyleLanguage": {
109
+ "description": "The stylesheet language to use for the application's inline component styles.",
110
+ "type": "string",
111
+ "default": "css",
112
+ "enum": ["css", "less", "sass", "scss"]
113
+ },
114
+ "stylePreprocessorOptions": {
115
+ "description": "Options to pass to style preprocessors.",
116
+ "type": "object",
117
+ "properties": {
118
+ "includePaths": {
119
+ "description": "Paths to include. Paths will be resolved to workspace root.",
120
+ "type": "array",
121
+ "items": {
122
+ "type": "string"
123
+ },
124
+ "default": []
125
+ },
126
+ "sass": {
127
+ "description": "Options to pass to the sass preprocessor.",
128
+ "type": "object",
129
+ "properties": {
130
+ "fatalDeprecations": {
131
+ "description": "A set of deprecations to treat as fatal. If a deprecation warning of any provided type is encountered during compilation, the compiler will error instead. If a Version is provided, then all deprecations that were active in that compiler version will be treated as fatal.",
132
+ "type": "array",
133
+ "items": {
134
+ "type": "string"
135
+ }
136
+ },
137
+ "silenceDeprecations": {
138
+ "description": " A set of active deprecations to ignore. If a deprecation warning of any provided type is encountered during compilation, the compiler will ignore it instead.",
139
+ "type": "array",
140
+ "items": {
141
+ "type": "string"
142
+ }
143
+ },
144
+ "futureDeprecations": {
145
+ "description": "A set of future deprecations to opt into early. Future deprecations passed here will be treated as active by the compiler, emitting warnings as necessary.",
146
+ "type": "array",
147
+ "items": {
148
+ "type": "string"
149
+ }
150
+ }
151
+ },
152
+ "additionalProperties": false
153
+ }
154
+ },
155
+ "additionalProperties": false
156
+ },
157
+ "externalDependencies": {
158
+ "description": "Exclude the listed external dependencies from being bundled into the bundle. Instead, the created bundle relies on these dependencies to be available during runtime.",
159
+ "type": "array",
160
+ "items": {
161
+ "type": "string"
162
+ },
163
+ "default": []
164
+ },
165
+ "loader": {
166
+ "description": "Defines the type of loader to use with a specified file extension when used with a JavaScript `import`. `text` inlines the content as a string; `binary` inlines the content as a Uint8Array; `file` emits the file and provides the runtime location of the file; `empty` considers the content to be empty and not include it in bundles.",
167
+ "type": "object",
168
+ "patternProperties": {
169
+ "^\\.\\S+$": { "enum": ["text", "binary", "file", "empty"] }
170
+ }
171
+ },
172
+ "define": {
173
+ "description": "Defines global identifiers that will be replaced with a specified constant value when found in any JavaScript or TypeScript code including libraries. The value will be used directly. String values must be put in quotes. Identifiers within Angular metadata such as Component Decorators will not be replaced.",
174
+ "type": "object",
175
+ "additionalProperties": {
176
+ "type": "string"
177
+ }
178
+ },
179
+ "include": {
180
+ "type": "array",
181
+ "items": {
182
+ "type": "string"
183
+ },
184
+ "default": ["**/*.spec.ts"],
185
+ "description": "Globs of files to include, relative to project root. \nThere are 2 special cases:\n - when a path to directory is provided, all spec files ending \".spec.@(ts|tsx)\" will be included\n - when a path to a file is provided, and a matching spec file exists it will be included instead."
186
+ },
187
+ "exclude": {
188
+ "type": "array",
189
+ "items": {
190
+ "type": "string"
191
+ },
192
+ "default": [],
193
+ "description": "Globs of files to exclude, relative to the project root."
194
+ },
195
+ "sourceMap": {
196
+ "description": "Output source maps for scripts and styles. For more information, see https://angular.dev/reference/configs/workspace-config#source-map-configuration.",
197
+ "default": true,
198
+ "oneOf": [
199
+ {
200
+ "type": "object",
201
+ "properties": {
202
+ "scripts": {
203
+ "type": "boolean",
204
+ "description": "Output source maps for all scripts.",
205
+ "default": true
206
+ },
207
+ "styles": {
208
+ "type": "boolean",
209
+ "description": "Output source maps for all styles.",
210
+ "default": true
211
+ },
212
+ "vendor": {
213
+ "type": "boolean",
214
+ "description": "Resolve vendor packages source maps.",
215
+ "default": false
216
+ }
217
+ },
218
+ "additionalProperties": false
219
+ },
220
+ {
221
+ "type": "boolean"
222
+ }
223
+ ]
224
+ },
225
+ "progress": {
226
+ "type": "boolean",
227
+ "description": "Log progress to the console while building.",
228
+ "default": true
229
+ },
230
+ "watch": {
231
+ "type": "boolean",
232
+ "description": "Run build when files change."
233
+ },
234
+ "poll": {
235
+ "type": "number",
236
+ "description": "Enable and define the file watching poll time period in milliseconds."
237
+ },
238
+ "preserveSymlinks": {
239
+ "type": "boolean",
240
+ "description": "Do not use the real path when resolving modules. If unset then will default to `true` if NodeJS option --preserve-symlinks is set."
241
+ },
242
+ "browsers": {
243
+ "description": "Override which browsers tests are run against. Set to `false` to not use any browser.",
244
+ "oneOf": [
245
+ {
246
+ "type": "string",
247
+ "description": "A comma seperate list of browsers to run tests against."
248
+ },
249
+ {
250
+ "const": false,
251
+ "type": "boolean",
252
+ "description": "Does use run tests against a browser."
253
+ }
254
+ ]
255
+ },
256
+ "codeCoverage": {
257
+ "type": "boolean",
258
+ "description": "Output a code coverage report.",
259
+ "default": false
260
+ },
261
+ "codeCoverageExclude": {
262
+ "type": "array",
263
+ "description": "Globs to exclude from code coverage.",
264
+ "items": {
265
+ "type": "string"
266
+ },
267
+ "default": []
268
+ },
269
+ "fileReplacements": {
270
+ "description": "Replace compilation source files with other compilation source files in the build.",
271
+ "type": "array",
272
+ "items": {
273
+ "$ref": "#/definitions/fileReplacement"
274
+ },
275
+ "default": []
276
+ },
277
+ "reporters": {
278
+ "type": "array",
279
+ "description": "Karma reporters to use. Directly passed to the karma runner.",
280
+ "items": {
281
+ "type": "string"
282
+ }
283
+ },
284
+ "webWorkerTsConfig": {
285
+ "type": "string",
286
+ "description": "TypeScript configuration for Web Worker modules."
287
+ },
288
+ "aot": {
289
+ "type": "boolean",
290
+ "description": "Run tests using Ahead of Time compilation.",
291
+ "default": false
292
+ }
293
+ },
294
+ "additionalProperties": false,
295
+ "required": ["tsConfig"],
296
+ "definitions": {
297
+ "assetPattern": {
298
+ "oneOf": [
299
+ {
300
+ "type": "object",
301
+ "properties": {
302
+ "glob": {
303
+ "type": "string",
304
+ "description": "The pattern to match."
305
+ },
306
+ "input": {
307
+ "type": "string",
308
+ "description": "The input directory path in which to apply 'glob'. Defaults to the project root."
309
+ },
310
+ "output": {
311
+ "type": "string",
312
+ "default": "",
313
+ "description": "Absolute path within the output."
314
+ },
315
+ "ignore": {
316
+ "description": "An array of globs to ignore.",
317
+ "type": "array",
318
+ "items": {
319
+ "type": "string"
320
+ }
321
+ }
322
+ },
323
+ "additionalProperties": false,
324
+ "required": ["glob", "input"]
325
+ },
326
+ {
327
+ "type": "string"
328
+ }
329
+ ]
330
+ },
331
+ "fileReplacement": {
332
+ "type": "object",
333
+ "properties": {
334
+ "replace": {
335
+ "type": "string",
336
+ "pattern": "\\.(([cm]?[jt])sx?|json)$"
337
+ },
338
+ "with": {
339
+ "type": "string",
340
+ "pattern": "\\.(([cm]?[jt])sx?|json)$"
341
+ }
342
+ },
343
+ "additionalProperties": false,
344
+ "required": ["replace", "with"]
345
+ }
346
+ }
347
+ }
package/src/private.d.ts CHANGED
@@ -11,6 +11,7 @@ export { buildApplicationInternal } from './builders/application';
11
11
  export type { ApplicationBuilderInternalOptions } from './builders/application/options';
12
12
  export { type Result, type ResultFile, ResultKind } from './builders/application/results';
13
13
  export { serveWithVite } from './builders/dev-server/vite-server';
14
+ export { execute as executeKarmaInternal } from './builders/karma/application_builder';
14
15
  export * from './tools/babel/plugins';
15
16
  export type { ExternalResultMetadata } from './tools/esbuild/bundler-execution-result';
16
17
  export { emitFilesToDisk } from './tools/esbuild/utils';
@@ -39,3 +40,4 @@ export { augmentAppWithServiceWorker } from './utils/service-worker';
39
40
  export { type BundleStats, generateBuildStatsTable } from './utils/stats-table';
40
41
  export { getSupportedBrowsers } from './utils/supported-browsers';
41
42
  export { assertCompatibleAngularVersion } from './utils/version';
43
+ export { findTests, getTestEntrypoints } from './builders/karma/find-tests';
package/src/private.js CHANGED
@@ -21,7 +21,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
21
21
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
22
22
  };
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.assertCompatibleAngularVersion = exports.getSupportedBrowsers = exports.generateBuildStatsTable = exports.augmentAppWithServiceWorker = exports.purgeStaleBuildCache = exports.createTranslationLoader = exports.loadProxyConfiguration = exports.InlineCriticalCssProcessor = exports.IndexHtmlGenerator = exports.loadTranslations = exports.createI18nOptions = exports.deleteOutputDir = exports.checkPort = exports.JavaScriptTransformer = exports.createJitResourceTransformer = exports.SourceFileCache = exports.SassWorkerImplementation = exports.transformSupportedBrowsersToTargets = exports.emitFilesToDisk = exports.serveWithVite = exports.ResultKind = exports.buildApplicationInternal = void 0;
24
+ exports.getTestEntrypoints = exports.findTests = exports.assertCompatibleAngularVersion = exports.getSupportedBrowsers = exports.generateBuildStatsTable = exports.augmentAppWithServiceWorker = exports.purgeStaleBuildCache = exports.createTranslationLoader = exports.loadProxyConfiguration = exports.InlineCriticalCssProcessor = exports.IndexHtmlGenerator = exports.loadTranslations = exports.createI18nOptions = exports.deleteOutputDir = exports.checkPort = exports.JavaScriptTransformer = exports.createJitResourceTransformer = exports.SourceFileCache = exports.SassWorkerImplementation = exports.transformSupportedBrowsersToTargets = exports.emitFilesToDisk = exports.executeKarmaInternal = exports.serveWithVite = exports.ResultKind = exports.buildApplicationInternal = void 0;
25
25
  exports.createCompilerPlugin = createCompilerPlugin;
26
26
  /**
27
27
  * @fileoverview
@@ -39,6 +39,8 @@ var results_1 = require("./builders/application/results");
39
39
  Object.defineProperty(exports, "ResultKind", { enumerable: true, get: function () { return results_1.ResultKind; } });
40
40
  var vite_server_1 = require("./builders/dev-server/vite-server");
41
41
  Object.defineProperty(exports, "serveWithVite", { enumerable: true, get: function () { return vite_server_1.serveWithVite; } });
42
+ var application_builder_1 = require("./builders/karma/application_builder");
43
+ Object.defineProperty(exports, "executeKarmaInternal", { enumerable: true, get: function () { return application_builder_1.execute; } });
42
44
  // Tools
43
45
  __exportStar(require("./tools/babel/plugins"), exports);
44
46
  var utils_1 = require("./tools/esbuild/utils");
@@ -85,3 +87,6 @@ var supported_browsers_1 = require("./utils/supported-browsers");
85
87
  Object.defineProperty(exports, "getSupportedBrowsers", { enumerable: true, get: function () { return supported_browsers_1.getSupportedBrowsers; } });
86
88
  var version_1 = require("./utils/version");
87
89
  Object.defineProperty(exports, "assertCompatibleAngularVersion", { enumerable: true, get: function () { return version_1.assertCompatibleAngularVersion; } });
90
+ var find_tests_1 = require("./builders/karma/find-tests");
91
+ Object.defineProperty(exports, "findTests", { enumerable: true, get: function () { return find_tests_1.findTests; } });
92
+ Object.defineProperty(exports, "getTestEntrypoints", { enumerable: true, get: function () { return find_tests_1.getTestEntrypoints; } });
@@ -403,7 +403,7 @@ function createCompilerPlugin(pluginOptions, compilationOrFactory, stylesheetBun
403
403
  const replacement = pluginOptions.fileReplacements?.[path.normalize(args.path)];
404
404
  if (replacement) {
405
405
  return {
406
- contents: await Promise.resolve().then(() => __importStar(require('fs/promises'))).then(({ readFile }) => readFile(path.normalize(replacement))),
406
+ contents: await Promise.resolve().then(() => __importStar(require('node:fs/promises'))).then(({ readFile }) => readFile(path.normalize(replacement))),
407
407
  loader: 'json',
408
408
  watchFiles: [replacement],
409
409
  };
@@ -59,13 +59,6 @@ async function generateIndexHtml(initialFiles, outputFiles, buildOptions, lang)
59
59
  }
60
60
  throw new Error(`Output file does not exist: ${relativefilePath}`);
61
61
  };
62
- // Read the Auto CSP options.
63
- const autoCsp = buildOptions.security?.autoCsp;
64
- const autoCspOptions = autoCsp === true
65
- ? { unsafeEval: false }
66
- : autoCsp
67
- ? { unsafeEval: !!autoCsp.unsafeEval }
68
- : undefined;
69
62
  // Create an index HTML generator that reads from the in-memory output files
70
63
  const indexHtmlGenerator = new index_html_generator_1.IndexHtmlGenerator({
71
64
  indexPath: indexHtmlOptions.input,
@@ -78,7 +71,7 @@ async function generateIndexHtml(initialFiles, outputFiles, buildOptions, lang)
78
71
  generateDedicatedSSRContent: !!(buildOptions.ssrOptions ||
79
72
  buildOptions.prerenderOptions ||
80
73
  buildOptions.appShellOptions),
81
- autoCsp: autoCspOptions,
74
+ autoCsp: buildOptions.security.autoCsp,
82
75
  });
83
76
  indexHtmlGenerator.readAsset = readAsset;
84
77
  return indexHtmlGenerator.process({
@@ -20,7 +20,8 @@ function angularHtmlFallbackMiddleware(req, _res, next) {
20
20
  }
21
21
  if (req.url) {
22
22
  const mimeType = (0, utils_1.lookupMimeTypeFromRequest)(req.url);
23
- if (mimeType === 'text/html' || mimeType === 'application/xhtml+xml') {
23
+ if ((mimeType === 'text/html' || mimeType === 'application/xhtml+xml') &&
24
+ !/^\/index\.(?:csr\.)?html/.test(req.url)) {
24
25
  // eslint-disable-next-line no-console
25
26
  console.warn(`Request for HTML file "${req.url}" was received but no asset found. Asset may be missing from build.`);
26
27
  }
@@ -11,10 +11,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.assertIsError = assertIsError;
14
- const assert_1 = __importDefault(require("assert"));
14
+ const node_assert_1 = __importDefault(require("node:assert"));
15
15
  function assertIsError(value) {
16
16
  const isError = value instanceof Error ||
17
17
  // The following is needing to identify errors coming from RxJs.
18
18
  (typeof value === 'object' && value && 'name' in value && 'message' in value);
19
- (0, assert_1.default)(isError, 'catch clause variable is not an Error instance');
19
+ (0, node_assert_1.default)(isError, 'catch clause variable is not an Error instance');
20
20
  }
@@ -112,7 +112,7 @@ async function autoCsp(html, unsafeEval = false) {
112
112
  rewriter.emitRaw(`<script>${loaderScript}</script>`);
113
113
  scriptContent = [];
114
114
  }
115
- rewriter.on('startTag', (tag, html) => {
115
+ rewriter.on('startTag', (tag) => {
116
116
  if (tag.tagName === 'script') {
117
117
  openedScriptTag = tag;
118
118
  const src = getScriptAttributeValue(tag, 'src');
@@ -32,7 +32,7 @@ class IndexHtmlGenerator {
32
32
  this.plugins = [augmentIndexHtmlPlugin(this), ...extraCommonPlugins, postTransformPlugin(this)];
33
33
  // CSR plugins
34
34
  if (options?.optimization?.styles?.inlineCritical) {
35
- this.csrPlugins.push(inlineCriticalCssPlugin(this));
35
+ this.csrPlugins.push(inlineCriticalCssPlugin(this, !!options.autoCsp));
36
36
  }
37
37
  this.csrPlugins.push(addNoncePlugin());
38
38
  // SSR plugins
@@ -127,11 +127,12 @@ function inlineFontsPlugin({ options }) {
127
127
  });
128
128
  return async (html) => inlineFontsProcessor.process(html);
129
129
  }
130
- function inlineCriticalCssPlugin(generator) {
130
+ function inlineCriticalCssPlugin(generator, autoCsp) {
131
131
  const inlineCriticalCssProcessor = new inline_critical_css_1.InlineCriticalCssProcessor({
132
132
  minify: generator.options.optimization?.styles.minify,
133
133
  deployUrl: generator.options.deployUrl,
134
134
  readAsset: (filePath) => generator.readAsset(filePath),
135
+ autoCsp,
135
136
  });
136
137
  return async (html, options) => inlineCriticalCssProcessor.process(html, { outputPath: options.outputPath });
137
138
  }
@@ -12,6 +12,7 @@ export interface InlineCriticalCssProcessorOptions {
12
12
  minify?: boolean;
13
13
  deployUrl?: string;
14
14
  readAsset?: (path: string) => Promise<string>;
15
+ autoCsp?: boolean;
15
16
  }
16
17
  export declare class InlineCriticalCssProcessor {
17
18
  protected readonly options: InlineCriticalCssProcessorOptions;
@@ -113,7 +113,7 @@ class BeastiesExtended extends BeastiesBase {
113
113
  }
114
114
  const returnValue = await super.embedLinkedStylesheet(link, document);
115
115
  const cspNonce = this.findCspNonce(document);
116
- if (cspNonce) {
116
+ if (cspNonce || this.optionsExtended.autoCsp) {
117
117
  const beastiesMedia = link.getAttribute('onload')?.match(MEDIA_SET_HANDLER_PATTERN);
118
118
  if (beastiesMedia) {
119
119
  // If there's a Beasties-generated `onload` handler and the file has an Angular CSP nonce,
@@ -128,11 +128,13 @@ class BeastiesExtended extends BeastiesBase {
128
128
  // a way of doing that at the moment so we fall back to doing it any time a `link` tag is
129
129
  // inserted. We mitigate it by only iterating the direct children of the `<head>` which
130
130
  // should be pretty shallow.
131
- document.head.children.forEach((child) => {
132
- if (child.tagName === 'style' && !child.hasAttribute('nonce')) {
133
- child.setAttribute('nonce', cspNonce);
134
- }
135
- });
131
+ if (cspNonce) {
132
+ document.head.children.forEach((child) => {
133
+ if (child.tagName === 'style' && !child.hasAttribute('nonce')) {
134
+ child.setAttribute('nonce', cspNonce);
135
+ }
136
+ });
137
+ }
136
138
  }
137
139
  return returnValue;
138
140
  }
@@ -159,8 +161,10 @@ class BeastiesExtended extends BeastiesBase {
159
161
  return;
160
162
  }
161
163
  const script = document.createElement('script');
162
- script.setAttribute('nonce', nonce);
163
164
  script.textContent = LINK_LOAD_SCRIPT_CONTENT;
165
+ if (nonce) {
166
+ script.setAttribute('nonce', nonce);
167
+ }
164
168
  // Prepend the script to the head since it needs to
165
169
  // run as early as possible, before the `link` tags.
166
170
  document.head.insertBefore(script, link);
@@ -41,8 +41,8 @@ var __importStar = (this && this.__importStar) || (function () {
41
41
  })();
42
42
  Object.defineProperty(exports, "__esModule", { value: true });
43
43
  exports.createTranslationLoader = createTranslationLoader;
44
- const crypto_1 = require("crypto");
45
- const fs = __importStar(require("fs"));
44
+ const node_crypto_1 = require("node:crypto");
45
+ const fs = __importStar(require("node:fs"));
46
46
  const load_esm_1 = require("./load-esm");
47
47
  async function createTranslationLoader() {
48
48
  const { parsers, diagnostics } = await importParsers();
@@ -55,7 +55,7 @@ async function createTranslationLoader() {
55
55
  // Types don't overlap here so we need to use any.
56
56
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
57
57
  const { locale, translations } = parser.parse(path, content, analysis.hint);
58
- const integrity = 'sha256-' + (0, crypto_1.createHash)('sha256').update(content).digest('base64');
58
+ const integrity = 'sha256-' + (0, node_crypto_1.createHash)('sha256').update(content).digest('base64');
59
59
  return { format, locale, translations, diagnostics, integrity };
60
60
  }
61
61
  else {
@@ -45,9 +45,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
45
45
  Object.defineProperty(exports, "__esModule", { value: true });
46
46
  exports.MissingAssetSourceRootException = void 0;
47
47
  exports.normalizeAssetPatterns = normalizeAssetPatterns;
48
- const fs_1 = require("fs");
49
48
  const node_assert_1 = __importDefault(require("node:assert"));
50
- const path = __importStar(require("path"));
49
+ const node_fs_1 = require("node:fs");
50
+ const path = __importStar(require("node:path"));
51
51
  class MissingAssetSourceRootException extends Error {
52
52
  constructor(path) {
53
53
  super(`The ${path} asset path must start with the project source root.`);
@@ -73,7 +73,7 @@ function normalizeAssetPatterns(assetPatterns, workspaceRoot, projectRoot, proje
73
73
  let glob, input;
74
74
  let isDirectory = false;
75
75
  try {
76
- isDirectory = (0, fs_1.statSync)(resolvedAssetPath).isDirectory();
76
+ isDirectory = (0, node_fs_1.statSync)(resolvedAssetPath).isDirectory();
77
77
  }
78
78
  catch {
79
79
  isDirectory = true;
@@ -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.2.0-next.2';
13
+ const VERSION = '19.2.0';
14
14
  function hasCacheMetadata(value) {
15
15
  return (!!value &&
16
16
  typeof value === 'object' &&
@@ -17,7 +17,6 @@ const node_assert_1 = __importDefault(require("node:assert"));
17
17
  const node_crypto_1 = require("node:crypto");
18
18
  const node_path_1 = require("node:path");
19
19
  const node_url_1 = require("node:url");
20
- const url_1 = require("url");
21
20
  const javascript_transformer_1 = require("../../../tools/esbuild/javascript-transformer");
22
21
  /**
23
22
  * @note For some unknown reason, setting `globalThis.ngServerMode = true` does not work when using ESM loader hooks.
@@ -110,7 +109,7 @@ async function load(url, context, nextLoad) {
110
109
  // Only module files potentially require transformation. Angular libraries that would
111
110
  // need linking are ESM only.
112
111
  if (format === 'module' && isFileProtocol(url)) {
113
- const filePath = (0, url_1.fileURLToPath)(url);
112
+ const filePath = (0, node_url_1.fileURLToPath)(url);
114
113
  let source = await javascriptTransformer.transformFile(filePath);
115
114
  if (filePath.includes('@angular/')) {
116
115
  // Prepend 'var ngServerMode=true;' to the source.
@@ -7,14 +7,14 @@
7
7
  * found in the LICENSE file at https://angular.dev/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- const worker_threads_1 = require("worker_threads");
10
+ const node_worker_threads_1 = require("node:worker_threads");
11
11
  const fetch_patch_1 = require("./fetch-patch");
12
12
  const launch_server_1 = require("./launch-server");
13
13
  const load_esm_from_memory_1 = require("./load-esm-from-memory");
14
14
  /**
15
15
  * This is passed as workerData when setting up the worker via the `piscina` package.
16
16
  */
17
- const { outputMode, hasSsrEntry } = worker_threads_1.workerData;
17
+ const { outputMode, hasSsrEntry } = node_worker_threads_1.workerData;
18
18
  let serverURL = launch_server_1.DEFAULT_URL;
19
19
  /**
20
20
  * Renders each route in routes and writes them to <outputPath>/<route>/index.html.
@@ -7,7 +7,7 @@
7
7
  * found in the LICENSE file at https://angular.dev/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- const worker_threads_1 = require("worker_threads");
10
+ const node_worker_threads_1 = require("node:worker_threads");
11
11
  const schema_1 = require("../../builders/application/schema");
12
12
  const fetch_patch_1 = require("./fetch-patch");
13
13
  const launch_server_1 = require("./launch-server");
@@ -15,7 +15,7 @@ const load_esm_from_memory_1 = require("./load-esm-from-memory");
15
15
  /**
16
16
  * This is passed as workerData when setting up the worker via the `piscina` package.
17
17
  */
18
- const { outputMode, hasSsrEntry } = worker_threads_1.workerData;
18
+ const { outputMode, hasSsrEntry } = node_worker_threads_1.workerData;
19
19
  /** Renders an application based on a provided options. */
20
20
  async function extractRoutes() {
21
21
  const serverURL = outputMode !== undefined && hasSsrEntry ? await (0, launch_server_1.launchServer)() : launch_server_1.DEFAULT_URL;
@@ -43,9 +43,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
43
43
  exports.augmentAppWithServiceWorker = augmentAppWithServiceWorker;
44
44
  exports.augmentAppWithServiceWorkerEsbuild = augmentAppWithServiceWorkerEsbuild;
45
45
  exports.augmentAppWithServiceWorkerCore = augmentAppWithServiceWorkerCore;
46
- const crypto = __importStar(require("crypto"));
46
+ const crypto = __importStar(require("node:crypto"));
47
47
  const node_fs_1 = require("node:fs");
48
- const path = __importStar(require("path"));
48
+ const path = __importStar(require("node:path"));
49
49
  const bundler_context_1 = require("../tools/esbuild/bundler-context");
50
50
  const error_1 = require("./error");
51
51
  const load_esm_1 = require("./load-esm");