@angular/build 19.0.5 → 19.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 (51) hide show
  1. package/package.json +19 -19
  2. package/src/builders/application/build-action.js +17 -7
  3. package/src/builders/application/execute-build.js +2 -2
  4. package/src/builders/application/execute-post-bundle.d.ts +3 -1
  5. package/src/builders/application/execute-post-bundle.js +6 -4
  6. package/src/builders/application/i18n.d.ts +3 -1
  7. package/src/builders/application/i18n.js +15 -13
  8. package/src/builders/application/options.js +7 -5
  9. package/src/builders/dev-server/vite-server.js +22 -26
  10. package/src/builders/extract-i18n/builder.js +17 -7
  11. package/src/builders/extract-i18n/options.js +1 -1
  12. package/src/tools/angular/compilation/angular-compilation.js +17 -7
  13. package/src/tools/angular/compilation/aot-compilation.d.ts +2 -0
  14. package/src/tools/angular/compilation/aot-compilation.js +22 -37
  15. package/src/tools/angular/compilation/factory.d.ts +2 -1
  16. package/src/tools/angular/compilation/factory.js +22 -11
  17. package/src/tools/angular/compilation/hmr-candidates.d.ts +22 -0
  18. package/src/tools/angular/compilation/hmr-candidates.js +238 -0
  19. package/src/tools/angular/compilation/jit-compilation.d.ts +2 -0
  20. package/src/tools/angular/compilation/jit-compilation.js +11 -1
  21. package/src/tools/angular/compilation/parallel-compilation.d.ts +3 -2
  22. package/src/tools/angular/compilation/parallel-compilation.js +4 -1
  23. package/src/tools/angular/compilation/parallel-worker.d.ts +1 -0
  24. package/src/tools/angular/compilation/parallel-worker.js +3 -1
  25. package/src/tools/angular/transformers/lazy-routes-transformer.d.ts +39 -0
  26. package/src/tools/angular/transformers/lazy-routes-transformer.js +163 -0
  27. package/src/tools/babel/plugins/pure-toplevel-functions.js +17 -7
  28. package/src/tools/esbuild/angular/compiler-plugin.d.ts +1 -0
  29. package/src/tools/esbuild/angular/compiler-plugin.js +18 -8
  30. package/src/tools/esbuild/angular/source-file-cache.d.ts +1 -1
  31. package/src/tools/esbuild/angular/source-file-cache.js +17 -7
  32. package/src/tools/esbuild/compiler-plugin-options.js +1 -0
  33. package/src/tools/esbuild/global-scripts.js +17 -7
  34. package/src/tools/esbuild/javascript-transformer-worker.js +17 -7
  35. package/src/tools/esbuild/stylesheets/less-language.js +17 -7
  36. package/src/tools/esbuild/stylesheets/sass-language.js +17 -7
  37. package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.js +17 -7
  38. package/src/tools/vite/plugins/ssr-transform-plugin.js +11 -15
  39. package/src/utils/check-port.js +17 -7
  40. package/src/utils/i18n-options.d.ts +4 -1
  41. package/src/utils/i18n-options.js +50 -7
  42. package/src/utils/index-file/auto-csp.js +17 -7
  43. package/src/utils/index-file/inline-fonts.js +17 -7
  44. package/src/utils/load-proxy-config.js +17 -7
  45. package/src/utils/load-translations.js +17 -7
  46. package/src/utils/normalize-asset-patterns.js +17 -7
  47. package/src/utils/normalize-cache.js +1 -1
  48. package/src/utils/server-rendering/manifest.d.ts +5 -1
  49. package/src/utils/server-rendering/manifest.js +60 -11
  50. package/src/utils/server-rendering/prerender.js +1 -1
  51. package/src/utils/service-worker.js +17 -7
@@ -13,6 +13,7 @@ export interface CompilerPluginOptions {
13
13
  sourcemap: boolean | 'external';
14
14
  tsconfig: string;
15
15
  jit?: boolean;
16
+ browserOnlyBuild?: boolean;
16
17
  /** Skip TypeScript compilation setup. This is useful to re-use the TypeScript compilation from another plugin. */
17
18
  noopTypeScriptCompilation?: boolean;
18
19
  advancedOptimizations?: boolean;
@@ -22,13 +22,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
22
22
  }) : function(o, v) {
23
23
  o["default"] = v;
24
24
  });
25
- var __importStar = (this && this.__importStar) || function (mod) {
26
- if (mod && mod.__esModule) return mod;
27
- var result = {};
28
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
- __setModuleDefault(result, mod);
30
- return result;
31
- };
25
+ var __importStar = (this && this.__importStar) || (function () {
26
+ var ownKeys = function(o) {
27
+ ownKeys = Object.getOwnPropertyNames || function (o) {
28
+ var ar = [];
29
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
30
+ return ar;
31
+ };
32
+ return ownKeys(o);
33
+ };
34
+ return function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
41
+ })();
32
42
  var __importDefault = (this && this.__importDefault) || function (mod) {
33
43
  return (mod && mod.__esModule) ? mod : { "default": mod };
34
44
  };
@@ -93,7 +103,7 @@ function createCompilerPlugin(pluginOptions, stylesheetBundler) {
93
103
  // Create new reusable compilation for the appropriate mode based on the `jit` plugin option
94
104
  const compilation = pluginOptions.noopTypeScriptCompilation
95
105
  ? new compilation_1.NoopCompilation()
96
- : await (0, compilation_1.createAngularCompilation)(!!pluginOptions.jit);
106
+ : await (0, compilation_1.createAngularCompilation)(!!pluginOptions.jit, !!pluginOptions.browserOnlyBuild);
97
107
  // Compilation is initially assumed to have errors until emitted
98
108
  let hasCompilationErrors = true;
99
109
  // Determines if TypeScript should process JavaScript files based on tsconfig `allowJs` option
@@ -10,7 +10,7 @@ import { MemoryLoadResultCache } from '../load-result-cache';
10
10
  export declare class SourceFileCache extends Map<string, ts.SourceFile> {
11
11
  readonly persistentCachePath?: string | undefined;
12
12
  readonly modifiedFiles: Set<string>;
13
- readonly typeScriptFileCache: Map<string, string | Uint8Array>;
13
+ readonly typeScriptFileCache: Map<string, string | Uint8Array<ArrayBufferLike>>;
14
14
  readonly loadResultCache: MemoryLoadResultCache;
15
15
  referencedFiles?: readonly string[];
16
16
  constructor(persistentCachePath?: string | undefined);
@@ -22,13 +22,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
22
22
  }) : function(o, v) {
23
23
  o["default"] = v;
24
24
  });
25
- var __importStar = (this && this.__importStar) || function (mod) {
26
- if (mod && mod.__esModule) return mod;
27
- var result = {};
28
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
- __setModuleDefault(result, mod);
30
- return result;
31
- };
25
+ var __importStar = (this && this.__importStar) || (function () {
26
+ var ownKeys = function(o) {
27
+ ownKeys = Object.getOwnPropertyNames || function (o) {
28
+ var ar = [];
29
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
30
+ return ar;
31
+ };
32
+ return ownKeys(o);
33
+ };
34
+ return function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
41
+ })();
32
42
  Object.defineProperty(exports, "__esModule", { value: true });
33
43
  exports.SourceFileCache = void 0;
34
44
  const node_os_1 = require("node:os");
@@ -12,6 +12,7 @@ function createCompilerPluginOptions(options, sourceFileCache, loadResultCache,
12
12
  const { sourcemapOptions, tsconfig, fileReplacements, advancedOptimizations, jit, externalRuntimeStyles, instrumentForCoverage, } = options;
13
13
  const incremental = !!options.watch;
14
14
  return {
15
+ browserOnlyBuild: !options.serverEntryPoint,
15
16
  sourcemap: !!sourcemapOptions.scripts && (sourcemapOptions.hidden ? 'external' : true),
16
17
  thirdPartySourcemaps: sourcemapOptions.vendor,
17
18
  tsconfig,
@@ -22,13 +22,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
22
22
  }) : function(o, v) {
23
23
  o["default"] = v;
24
24
  });
25
- var __importStar = (this && this.__importStar) || function (mod) {
26
- if (mod && mod.__esModule) return mod;
27
- var result = {};
28
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
- __setModuleDefault(result, mod);
30
- return result;
31
- };
25
+ var __importStar = (this && this.__importStar) || (function () {
26
+ var ownKeys = function(o) {
27
+ ownKeys = Object.getOwnPropertyNames || function (o) {
28
+ var ar = [];
29
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
30
+ return ar;
31
+ };
32
+ return ownKeys(o);
33
+ };
34
+ return function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
41
+ })();
32
42
  var __importDefault = (this && this.__importDefault) || function (mod) {
33
43
  return (mod && mod.__esModule) ? mod : { "default": mod };
34
44
  };
@@ -22,13 +22,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
22
22
  }) : function(o, v) {
23
23
  o["default"] = v;
24
24
  });
25
- var __importStar = (this && this.__importStar) || function (mod) {
26
- if (mod && mod.__esModule) return mod;
27
- var result = {};
28
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
- __setModuleDefault(result, mod);
30
- return result;
31
- };
25
+ var __importStar = (this && this.__importStar) || (function () {
26
+ var ownKeys = function(o) {
27
+ ownKeys = Object.getOwnPropertyNames || function (o) {
28
+ var ar = [];
29
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
30
+ return ar;
31
+ };
32
+ return ownKeys(o);
33
+ };
34
+ return function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
41
+ })();
32
42
  var __importDefault = (this && this.__importDefault) || function (mod) {
33
43
  return (mod && mod.__esModule) ? mod : { "default": mod };
34
44
  };
@@ -22,13 +22,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
22
22
  }) : function(o, v) {
23
23
  o["default"] = v;
24
24
  });
25
- var __importStar = (this && this.__importStar) || function (mod) {
26
- if (mod && mod.__esModule) return mod;
27
- var result = {};
28
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
- __setModuleDefault(result, mod);
30
- return result;
31
- };
25
+ var __importStar = (this && this.__importStar) || (function () {
26
+ var ownKeys = function(o) {
27
+ ownKeys = Object.getOwnPropertyNames || function (o) {
28
+ var ar = [];
29
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
30
+ return ar;
31
+ };
32
+ return ownKeys(o);
33
+ };
34
+ return function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
41
+ })();
32
42
  Object.defineProperty(exports, "__esModule", { value: true });
33
43
  exports.LessStylesheetLanguage = void 0;
34
44
  const promises_1 = require("node:fs/promises");
@@ -22,13 +22,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
22
22
  }) : function(o, v) {
23
23
  o["default"] = v;
24
24
  });
25
- var __importStar = (this && this.__importStar) || function (mod) {
26
- if (mod && mod.__esModule) return mod;
27
- var result = {};
28
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
- __setModuleDefault(result, mod);
30
- return result;
31
- };
25
+ var __importStar = (this && this.__importStar) || (function () {
26
+ var ownKeys = function(o) {
27
+ ownKeys = Object.getOwnPropertyNames || function (o) {
28
+ var ar = [];
29
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
30
+ return ar;
31
+ };
32
+ return ownKeys(o);
33
+ };
34
+ return function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
41
+ })();
32
42
  Object.defineProperty(exports, "__esModule", { value: true });
33
43
  exports.SassStylesheetLanguage = void 0;
34
44
  exports.shutdownSassWorkerPool = shutdownSassWorkerPool;
@@ -22,13 +22,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
22
22
  }) : function(o, v) {
23
23
  o["default"] = v;
24
24
  });
25
- var __importStar = (this && this.__importStar) || function (mod) {
26
- if (mod && mod.__esModule) return mod;
27
- var result = {};
28
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
- __setModuleDefault(result, mod);
30
- return result;
31
- };
25
+ var __importStar = (this && this.__importStar) || (function () {
26
+ var ownKeys = function(o) {
27
+ ownKeys = Object.getOwnPropertyNames || function (o) {
28
+ var ar = [];
29
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
30
+ return ar;
31
+ };
32
+ return ownKeys(o);
33
+ };
34
+ return function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
41
+ })();
32
42
  var __importDefault = (this && this.__importDefault) || function (mod) {
33
43
  return (mod && mod.__esModule) ? mod : { "default": mod };
34
44
  };
@@ -17,21 +17,17 @@ async function createAngularSsrTransformPlugin(workspaceRoot) {
17
17
  const { normalizePath } = await (0, load_esm_1.loadEsmModule)('vite');
18
18
  return {
19
19
  name: 'vite:angular-ssr-transform',
20
- enforce: 'pre',
21
- async configureServer(server) {
22
- const originalssrTransform = server.ssrTransform;
23
- server.ssrTransform = async (code, map, url, originalCode) => {
24
- const result = await originalssrTransform(code, null, url, originalCode);
25
- if (!result || !result.map || !map) {
26
- return result;
27
- }
28
- const remappedMap = (0, remapping_1.default)([result.map, map], () => null);
29
- // Set the sourcemap root to the workspace root. This is needed since we set a virtual path as root.
30
- remappedMap.sourceRoot = normalizePath(workspaceRoot) + '/';
31
- return {
32
- ...result,
33
- map: remappedMap,
34
- };
20
+ enforce: 'post',
21
+ transform(code, _id, { ssr, inMap } = {}) {
22
+ if (!ssr || !inMap) {
23
+ return null;
24
+ }
25
+ const remappedMap = (0, remapping_1.default)([inMap], () => null);
26
+ // Set the sourcemap root to the workspace root. This is needed since we set a virtual path as root.
27
+ remappedMap.sourceRoot = normalizePath(workspaceRoot) + '/';
28
+ return {
29
+ code,
30
+ map: remappedMap,
35
31
  };
36
32
  },
37
33
  };
@@ -22,13 +22,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
22
22
  }) : function(o, v) {
23
23
  o["default"] = v;
24
24
  });
25
- var __importStar = (this && this.__importStar) || function (mod) {
26
- if (mod && mod.__esModule) return mod;
27
- var result = {};
28
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
- __setModuleDefault(result, mod);
30
- return result;
31
- };
25
+ var __importStar = (this && this.__importStar) || (function () {
26
+ var ownKeys = function(o) {
27
+ ownKeys = Object.getOwnPropertyNames || function (o) {
28
+ var ar = [];
29
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
30
+ return ar;
31
+ };
32
+ return ownKeys(o);
33
+ };
34
+ return function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
41
+ })();
32
42
  var __importDefault = (this && this.__importDefault) || function (mod) {
33
43
  return (mod && mod.__esModule) ? mod : { "default": mod };
34
44
  };
@@ -15,6 +15,7 @@ export interface LocaleDescription {
15
15
  translation?: Record<string, unknown>;
16
16
  dataPath?: string;
17
17
  baseHref?: string;
18
+ subPath: string;
18
19
  }
19
20
  export interface I18nOptions {
20
21
  inlineLocales: Set<string>;
@@ -26,7 +27,9 @@ export interface I18nOptions {
26
27
  }
27
28
  export declare function createI18nOptions(projectMetadata: {
28
29
  i18n?: unknown;
29
- }, inline?: boolean | string[]): I18nOptions;
30
+ }, inline?: boolean | string[], logger?: {
31
+ warn(message: string): void;
32
+ }): I18nOptions;
30
33
  export declare function loadTranslations(locale: string, desc: LocaleDescription, workspaceRoot: string, loader: TranslationLoader, logger: {
31
34
  warn: (message: string) => void;
32
35
  error: (message: string) => void;
@@ -31,15 +31,21 @@ function normalizeTranslationFileOption(option, locale, expectObjectInError) {
31
31
  }
32
32
  function ensureObject(value, name) {
33
33
  if (!value || typeof value !== 'object' || Array.isArray(value)) {
34
- throw new Error(`Project ${name} field is malformed. Expected an object.`);
34
+ throw new Error(`Project field '${name}' is malformed. Expected an object.`);
35
35
  }
36
36
  }
37
37
  function ensureString(value, name) {
38
38
  if (typeof value !== 'string') {
39
- throw new Error(`Project ${name} field is malformed. Expected a string.`);
39
+ throw new Error(`Project field '${name}' is malformed. Expected a string.`);
40
40
  }
41
41
  }
42
- function createI18nOptions(projectMetadata, inline) {
42
+ function ensureValidsubPath(value, name) {
43
+ ensureString(value, name);
44
+ if (!/^[\w-]*$/.test(value)) {
45
+ throw new Error(`Project field '${name}' is invalid. It can only contain letters, numbers, hyphens, and underscores.`);
46
+ }
47
+ }
48
+ function createI18nOptions(projectMetadata, inline, logger) {
43
49
  const { i18n: metadata = {} } = projectMetadata;
44
50
  ensureObject(metadata, 'i18n');
45
51
  const i18n = {
@@ -53,19 +59,31 @@ function createI18nOptions(projectMetadata, inline) {
53
59
  };
54
60
  let rawSourceLocale;
55
61
  let rawSourceLocaleBaseHref;
62
+ let rawsubPath;
56
63
  if (typeof metadata.sourceLocale === 'string') {
57
64
  rawSourceLocale = metadata.sourceLocale;
58
65
  }
59
66
  else if (metadata.sourceLocale !== undefined) {
60
- ensureObject(metadata.sourceLocale, 'i18n sourceLocale');
67
+ ensureObject(metadata.sourceLocale, 'i18n.sourceLocale');
61
68
  if (metadata.sourceLocale.code !== undefined) {
62
- ensureString(metadata.sourceLocale.code, 'i18n sourceLocale code');
69
+ ensureString(metadata.sourceLocale.code, 'i18n.sourceLocale.code');
63
70
  rawSourceLocale = metadata.sourceLocale.code;
64
71
  }
65
72
  if (metadata.sourceLocale.baseHref !== undefined) {
66
- ensureString(metadata.sourceLocale.baseHref, 'i18n sourceLocale baseHref');
73
+ ensureString(metadata.sourceLocale.baseHref, 'i18n.sourceLocale.baseHref');
74
+ logger?.warn(`The 'baseHref' field under 'i18n.sourceLocale' is deprecated and will be removed in future versions. ` +
75
+ `Please use 'subPath' instead.\nNote: 'subPath' defines the URL segment for the locale, acting ` +
76
+ `as both the HTML base HREF and the directory name for output.\nBy default, ` +
77
+ `if not specified, 'subPath' uses the locale code.`);
67
78
  rawSourceLocaleBaseHref = metadata.sourceLocale.baseHref;
68
79
  }
80
+ if (metadata.sourceLocale.subPath !== undefined) {
81
+ ensureValidsubPath(metadata.sourceLocale.subPath, 'i18n.sourceLocale.subPath');
82
+ rawsubPath = metadata.sourceLocale.subPath;
83
+ }
84
+ if (rawsubPath !== undefined && rawSourceLocaleBaseHref !== undefined) {
85
+ throw new Error(`'i18n.sourceLocale.subPath' and 'i18n.sourceLocale.baseHref' cannot be used together.`);
86
+ }
69
87
  }
70
88
  if (rawSourceLocale !== undefined) {
71
89
  i18n.sourceLocale = rawSourceLocale;
@@ -74,18 +92,31 @@ function createI18nOptions(projectMetadata, inline) {
74
92
  i18n.locales[i18n.sourceLocale] = {
75
93
  files: [],
76
94
  baseHref: rawSourceLocaleBaseHref,
95
+ subPath: rawsubPath ?? i18n.sourceLocale,
77
96
  };
78
97
  if (metadata.locales !== undefined) {
79
98
  ensureObject(metadata.locales, 'i18n locales');
80
99
  for (const [locale, options] of Object.entries(metadata.locales)) {
81
100
  let translationFiles;
82
101
  let baseHref;
102
+ let subPath;
83
103
  if (options && typeof options === 'object' && 'translation' in options) {
84
104
  translationFiles = normalizeTranslationFileOption(options.translation, locale, false);
85
105
  if ('baseHref' in options) {
86
- ensureString(options.baseHref, `i18n locales ${locale} baseHref`);
106
+ ensureString(options.baseHref, `i18n.locales.${locale}.baseHref`);
107
+ logger?.warn(`The 'baseHref' field under 'i18n.locales.${locale}' is deprecated and will be removed in future versions. ` +
108
+ `Please use 'subPath' instead.\nNote: 'subPath' defines the URL segment for the locale, acting ` +
109
+ `as both the HTML base HREF and the directory name for output.\nBy default, ` +
110
+ `if not specified, 'subPath' uses the locale code.`);
87
111
  baseHref = options.baseHref;
88
112
  }
113
+ if ('subPath' in options) {
114
+ ensureString(options.subPath, `i18n.locales.${locale}.subPath`);
115
+ subPath = options.subPath;
116
+ }
117
+ if (subPath !== undefined && baseHref !== undefined) {
118
+ throw new Error(`'i18n.locales.${locale}.subPath' and 'i18n.locales.${locale}.baseHref' cannot be used together.`);
119
+ }
89
120
  }
90
121
  else {
91
122
  translationFiles = normalizeTranslationFileOption(options, locale, true);
@@ -96,9 +127,21 @@ function createI18nOptions(projectMetadata, inline) {
96
127
  i18n.locales[locale] = {
97
128
  files: translationFiles.map((file) => ({ path: file })),
98
129
  baseHref,
130
+ subPath: subPath ?? locale,
99
131
  };
100
132
  }
101
133
  }
134
+ // Check that subPaths are unique.
135
+ const localesData = Object.entries(i18n.locales);
136
+ for (let i = 0; i < localesData.length; i++) {
137
+ const [localeA, { subPath: subPathA }] = localesData[i];
138
+ for (let j = i + 1; j < localesData.length; j++) {
139
+ const [localeB, { subPath: subPathB }] = localesData[j];
140
+ if (subPathA === subPathB) {
141
+ throw new Error(`Invalid i18n configuration: Locales '${localeA}' and '${localeB}' cannot have the same subPath: '${subPathB}'.`);
142
+ }
143
+ }
144
+ }
102
145
  if (inline === true) {
103
146
  i18n.inlineLocales.add(i18n.sourceLocale);
104
147
  Object.keys(i18n.locales).forEach((locale) => i18n.inlineLocales.add(locale));
@@ -22,13 +22,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
22
22
  }) : function(o, v) {
23
23
  o["default"] = v;
24
24
  });
25
- var __importStar = (this && this.__importStar) || function (mod) {
26
- if (mod && mod.__esModule) return mod;
27
- var result = {};
28
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
- __setModuleDefault(result, mod);
30
- return result;
31
- };
25
+ var __importStar = (this && this.__importStar) || (function () {
26
+ var ownKeys = function(o) {
27
+ ownKeys = Object.getOwnPropertyNames || function (o) {
28
+ var ar = [];
29
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
30
+ return ar;
31
+ };
32
+ return ownKeys(o);
33
+ };
34
+ return function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
41
+ })();
32
42
  Object.defineProperty(exports, "__esModule", { value: true });
33
43
  exports.hashTextContent = hashTextContent;
34
44
  exports.autoCsp = autoCsp;
@@ -22,13 +22,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
22
22
  }) : function(o, v) {
23
23
  o["default"] = v;
24
24
  });
25
- var __importStar = (this && this.__importStar) || function (mod) {
26
- if (mod && mod.__esModule) return mod;
27
- var result = {};
28
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
- __setModuleDefault(result, mod);
30
- return result;
31
- };
25
+ var __importStar = (this && this.__importStar) || (function () {
26
+ var ownKeys = function(o) {
27
+ ownKeys = Object.getOwnPropertyNames || function (o) {
28
+ var ar = [];
29
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
30
+ return ar;
31
+ };
32
+ return ownKeys(o);
33
+ };
34
+ return function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
41
+ })();
32
42
  Object.defineProperty(exports, "__esModule", { value: true });
33
43
  exports.InlineFontsProcessor = void 0;
34
44
  const https_proxy_agent_1 = require("https-proxy-agent");
@@ -22,13 +22,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
22
22
  }) : function(o, v) {
23
23
  o["default"] = v;
24
24
  });
25
- var __importStar = (this && this.__importStar) || function (mod) {
26
- if (mod && mod.__esModule) return mod;
27
- var result = {};
28
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
- __setModuleDefault(result, mod);
30
- return result;
31
- };
25
+ var __importStar = (this && this.__importStar) || (function () {
26
+ var ownKeys = function(o) {
27
+ ownKeys = Object.getOwnPropertyNames || function (o) {
28
+ var ar = [];
29
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
30
+ return ar;
31
+ };
32
+ return ownKeys(o);
33
+ };
34
+ return function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
41
+ })();
32
42
  Object.defineProperty(exports, "__esModule", { value: true });
33
43
  exports.loadProxyConfiguration = loadProxyConfiguration;
34
44
  const fast_glob_1 = require("fast-glob");
@@ -22,13 +22,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
22
22
  }) : function(o, v) {
23
23
  o["default"] = v;
24
24
  });
25
- var __importStar = (this && this.__importStar) || function (mod) {
26
- if (mod && mod.__esModule) return mod;
27
- var result = {};
28
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
- __setModuleDefault(result, mod);
30
- return result;
31
- };
25
+ var __importStar = (this && this.__importStar) || (function () {
26
+ var ownKeys = function(o) {
27
+ ownKeys = Object.getOwnPropertyNames || function (o) {
28
+ var ar = [];
29
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
30
+ return ar;
31
+ };
32
+ return ownKeys(o);
33
+ };
34
+ return function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
41
+ })();
32
42
  Object.defineProperty(exports, "__esModule", { value: true });
33
43
  exports.createTranslationLoader = createTranslationLoader;
34
44
  const crypto_1 = require("crypto");
@@ -22,13 +22,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
22
22
  }) : function(o, v) {
23
23
  o["default"] = v;
24
24
  });
25
- var __importStar = (this && this.__importStar) || function (mod) {
26
- if (mod && mod.__esModule) return mod;
27
- var result = {};
28
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
- __setModuleDefault(result, mod);
30
- return result;
31
- };
25
+ var __importStar = (this && this.__importStar) || (function () {
26
+ var ownKeys = function(o) {
27
+ ownKeys = Object.getOwnPropertyNames || function (o) {
28
+ var ar = [];
29
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
30
+ return ar;
31
+ };
32
+ return ownKeys(o);
33
+ };
34
+ return function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
41
+ })();
32
42
  var __importDefault = (this && this.__importDefault) || function (mod) {
33
43
  return (mod && mod.__esModule) ? mod : { "default": mod };
34
44
  };
@@ -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.0.5';
13
+ const VERSION = '19.1.0-next.1';
14
14
  function hasCacheMetadata(value) {
15
15
  return (!!value &&
16
16
  typeof value === 'object' &&