@nx/angular-rspack 20.6.2-beta.0 → 20.7.0-beta.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 (39) hide show
  1. package/dist/lib/config/create-config.d.ts.map +1 -1
  2. package/dist/lib/config/create-config.js +51 -10
  3. package/dist/lib/config/dev-server-config-utils.d.ts +1 -0
  4. package/dist/lib/config/dev-server-config-utils.d.ts.map +1 -1
  5. package/dist/lib/config/dev-server-config-utils.js +10 -0
  6. package/dist/lib/config/helpers.d.ts +11 -0
  7. package/dist/lib/config/helpers.d.ts.map +1 -1
  8. package/dist/lib/config/helpers.js +36 -0
  9. package/dist/lib/config/i18n/create-i18n-options.d.ts +6 -0
  10. package/dist/lib/config/i18n/create-i18n-options.d.ts.map +1 -0
  11. package/dist/lib/config/i18n/create-i18n-options.js +122 -0
  12. package/dist/lib/models/angular-rspack-plugin-options.d.ts +46 -0
  13. package/dist/lib/models/angular-rspack-plugin-options.d.ts.map +1 -1
  14. package/dist/lib/models/augmented-compilation.d.ts +2 -0
  15. package/dist/lib/models/augmented-compilation.d.ts.map +1 -1
  16. package/dist/lib/models/i18n.d.ts +33 -0
  17. package/dist/lib/models/i18n.d.ts.map +1 -0
  18. package/dist/lib/models/i18n.js +39 -0
  19. package/dist/lib/models/index.d.ts +1 -0
  20. package/dist/lib/models/index.d.ts.map +1 -1
  21. package/dist/lib/models/index.js +1 -0
  22. package/dist/lib/models/normalize-options.d.ts.map +1 -1
  23. package/dist/lib/models/normalize-options.js +9 -1
  24. package/dist/lib/models/unsupported-options.d.ts +0 -8
  25. package/dist/lib/models/unsupported-options.d.ts.map +1 -1
  26. package/dist/lib/models/unsupported-options.js +0 -8
  27. package/dist/lib/plugins/angular-rspack-plugin.d.ts +2 -2
  28. package/dist/lib/plugins/angular-rspack-plugin.d.ts.map +1 -1
  29. package/dist/lib/plugins/angular-rspack-plugin.js +41 -1
  30. package/dist/lib/plugins/i18n-inline-plugin.d.ts +8 -0
  31. package/dist/lib/plugins/i18n-inline-plugin.d.ts.map +1 -0
  32. package/dist/lib/plugins/i18n-inline-plugin.js +226 -0
  33. package/dist/lib/plugins/ng-rspack.d.ts +3 -2
  34. package/dist/lib/plugins/ng-rspack.d.ts.map +1 -1
  35. package/dist/lib/plugins/ng-rspack.js +9 -2
  36. package/dist/lib/utils/find-project-for-path.d.ts +16 -0
  37. package/dist/lib/utils/find-project-for-path.d.ts.map +1 -0
  38. package/dist/lib/utils/find-project-for-path.js +44 -0
  39. package/package.json +7 -3
@@ -1 +1 @@
1
- {"version":3,"file":"create-config.d.ts","sourceRoot":"","sources":["../../../src/lib/config/create-config.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EAOd,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,0BAA0B,EAG3B,MAAM,WAAW,CAAC;AAkEnB,wBAAsB,aAAa,CACjC,OAAO,EAAE,0BAA0B,EACnC,qBAAqB,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAC7C,OAAO,CAAC,aAAa,EAAE,CAAC,CAuX1B;AAED,wBAAsB,YAAY,CAChC,cAAc,EAAE;IACd,OAAO,EAAE,0BAA0B,CAAC;IACpC,qBAAqB,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;CAChD,EACD,cAAc,GAAE,MAAM,CACpB,MAAM,EACN;IACE,OAAO,EAAE,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAC7C,qBAAqB,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;CAChD,CACG,EACN,YAAY,SAAgB,GAC3B,OAAO,CAAC,aAAa,EAAE,CAAC,CAyB1B"}
1
+ {"version":3,"file":"create-config.d.ts","sourceRoot":"","sources":["../../../src/lib/config/create-config.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EAQd,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,0BAA0B,EAG3B,MAAM,WAAW,CAAC;AAsEnB,wBAAsB,aAAa,CACjC,OAAO,EAAE,0BAA0B,EACnC,qBAAqB,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAC7C,OAAO,CAAC,aAAa,EAAE,CAAC,CAyb1B;AAED,wBAAsB,YAAY,CAChC,cAAc,EAAE;IACd,OAAO,EAAE,0BAA0B,CAAC;IACpC,qBAAqB,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;CAChD,EACD,cAAc,GAAE,MAAM,CACpB,MAAM,EACN;IACE,OAAO,EAAE,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAC7C,qBAAqB,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;CAChD,CACG,EACN,YAAY,SAAgB,GAC3B,OAAO,CAAC,aAAa,EAAE,CAAC,CAyB1B"}
@@ -12,6 +12,7 @@ const style_config_utils_1 = require("./style-config-utils");
12
12
  const helpers_1 = require("./helpers");
13
13
  const dev_server_config_utils_1 = require("./dev-server-config-utils");
14
14
  const dev_tools_ignore_plugin_1 = require("../plugins/tools/dev-tools-ignore-plugin");
15
+ const create_i18n_options_1 = require("./i18n/create-i18n-options");
15
16
  function configureSourceMap(sourceMap) {
16
17
  const { scripts, styles, hidden, vendor } = sourceMap;
17
18
  const sourceMapRules = [];
@@ -57,11 +58,21 @@ function configureSourceMap(sourceMap) {
57
58
  }
58
59
  const VENDORS_TEST = /[\\/]node_modules[\\/]/;
59
60
  async function _createConfig(options, rspackConfigOverrides) {
60
- const normalizedOptions = (0, models_1.normalizeOptions)(options);
61
+ const { options: _options, i18n } = await (0, create_i18n_options_1.configureI18n)(options.root ?? process.cwd(), options);
62
+ // Update file hashes to include translation file content
63
+ const i18nHash = i18n.shouldInline
64
+ ? Object.values(i18n.locales).reduce((data, locale) => data + locale.files.map((file) => file.integrity || '').join('|'), '')
65
+ : () => {
66
+ // no-op as i18n is not inlined
67
+ };
68
+ const normalizedOptions = (0, models_1.normalizeOptions)(_options);
61
69
  const isProduction = process.env['NODE_ENV'] === 'production';
62
70
  const isDevServer = process.env['WEBPACK_SERVE'];
63
71
  const hashFormat = (0, helpers_1.getOutputHashFormat)(normalizedOptions.outputHashing);
64
72
  const { root } = normalizedOptions;
73
+ if (options.deleteOutputPath) {
74
+ await (0, helpers_1.deleteOutputDir)(root, normalizedOptions.outputPath.base);
75
+ }
65
76
  const { sourceMapRules, sourceMapPlugins } = configureSourceMap(normalizedOptions.sourceMap);
66
77
  const defaultConfig = {
67
78
  context: root,
@@ -70,7 +81,7 @@ async function _createConfig(options, rspackConfigOverrides) {
70
81
  output: {
71
82
  uniqueName: 'rspack-angular',
72
83
  publicPath: 'auto',
73
- clean: true,
84
+ clean: normalizedOptions.deleteOutputPath,
74
85
  crossOriginLoading: false,
75
86
  trustedTypes: { policyName: 'angular#bundler' },
76
87
  sourceMapFilename: normalizedOptions.sourceMap.scripts
@@ -79,12 +90,22 @@ async function _createConfig(options, rspackConfigOverrides) {
79
90
  },
80
91
  resolve: {
81
92
  extensions: ['.ts', '.tsx', '.mjs', '.js'],
93
+ symlinks: !normalizedOptions.preserveSymlinks,
82
94
  modules: ['node_modules'],
83
95
  mainFields: ['es2020', 'es2015', 'browser', 'module', 'main'],
84
96
  conditionNames: ['es2020', 'es2015', '...'],
85
97
  tsConfig: {
86
98
  configFile: normalizedOptions.tsConfig,
87
99
  },
100
+ ...(i18n.shouldInline && normalizedOptions.aot
101
+ ? { alias: { '@angular/localize/init': false } }
102
+ : {}),
103
+ },
104
+ resolveLoader: {
105
+ symlinks: !normalizedOptions.preserveSymlinks,
106
+ },
107
+ watchOptions: {
108
+ followSymlinks: normalizedOptions.preserveSymlinks,
88
109
  },
89
110
  module: {
90
111
  parser: {
@@ -128,6 +149,19 @@ async function _createConfig(options, rspackConfigOverrides) {
128
149
  },
129
150
  plugins: [
130
151
  ...sourceMapPlugins,
152
+ ...(i18n.shouldInline
153
+ ? [
154
+ {
155
+ apply(compiler) {
156
+ compiler.hooks.compilation.tap('AngularRspackPlugin', (compilation) => {
157
+ core_1.javascript.JavascriptModulesPlugin.getCompilationHooks(compilation).chunkHash.tap('AngularRspackPlugin', (_, hash) => {
158
+ hash.update('$localize' + i18nHash);
159
+ });
160
+ });
161
+ },
162
+ },
163
+ ]
164
+ : []),
131
165
  new core_1.CssExtractRspackPlugin({
132
166
  filename: `[name]${hashFormat.extract}.css`,
133
167
  }),
@@ -141,13 +175,16 @@ async function _createConfig(options, rspackConfigOverrides) {
141
175
  target: 'node',
142
176
  entry: {
143
177
  server: {
144
- import: [normalizedOptions.ssr.entry],
178
+ import: [
179
+ normalizedOptions.ssr.entry,
180
+ ...(i18n.shouldInline ? ['@angular/localize/init'] : []),
181
+ ],
145
182
  },
146
183
  },
147
184
  output: {
148
185
  ...defaultConfig.output,
149
186
  publicPath: '/',
150
- clean: true,
187
+ clean: normalizedOptions.deleteOutputPath,
151
188
  path: normalizedOptions.outputPath.server,
152
189
  filename: '[name].js',
153
190
  chunkFilename: '[name].js',
@@ -156,7 +193,7 @@ async function _createConfig(options, rspackConfigOverrides) {
156
193
  headers: {
157
194
  'Access-Control-Allow-Origin': '*',
158
195
  },
159
- allowedHosts: 'auto',
196
+ allowedHosts: (0, dev_server_config_utils_1.getAllowedHostsConfig)(normalizedOptions.devServer.allowedHosts, normalizedOptions.devServer.disableHostCheck),
160
197
  client: {
161
198
  webSocketURL: {
162
199
  hostname: normalizedOptions.devServer.host,
@@ -193,6 +230,7 @@ async function _createConfig(options, rspackConfigOverrides) {
193
230
  },
194
231
  proxy: await (0, dev_server_config_utils_1.getProxyConfig)(root, normalizedOptions.devServer.proxyConfig),
195
232
  },
233
+ externals: normalizedOptions.externalDependencies,
196
234
  optimization: {
197
235
  chunkIds: normalizedOptions.namedChunks ? 'named' : 'deterministic',
198
236
  moduleIds: 'deterministic',
@@ -252,7 +290,7 @@ async function _createConfig(options, rspackConfigOverrides) {
252
290
  new ng_rspack_1.NgRspackPlugin({
253
291
  ...normalizedOptions,
254
292
  polyfills: ['zone.js/node'],
255
- }),
293
+ }, i18n),
256
294
  ],
257
295
  };
258
296
  const mergedConfig = (0, webpack_merge_1.merge)(serverConfig, rspackConfigOverrides ?? {});
@@ -267,7 +305,10 @@ async function _createConfig(options, rspackConfigOverrides) {
267
305
  target: 'web',
268
306
  entry: {
269
307
  main: {
270
- import: [normalizedOptions.browser],
308
+ import: [
309
+ normalizedOptions.browser,
310
+ ...(i18n.shouldInline ? ['@angular/localize/init'] : []),
311
+ ],
271
312
  },
272
313
  styles: {
273
314
  import: (0, style_config_utils_1.getStylesEntry)(normalizedOptions),
@@ -277,7 +318,7 @@ async function _createConfig(options, rspackConfigOverrides) {
277
318
  headers: {
278
319
  'Access-Control-Allow-Origin': '*',
279
320
  },
280
- allowedHosts: 'auto',
321
+ allowedHosts: (0, dev_server_config_utils_1.getAllowedHostsConfig)(normalizedOptions.devServer.allowedHosts, normalizedOptions.devServer.disableHostCheck),
281
322
  client: {
282
323
  webSocketURL: {
283
324
  hostname: normalizedOptions.devServer.host,
@@ -326,7 +367,7 @@ async function _createConfig(options, rspackConfigOverrides) {
326
367
  ...defaultConfig.output,
327
368
  hashFunction: isProduction ? 'xxhash64' : undefined,
328
369
  publicPath: 'auto',
329
- clean: true,
370
+ clean: normalizedOptions.deleteOutputPath,
330
371
  path: normalizedOptions.outputPath.browser,
331
372
  cssFilename: `[name]${hashFormat.file}.css`,
332
373
  filename: `[name]${hashFormat.chunk}.js`,
@@ -395,7 +436,7 @@ async function _createConfig(options, rspackConfigOverrides) {
395
436
  ...normalizedOptions,
396
437
  polyfills: ['zone.js'],
397
438
  hasServer: false,
398
- }),
439
+ }, i18n),
399
440
  ],
400
441
  };
401
442
  const mergedConfig = (0, webpack_merge_1.merge)(browserConfig, rspackConfigOverrides ?? {});
@@ -1,3 +1,4 @@
1
1
  import type { DevServer } from '@rspack/core';
2
+ export declare function getAllowedHostsConfig(allowedHosts: string[] | boolean | undefined, disableHostCheck: boolean | undefined): "all" | string[] | undefined;
2
3
  export declare function getProxyConfig(root: string, proxyConfig: string | undefined): Promise<DevServer['proxy'] | undefined>;
3
4
  //# sourceMappingURL=dev-server-config-utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dev-server-config-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/config/dev-server-config-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAM9C,wBAAsB,cAAc,CAClC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,GAAG,SAAS,GAC9B,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC,CA2EzC"}
1
+ {"version":3,"file":"dev-server-config-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/config/dev-server-config-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAM9C,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,MAAM,EAAE,GAAG,OAAO,GAAG,SAAS,EAC5C,gBAAgB,EAAE,OAAO,GAAG,SAAS,gCAUtC;AAED,wBAAsB,cAAc,CAClC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,GAAG,SAAS,GAC9B,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC,CA2EzC"}
@@ -1,11 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAllowedHostsConfig = getAllowedHostsConfig;
3
4
  exports.getProxyConfig = getProxyConfig;
4
5
  const tslib_1 = require("tslib");
5
6
  const node_assert_1 = tslib_1.__importDefault(require("node:assert"));
6
7
  const node_fs_1 = require("node:fs");
7
8
  const node_path_1 = require("node:path");
8
9
  const node_url_1 = require("node:url");
10
+ function getAllowedHostsConfig(allowedHosts, disableHostCheck) {
11
+ if (disableHostCheck || allowedHosts === true) {
12
+ return 'all';
13
+ }
14
+ if (Array.isArray(allowedHosts) && allowedHosts.length > 0) {
15
+ return allowedHosts;
16
+ }
17
+ return undefined;
18
+ }
9
19
  async function getProxyConfig(root, proxyConfig) {
10
20
  if (!proxyConfig) {
11
21
  return undefined;
@@ -1,3 +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
+ */
1
8
  import { OutputHashing, HashFormat } from '../models';
9
+ /**
10
+ * Delete an output directory, but error out if it's the root of the project.
11
+ */
12
+ export declare function deleteOutputDir(root: string, outputPath: string, emptyOnlyDirectories?: string[]): Promise<void>;
2
13
  export declare function getOutputHashFormat(outputHashing?: OutputHashing, length?: number): HashFormat;
3
14
  //# sourceMappingURL=helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/lib/config/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEtD,wBAAgB,mBAAmB,CACjC,aAAa,GAAE,aAAsB,EACrC,MAAM,SAAI,GACT,UAAU,CAkCZ"}
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/lib/config/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAItD;;GAEG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,oBAAoB,CAAC,EAAE,MAAM,EAAE,GAC9B,OAAO,CAAC,IAAI,CAAC,CAqCf;AAED,wBAAgB,mBAAmB,CACjC,aAAa,GAAE,aAAsB,EACrC,MAAM,SAAI,GACT,UAAU,CAkCZ"}
@@ -1,6 +1,42 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deleteOutputDir = deleteOutputDir;
3
4
  exports.getOutputHashFormat = getOutputHashFormat;
5
+ const promises_1 = require("node:fs/promises");
6
+ const node_path_1 = require("node:path");
7
+ /**
8
+ * Delete an output directory, but error out if it's the root of the project.
9
+ */
10
+ async function deleteOutputDir(root, outputPath, emptyOnlyDirectories) {
11
+ const resolvedOutputPath = (0, node_path_1.resolve)(root, outputPath);
12
+ if (resolvedOutputPath === root) {
13
+ throw new Error('Output path MUST not be project root directory!');
14
+ }
15
+ const directoriesToEmpty = emptyOnlyDirectories
16
+ ? new Set(emptyOnlyDirectories.map((directory) => (0, node_path_1.join)(resolvedOutputPath, directory)))
17
+ : undefined;
18
+ // Avoid removing the actual directory to avoid errors in cases where the output
19
+ // directory is mounted or symlinked. Instead the contents are removed.
20
+ let entries;
21
+ try {
22
+ entries = await (0, promises_1.readdir)(resolvedOutputPath);
23
+ }
24
+ catch (error) {
25
+ if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {
26
+ return;
27
+ }
28
+ throw error;
29
+ }
30
+ for (const entry of entries) {
31
+ const fullEntry = (0, node_path_1.join)(resolvedOutputPath, entry);
32
+ // Leave requested directories. This allows symlinks to continue to function.
33
+ if (directoriesToEmpty?.has(fullEntry)) {
34
+ await deleteOutputDir(resolvedOutputPath, fullEntry);
35
+ continue;
36
+ }
37
+ await (0, promises_1.rm)(fullEntry, { force: true, recursive: true, maxRetries: 3 });
38
+ }
39
+ }
4
40
  function getOutputHashFormat(outputHashing = 'none', length = 8) {
5
41
  const hashTemplate = `.[contenthash:${length}]`;
6
42
  switch (outputHashing) {
@@ -0,0 +1,6 @@
1
+ import { AngularRspackPluginOptions } from '../../models';
2
+ export declare function configureI18n(projectRoot: string, options: AngularRspackPluginOptions): Promise<{
3
+ options: AngularRspackPluginOptions;
4
+ i18n: import("@angular/build/private").I18nOptions;
5
+ }>;
6
+ //# sourceMappingURL=create-i18n-options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-i18n-options.d.ts","sourceRoot":"","sources":["../../../../src/lib/config/i18n/create-i18n-options.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AA4E1D,wBAAsB,aAAa,CACjC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,0BAA0B;;;GAmFpC"}
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.configureI18n = configureI18n;
4
+ const tslib_1 = require("tslib");
5
+ const devkit_1 = require("@nx/devkit");
6
+ const private_1 = require("@angular/build/private");
7
+ const path = tslib_1.__importStar(require("node:path"));
8
+ const node_module_1 = require("node:module");
9
+ const find_project_for_path_1 = require("../../utils/find-project-for-path");
10
+ const node_path_1 = require("node:path");
11
+ /**
12
+ * The base module location used to search for locale specific data.
13
+ */
14
+ const LOCALE_DATA_BASE_MODULE = '@angular/common/locales/global';
15
+ function findLocaleDataPath(locale, resolver) {
16
+ // Remove private use subtags
17
+ const scrubbedLocale = locale.replace(/-x(-[a-zA-Z0-9]{1,8})+$/, '');
18
+ try {
19
+ return resolver(scrubbedLocale);
20
+ }
21
+ catch {
22
+ // fallback to known existing en-US locale data as of 14.0
23
+ return scrubbedLocale === 'en-US'
24
+ ? findLocaleDataPath('en', resolver)
25
+ : null;
26
+ }
27
+ }
28
+ async function getI18nMetadata(projectRoot, i18nMetadata) {
29
+ if (i18nMetadata === undefined) {
30
+ return await tryGetI18nMetadataFromProject(projectRoot);
31
+ }
32
+ return i18nMetadata;
33
+ }
34
+ async function tryGetI18nMetadataFromProject(projectRoot) {
35
+ try {
36
+ const graph = await (0, devkit_1.createProjectGraphAsync)();
37
+ const projectRootMappings = (0, find_project_for_path_1.createProjectRootMappings)(graph.nodes);
38
+ const root = projectRoot.startsWith(devkit_1.workspaceRoot)
39
+ ? (0, node_path_1.relative)(devkit_1.workspaceRoot, projectRoot)
40
+ : projectRoot;
41
+ const projectName = (0, find_project_for_path_1.findProjectForPath)(root, projectRootMappings);
42
+ if (!projectName) {
43
+ // Could not find a project the given root
44
+ return undefined;
45
+ }
46
+ const project = graph.nodes[projectName];
47
+ // Need to cast to any as Nx is not aware of the i18n metadata that exists in angular projects
48
+ const projectData = project.data;
49
+ if (projectData.i18n && typeof projectData.i18n === 'object') {
50
+ return projectData.i18n;
51
+ }
52
+ }
53
+ catch {
54
+ // Issue attempting to use the Nx project graph to determine the project to get the i18n metadata.
55
+ return undefined;
56
+ }
57
+ }
58
+ async function createI18nOptions(projectRoot, options, inline, ssrEnabled) {
59
+ const i18nMetadata = await getI18nMetadata(projectRoot, options.i18nMetadata);
60
+ return (0, private_1.createI18nOptions)({ i18n: i18nMetadata }, inline, devkit_1.logger, ssrEnabled);
61
+ }
62
+ async function configureI18n(projectRoot, options) {
63
+ if (global.NX_GRAPH_CREATION) {
64
+ return {
65
+ options,
66
+ i18n: {
67
+ inlineLocales: new Set(),
68
+ // en-US is the default locale added to Angular applications (https://angular.dev/guide/i18n/format-data-locale)
69
+ sourceLocale: 'en-US',
70
+ locales: {},
71
+ get shouldInline() {
72
+ return this.inlineLocales.size > 0;
73
+ },
74
+ },
75
+ };
76
+ }
77
+ const i18n = await createI18nOptions(projectRoot, options, options.localize);
78
+ // No additional processing needed if no inlining requested and no source locale defined.
79
+ if (!i18n.shouldInline && !i18n.hasDefinedSourceLocale) {
80
+ return { options, i18n };
81
+ }
82
+ // The trailing slash is required to signal that the path is a directory and not a file.
83
+ const projectRequire = (0, node_module_1.createRequire)(projectRoot + '/');
84
+ const localeResolver = (locale) => projectRequire.resolve(path.join(LOCALE_DATA_BASE_MODULE, locale));
85
+ // Load locale data and translations (if present)
86
+ let loader;
87
+ const usedFormats = new Set();
88
+ for (const [locale, desc] of Object.entries(i18n.locales)) {
89
+ if (!i18n.inlineLocales.has(locale) && locale !== i18n.sourceLocale) {
90
+ continue;
91
+ }
92
+ let localeDataPath = findLocaleDataPath(locale, localeResolver);
93
+ if (!localeDataPath) {
94
+ const [first] = locale.split('-');
95
+ if (first) {
96
+ localeDataPath = findLocaleDataPath(first.toLowerCase(), localeResolver);
97
+ if (localeDataPath) {
98
+ devkit_1.logger.warn(`Locale data for '${locale}' cannot be found. Using locale data for '${first}'.`);
99
+ }
100
+ }
101
+ }
102
+ if (!localeDataPath) {
103
+ devkit_1.logger.warn(`Locale data for '${locale}' cannot be found. No locale data will be included for this locale.`);
104
+ }
105
+ else {
106
+ desc.dataPath = localeDataPath;
107
+ }
108
+ if (!desc.files.length) {
109
+ continue;
110
+ }
111
+ loader ??= await (0, private_1.createTranslationLoader)();
112
+ (0, private_1.loadTranslations)(locale, desc, devkit_1.workspaceRoot, loader, {
113
+ warn(message) {
114
+ devkit_1.logger.warn(message);
115
+ },
116
+ error(message) {
117
+ throw new Error(message);
118
+ },
119
+ }, usedFormats, options.i18nDuplicateTranslation);
120
+ }
121
+ return { options, i18n };
122
+ }
@@ -1,6 +1,15 @@
1
1
  import type { FileReplacement, InlineStyleLanguage, StylePreprocessorOptions } from '@nx/angular-rspack-compiler';
2
2
  import type { DevServerUnsupportedOptions, PluginUnsupportedOptions } from './unsupported-options';
3
+ import { I18nProjectMetadata } from './i18n';
3
4
  export interface DevServerOptions extends DevServerUnsupportedOptions {
5
+ /**
6
+ * The hosts that the development server will respond to.
7
+ */
8
+ allowedHosts?: string[] | boolean;
9
+ /**
10
+ * Don't verify connected clients are part of allowed hosts.
11
+ */
12
+ disableHostCheck?: boolean;
4
13
  host?: string;
5
14
  port?: number;
6
15
  proxyConfig?: string;
@@ -9,6 +18,7 @@ export interface DevServerOptions extends DevServerUnsupportedOptions {
9
18
  sslKey?: string;
10
19
  }
11
20
  export interface NormalizedDevServerOptions extends DevServerOptions {
21
+ allowedHosts: string[] | boolean;
12
22
  host: string;
13
23
  port: number;
14
24
  }
@@ -72,16 +82,50 @@ export interface AngularRspackPluginOptions extends PluginUnsupportedOptions {
72
82
  assets?: AssetElement[];
73
83
  browser?: string;
74
84
  commonChunk?: boolean;
85
+ /**
86
+ * Defines global identifiers that will be replaced with a specified constant value when found in any JavaScript or TypeScript code including libraries.
87
+ * The value will be used directly.
88
+ * String values must be put in quotes.
89
+ */
90
+ define?: Record<string, string>;
91
+ /**
92
+ * Delete the output path before building.
93
+ */
94
+ deleteOutputPath?: boolean;
75
95
  devServer?: DevServerOptions;
96
+ /**
97
+ * Exclude the listed external dependencies from being bundled into the bundle. Instead, the created bundle relies on these dependencies to be available during runtime.
98
+ */
99
+ externalDependencies?: string[];
76
100
  extractLicenses?: boolean;
77
101
  fileReplacements?: FileReplacement[];
78
102
  index?: IndexElement;
79
103
  inlineStyleLanguage?: InlineStyleLanguage;
104
+ /**
105
+ * Project metadata for i18n.
106
+ */
107
+ i18nMetadata?: I18nProjectMetadata;
108
+ /**
109
+ * How to handle missing translations for i18n.
110
+ */
111
+ i18nMissingTranslation?: 'warning' | 'error' | 'ignore';
112
+ /**
113
+ * How to handle duplicate translations for i18n.
114
+ */
115
+ i18nDuplicateTranslation?: 'warning' | 'error' | 'ignore';
116
+ /**
117
+ * Translate the bundles in one or more locales.
118
+ */
119
+ localize?: boolean | string[];
80
120
  namedChunks?: boolean;
81
121
  optimization?: boolean | OptimizationOptions;
82
122
  outputHashing?: OutputHashing;
83
123
  outputPath?: string | (Required<Pick<OutputPath, 'base'>> & Partial<OutputPath>);
84
124
  polyfills?: string[];
125
+ /**
126
+ * Do not use the real path when resolving modules. If unset then will default to `true` if NodeJS option --preserve-symlinks is set.
127
+ */
128
+ preserveSymlinks?: boolean;
85
129
  root?: string;
86
130
  scripts?: ScriptOrStyleEntry[];
87
131
  server?: string;
@@ -103,7 +147,9 @@ export interface NormalizedAngularRspackPluginOptions extends Omit<AngularRspack
103
147
  assets: NormalizedAssetElement[];
104
148
  browser: string;
105
149
  commonChunk: boolean;
150
+ deleteOutputPath: boolean;
106
151
  devServer: NormalizedDevServerOptions;
152
+ externalDependencies: string[];
107
153
  extractLicenses: boolean;
108
154
  fileReplacements: FileReplacement[];
109
155
  globalScripts: GlobalEntry[];
@@ -1 +1 @@
1
- {"version":3,"file":"angular-rspack-plugin-options.d.ts","sourceRoot":"","sources":["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;IACxE,qBAAqB,EAAE,OAAO,CAAC;IAC/B,GAAG,EAAE,OAAO,CAAC;IACb,MAAM,EAAE,sBAAsB,EAAE,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,0BAA0B,CAAC;IACtC,eAAe,EAAE,OAAO,CAAC;IACzB,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC,aAAa,EAAE,WAAW,EAAE,CAAC;IAC7B,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,KAAK,EAAE,sBAAsB,GAAG,SAAS,CAAC;IAC1C,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,OAAO,GAAG,mBAAmB,CAAC;IAC5C,aAAa,EAAE,aAAa,CAAC;IAC7B,UAAU,EAAE,UAAU,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;CACtB"}
1
+ {"version":3,"file":"angular-rspack-plugin-options.d.ts","sourceRoot":"","sources":["../../../src/lib/models/angular-rspack-plugin-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,mBAAmB,EACnB,wBAAwB,EACzB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EACV,2BAA2B,EAC3B,wBAAwB,EACzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAE7C,MAAM,WAAW,gBAAiB,SAAQ,2BAA2B;IACnE;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAClC;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,IAAI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C,CAAC;IACN,wBAAwB,CAAC,EAAE,wBAAwB,CAAC;IACpD,MAAM,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,oCACf,SAAQ,IAAI,CAAC,0BAA0B,EAAE,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAC;IACxE,qBAAqB,EAAE,OAAO,CAAC;IAC/B,GAAG,EAAE,OAAO,CAAC;IACb,MAAM,EAAE,sBAAsB,EAAE,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;IACrB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,SAAS,EAAE,0BAA0B,CAAC;IACtC,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,eAAe,EAAE,OAAO,CAAC;IACzB,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC,aAAa,EAAE,WAAW,EAAE,CAAC;IAC7B,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,KAAK,EAAE,sBAAsB,GAAG,SAAS,CAAC;IAC1C,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,OAAO,GAAG,mBAAmB,CAAC;IAC5C,aAAa,EAAE,aAAa,CAAC;IAC7B,UAAU,EAAE,UAAU,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;CACtB"}
@@ -1,9 +1,11 @@
1
1
  import type { Compilation } from '@rspack/core';
2
2
  import type { JavaScriptTransformer } from '@nx/angular-rspack-compiler';
3
+ import { I18nOptions } from './i18n';
3
4
  export declare const NG_RSPACK_SYMBOL_NAME = "NG_RSPACK_BUILD";
4
5
  export type NG_RSPACK_COMPILATION_STATE = {
5
6
  javascriptTransformer: JavaScriptTransformer;
6
7
  typescriptFileCache: Map<string, string | Buffer>;
8
+ i18n?: I18nOptions;
7
9
  };
8
10
  export type NgRspackCompilation = Compilation & {
9
11
  [NG_RSPACK_SYMBOL_NAME]: () => NG_RSPACK_COMPILATION_STATE;
@@ -1 +1 @@
1
- {"version":3,"file":"augmented-compilation.d.ts","sourceRoot":"","sources":["../../../src/lib/models/augmented-compilation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEzE,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AAEvD,MAAM,MAAM,2BAA2B,GAAG;IACxC,qBAAqB,EAAE,qBAAqB,CAAC;IAC7C,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;CACnD,CAAC;AACF,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG;IAC9C,CAAC,qBAAqB,CAAC,EAAE,MAAM,2BAA2B,CAAC;CAC5D,CAAC"}
1
+ {"version":3,"file":"augmented-compilation.d.ts","sourceRoot":"","sources":["../../../src/lib/models/augmented-compilation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AAEvD,MAAM,MAAM,2BAA2B,GAAG;IACxC,qBAAqB,EAAE,qBAAqB,CAAC;IAC7C,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IAClD,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB,CAAC;AACF,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG;IAC9C,CAAC,qBAAqB,CAAC,EAAE,MAAM,2BAA2B,CAAC;CAC5D,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { I18nOptions as _I18nOptions } from '@angular/build/private';
2
+ export type I18nOptions = _I18nOptions;
3
+ export interface SourceLocale {
4
+ code?: string;
5
+ baseHref?: string;
6
+ subPath?: string;
7
+ }
8
+ export interface LocaleMetadata {
9
+ translation?: string | string[];
10
+ baseHref?: string;
11
+ subPath?: string;
12
+ }
13
+ export interface I18nProjectMetadata {
14
+ sourceLocale?: string | SourceLocale;
15
+ locales?: Record<string, string | string[] | LocaleMetadata>;
16
+ }
17
+ /**
18
+ * How to handle potential diagnostics.
19
+ */
20
+ export type DiagnosticHandlingStrategy = 'error' | 'warning' | 'ignore';
21
+ export declare class Diagnostics {
22
+ readonly messages: {
23
+ type: 'warning' | 'error';
24
+ message: string;
25
+ }[];
26
+ get hasErrors(): boolean;
27
+ add(type: DiagnosticHandlingStrategy, message: string): void;
28
+ warn(message: string): void;
29
+ error(message: string): void;
30
+ merge(other: Diagnostics): void;
31
+ formatDiagnostics(message: string): string;
32
+ }
33
+ //# sourceMappingURL=i18n.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../../src/lib/models/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAErE,MAAM,MAAM,WAAW,GAAG,YAAY,CAAC;AAEvC,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,mBAAmB;IAClC,YAAY,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,cAAc,CAAC,CAAC;CAC9D;AAED;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAC;AAExE,qBAAa,WAAW;IACtB,QAAQ,CAAC,QAAQ,EAAE;QAAE,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,CAAM;IACzE,IAAI,SAAS,YAEZ;IACD,GAAG,CAAC,IAAI,EAAE,0BAA0B,EAAE,OAAO,EAAE,MAAM;IAKrD,IAAI,CAAC,OAAO,EAAE,MAAM;IAGpB,KAAK,CAAC,OAAO,EAAE,MAAM;IAGrB,KAAK,CAAC,KAAK,EAAE,WAAW;IAGxB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;CAe3C"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Diagnostics = void 0;
4
+ class Diagnostics {
5
+ messages = [];
6
+ get hasErrors() {
7
+ return this.messages.some((m) => m.type === 'error');
8
+ }
9
+ add(type, message) {
10
+ if (type !== 'ignore') {
11
+ this.messages.push({ type, message });
12
+ }
13
+ }
14
+ warn(message) {
15
+ this.messages.push({ type: 'warning', message });
16
+ }
17
+ error(message) {
18
+ this.messages.push({ type: 'error', message });
19
+ }
20
+ merge(other) {
21
+ this.messages.push(...other.messages);
22
+ }
23
+ formatDiagnostics(message) {
24
+ const errors = this.messages
25
+ .filter((d) => d.type === 'error')
26
+ .map((d) => ' - ' + d.message);
27
+ const warnings = this.messages
28
+ .filter((d) => d.type === 'warning')
29
+ .map((d) => ' - ' + d.message);
30
+ if (errors.length) {
31
+ message += '\nERRORS:\n' + errors.join('\n');
32
+ }
33
+ if (warnings.length) {
34
+ message += '\nWARNINGS:\n' + warnings.join('\n');
35
+ }
36
+ return message;
37
+ }
38
+ }
39
+ exports.Diagnostics = Diagnostics;
@@ -1,4 +1,5 @@
1
1
  export * from './angular-rspack-plugin-options';
2
2
  export * from './augmented-compilation';
3
+ export * from './i18n';
3
4
  export * from './normalize-options';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC;AACxC,cAAc,QAAQ,CAAC;AACvB,cAAc,qBAAqB,CAAC"}
@@ -3,4 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./angular-rspack-plugin-options"), exports);
5
5
  tslib_1.__exportStar(require("./augmented-compilation"), exports);
6
+ tslib_1.__exportStar(require("./i18n"), exports);
6
7
  tslib_1.__exportStar(require("./normalize-options"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"normalize-options.d.ts","sourceRoot":"","sources":["../../../src/lib/models/normalize-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAkB9D,OAAO,KAAK,EACV,0BAA0B,EAI1B,oCAAoC,EAOrC,MAAM,iCAAiC,CAAC;AAMzC,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAE/C;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,gBAAgB,EAAE,eAAe,EAAE,EACnC,IAAI,EAAE,MAAM,GACX,eAAe,EAAE,CAKnB;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,GAAG,EAAE,0BAA0B,CAAC,KAAK,CAAC,GACrC,OAAO,CAQT;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,0BAA0B,CAAC,KAAK,CAAC,QAmBjE;AAED,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,0BAA0B,CAAC,cAAc,CAAC,QASzD;AA0BD,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,0BAA0B,GAClC,oCAAoC,CA0ItC"}
1
+ {"version":3,"file":"normalize-options.d.ts","sourceRoot":"","sources":["../../../src/lib/models/normalize-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAkB9D,OAAO,KAAK,EACV,0BAA0B,EAI1B,oCAAoC,EAOrC,MAAM,iCAAiC,CAAC;AAMzC,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAE/C;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,gBAAgB,EAAE,eAAe,EAAE,EACnC,IAAI,EAAE,MAAM,GACX,eAAe,EAAE,CAKnB;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,GAAG,EAAE,0BAA0B,CAAC,KAAK,CAAC,GACrC,OAAO,CAQT;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,0BAA0B,CAAC,KAAK,CAAC,QAmBjE;AAED,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,0BAA0B,CAAC,cAAc,CAAC,QASzD;AA0BD,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,0BAA0B,GAClC,oCAAoC,CA6ItC"}
@@ -157,7 +157,10 @@ function normalizeOptions(options) {
157
157
  aot,
158
158
  browser: options.browser ?? './src/main.ts',
159
159
  commonChunk: options.commonChunk ?? true,
160
+ define: options.define ?? {},
161
+ deleteOutputPath: options.deleteOutputPath ?? true,
160
162
  devServer: normalizeDevServer(options.devServer),
163
+ externalDependencies: options.externalDependencies ?? [],
161
164
  extractLicenses: options.extractLicenses ?? true,
162
165
  fileReplacements: resolveFileReplacements(fileReplacements, root),
163
166
  globalStyles,
@@ -208,10 +211,15 @@ function normalizeDevServer(devServer) {
208
211
  const defaultHost = 'localhost';
209
212
  const defaultPort = 4200;
210
213
  if (!devServer) {
211
- return { host: defaultHost, port: defaultPort };
214
+ return {
215
+ allowedHosts: [],
216
+ host: defaultHost,
217
+ port: defaultPort,
218
+ };
212
219
  }
213
220
  return {
214
221
  ...devServer,
222
+ allowedHosts: devServer.allowedHosts ?? [],
215
223
  host: devServer.host ?? defaultHost,
216
224
  port: devServer.port ?? defaultPort,
217
225
  };
@@ -10,7 +10,6 @@ export type BudgetEntry = {
10
10
  error?: string;
11
11
  };
12
12
  export interface DevServerUnsupportedOptions {
13
- allowedHosts?: string[] | boolean;
14
13
  headers?: Record<string, string>;
15
14
  open?: boolean;
16
15
  liveReload?: boolean;
@@ -28,19 +27,12 @@ export interface PluginUnsupportedOptions {
28
27
  unsafeEval?: boolean;
29
28
  };
30
29
  };
31
- externalDependencies?: string[];
32
30
  clearScreen?: boolean;
33
- define?: Record<string, string>;
34
31
  baseHref?: string;
35
32
  verbose?: boolean;
36
33
  progress?: boolean;
37
- i18nMissingTranslation?: 'warning' | 'error' | 'ignore';
38
- i18nDuplicateTranslation?: 'warning' | 'error' | 'ignore';
39
- localize?: boolean | string[];
40
34
  watch?: boolean;
41
35
  poll?: number;
42
- deleteOutputPath?: boolean;
43
- preserveSymlinks?: boolean;
44
36
  subresourceIntegrity?: boolean;
45
37
  serviceWorker?: string | false;
46
38
  statsJson?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"unsupported-options.d.ts","sourceRoot":"","sources":["../../../src/lib/models/unsupported-options.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xB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,iBAAiB,CAAC;IACvD,2BAA2B,CAAC,EAAE,MAAM,EAAE,CAAC;IACvC,SAAS,CAAC,EACN,OAAO,GACP;QACE,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,cAAc,CAAC,EAAE,OAAO,CAAC;KAC1B,CAAC;IACN,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;CAClC;AAED,eAAO,MAAM,iCAAiC,UAmB7C,CAAC;AAEF,eAAO,MAAM,kCAAkC,UAQ9C,CAAC"}
@@ -4,19 +4,12 @@ exports.DEV_SERVER_OPTIONS_PENDING_SUPPORT = exports.TOP_LEVEL_OPTIONS_PENDING_S
4
4
  exports.TOP_LEVEL_OPTIONS_PENDING_SUPPORT = [
5
5
  'deployUrl',
6
6
  'security',
7
- 'externalDependencies',
8
7
  'clearScreen',
9
- 'define',
10
8
  'baseHref',
11
9
  'verbose',
12
10
  'progress',
13
- 'i18nMissingTranslation',
14
- 'i18nDuplicateTranslation',
15
- 'localize',
16
11
  'watch',
17
12
  'poll',
18
- 'deleteOutputPath',
19
- 'preserveSymlinks',
20
13
  'subresourceIntegrity',
21
14
  'serviceWorker',
22
15
  'statsJson',
@@ -29,7 +22,6 @@ exports.TOP_LEVEL_OPTIONS_PENDING_SUPPORT = [
29
22
  'outputMode',
30
23
  ];
31
24
  exports.DEV_SERVER_OPTIONS_PENDING_SUPPORT = [
32
- 'allowedHosts',
33
25
  'headers',
34
26
  'open',
35
27
  'liveReload',
@@ -1,8 +1,8 @@
1
1
  import { Compiler, RspackPluginInstance } from '@rspack/core';
2
- import { type NormalizedAngularRspackPluginOptions } from '../models';
2
+ import { I18nOptions, type NormalizedAngularRspackPluginOptions } from '../models';
3
3
  export declare class AngularRspackPlugin implements RspackPluginInstance {
4
4
  #private;
5
- constructor(options: NormalizedAngularRspackPluginOptions);
5
+ constructor(options: NormalizedAngularRspackPluginOptions, i18nOptions?: I18nOptions);
6
6
  apply(compiler: Compiler): void;
7
7
  private setupCompilation;
8
8
  }
@@ -1 +1 @@
1
- {"version":3,"file":"angular-rspack-plugin.d.ts","sourceRoot":"","sources":["../../../src/lib/plugins/angular-rspack-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAGR,oBAAoB,EACrB,MAAM,cAAc,CAAC;AACtB,OAAO,EAGL,KAAK,oCAAoC,EAC1C,MAAM,WAAW,CAAC;AAiBnB,qBAAa,mBAAoB,YAAW,oBAAoB;;gBAWlD,OAAO,EAAE,oCAAoC;IAqBzD,KAAK,CAAC,QAAQ,EAAE,QAAQ;YAgJV,gBAAgB;CA0B/B"}
1
+ {"version":3,"file":"angular-rspack-plugin.d.ts","sourceRoot":"","sources":["../../../src/lib/plugins/angular-rspack-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAGR,oBAAoB,EAErB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,WAAW,EAGX,KAAK,oCAAoC,EAC1C,MAAM,WAAW,CAAC;AAiBnB,qBAAa,mBAAoB,YAAW,oBAAoB;;gBAa5D,OAAO,EAAE,oCAAoC,EAC7C,WAAW,CAAC,EAAE,WAAW;IAuB3B,KAAK,CAAC,QAAQ,EAAE,QAAQ;YAiMV,gBAAgB;CA0B/B"}
@@ -10,14 +10,16 @@ const fs_2 = tslib_1.__importDefault(require("fs"));
10
10
  const PLUGIN_NAME = 'AngularRspackPlugin';
11
11
  class AngularRspackPlugin {
12
12
  #_options;
13
+ #i18n;
13
14
  #typescriptFileCache;
14
15
  #javascriptTransformer;
15
16
  // This will be defined in the apply method correctly
16
17
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
17
18
  // @ts-expect-error
18
19
  #angularCompilation;
19
- constructor(options) {
20
+ constructor(options, i18nOptions) {
20
21
  this.#_options = options;
22
+ this.#i18n = i18nOptions;
21
23
  this.#typescriptFileCache = new Map();
22
24
  this.#javascriptTransformer = new angular_rspack_compiler_1.JavaScriptTransformer({
23
25
  /**
@@ -70,6 +72,43 @@ class AngularRspackPlugin {
70
72
  }
71
73
  callback();
72
74
  });
75
+ compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
76
+ compilation.hooks.processAssets.tap({
77
+ name: PLUGIN_NAME,
78
+ stage: compiler.rspack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
79
+ }, (assets) => {
80
+ for (const assetName in assets) {
81
+ const asset = compilation.getAsset(assetName);
82
+ if (!asset) {
83
+ continue;
84
+ }
85
+ const assetHash = asset.info?.contenthash?.[0] ?? '';
86
+ const assetNameWithoutHash = assetName.replace(`.${assetHash}`, '');
87
+ if (assetNameWithoutHash !== 'main.js') {
88
+ continue;
89
+ }
90
+ const originalSource = asset.source.source();
91
+ let updatedSourceContent = typeof originalSource === 'string'
92
+ ? originalSource
93
+ : originalSource.toString();
94
+ if (this.#i18n?.shouldInline) {
95
+ // When inlining, a placeholder is used to allow the post-processing step to inject the $localize locale identifier.
96
+ updatedSourceContent +=
97
+ '(globalThis.$localize ??= {}).locale = "___NG_LOCALE_INSERT___";\n';
98
+ }
99
+ else if (this.#i18n?.hasDefinedSourceLocale) {
100
+ // If not inlining translations and source locale is defined, inject the locale specifier.
101
+ updatedSourceContent += `(globalThis.$localize ??= {}).locale = "${this.#i18n.sourceLocale}";\n`;
102
+ }
103
+ // Replace the asset with the modified content
104
+ const map = asset.source.map();
105
+ const updatedSource = map
106
+ ? new core_1.sources.SourceMapSource(updatedSourceContent, asset.name, map)
107
+ : new core_1.sources.RawSource(updatedSourceContent);
108
+ compilation.updateAsset(assetName, updatedSource);
109
+ }
110
+ });
111
+ });
73
112
  compiler.hooks.emit.tapAsync(PLUGIN_NAME, async (compilation, callback) => {
74
113
  if (!this.#_options.skipTypeChecking) {
75
114
  const { errors, warnings } = await this.#angularCompilation.diagnoseFiles(angular_rspack_compiler_1.DiagnosticModes.All);
@@ -111,6 +150,7 @@ class AngularRspackPlugin {
111
150
  javascriptTransformer: this
112
151
  .#javascriptTransformer,
113
152
  typescriptFileCache: this.#typescriptFileCache,
153
+ i18n: this.#i18n,
114
154
  });
115
155
  });
116
156
  compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
@@ -0,0 +1,8 @@
1
+ import { RspackPluginInstance, Compiler } from '@rspack/core';
2
+ import { I18nOptions, NormalizedAngularRspackPluginOptions } from '../models';
3
+ export declare class I18nInlinePlugin implements RspackPluginInstance {
4
+ #private;
5
+ constructor(pluginOptions: NormalizedAngularRspackPluginOptions, i18nOptions: I18nOptions);
6
+ apply(compiler: Compiler): void;
7
+ }
8
+ //# sourceMappingURL=i18n-inline-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n-inline-plugin.d.ts","sourceRoot":"","sources":["../../../src/lib/plugins/i18n-inline-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAW,MAAM,cAAc,CAAC;AASvE,OAAO,EAAE,WAAW,EAAE,oCAAoC,EAAE,MAAM,WAAW,CAAC;AAS9E,qBAAa,gBAAiB,YAAW,oBAAoB;;gBAUzD,aAAa,EAAE,oCAAoC,EACnD,WAAW,EAAE,WAAW;IAM1B,KAAK,CAAC,QAAQ,EAAE,QAAQ;CAuSzB"}
@@ -0,0 +1,226 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.I18nInlinePlugin = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const core_1 = require("@rspack/core");
6
+ const core_2 = require("@babel/core");
7
+ const remapping_1 = tslib_1.__importDefault(require("@ampproject/remapping"));
8
+ const node_assert_1 = tslib_1.__importDefault(require("node:assert"));
9
+ const PLUGIN_NAME = 'I18nInlinePlugin';
10
+ class I18nInlinePlugin {
11
+ #pluginOptions;
12
+ #i18n;
13
+ /**
14
+ * Cached instance of the `@angular/localize/tools` module.
15
+ * This is used to remove the need to repeatedly import the module per file translation.
16
+ */
17
+ #localizeToolsModule;
18
+ constructor(pluginOptions, i18nOptions) {
19
+ this.#pluginOptions = pluginOptions;
20
+ this.#i18n = i18nOptions;
21
+ }
22
+ apply(compiler) {
23
+ compiler.hooks.emit.tapAsync(PLUGIN_NAME, async (compilation, callback) => {
24
+ const filesToInline = new Map();
25
+ const additionalFiles = new Map();
26
+ for (const [filename, source] of Object.entries(compilation.assets)) {
27
+ let contents = source.source();
28
+ if (typeof contents !== 'string') {
29
+ contents = contents.toString();
30
+ }
31
+ if (!filename.endsWith('.map') && contents.includes('$localize')) {
32
+ filesToInline.set(filename, { text: contents, map: source.map() });
33
+ }
34
+ else {
35
+ additionalFiles.set(filename, source);
36
+ }
37
+ }
38
+ // Map of locales to Map of files to output
39
+ const filesToOutput = new Map();
40
+ for (const localeKey of this.#i18n.inlineLocales) {
41
+ const locale = this.#i18n.locales[localeKey];
42
+ const localeFiles = new Map();
43
+ for (const [filename, { text, map }] of filesToInline.entries()) {
44
+ const result = await this.#transformWithBabel(text, map, filename, localeKey, locale.translation, this.#pluginOptions.advancedOptimizations);
45
+ localeFiles.set(filename, { text: result.code, map: result.map });
46
+ // TODO: Add support for diagnostics
47
+ }
48
+ for (const [filename, source] of additionalFiles.entries()) {
49
+ localeFiles.set(filename, {
50
+ text: source.source(),
51
+ map: source.map(),
52
+ });
53
+ }
54
+ filesToOutput.set(locale.subPath, localeFiles);
55
+ }
56
+ for (const [localeSubPath, files] of filesToOutput.entries()) {
57
+ for (const [filename, { text, map }] of files.entries()) {
58
+ const localeFileName = `${localeSubPath}/${filename}`;
59
+ if (localeFileName.endsWith('index.html')) {
60
+ // update the baseHref for the locale and set the lang attribute
61
+ const html = typeof text === 'string' ? text : text.toString();
62
+ const updatedHtml = await this.#updateBaseHrefAndLang(html, localeSubPath);
63
+ compilation.emitAsset(localeFileName, new core_1.sources.RawSource(updatedHtml));
64
+ if (compilation.getAsset(filename)) {
65
+ compilation.deleteAsset(filename);
66
+ }
67
+ continue;
68
+ }
69
+ if (map) {
70
+ compilation.emitAsset(localeFileName, new core_1.sources.SourceMapSource(text, localeFileName, map));
71
+ }
72
+ compilation.emitAsset(localeFileName, new core_1.sources.RawSource(text));
73
+ if (compilation.getAsset(filename)) {
74
+ compilation.deleteAsset(filename);
75
+ }
76
+ }
77
+ }
78
+ callback();
79
+ });
80
+ }
81
+ async #updateBaseHrefAndLang(html, localeSubPath) {
82
+ // TODO: add support for diagnostics
83
+ const dir = localeSubPath
84
+ ? await this.#getLanguageDirection(localeSubPath, [])
85
+ : undefined;
86
+ html = html.replace(/<base href="([^"]+)">/g, `<base href="/${localeSubPath}$1">`);
87
+ html = html.replace(/<html lang="([^"]+)">/g, `<html lang="${localeSubPath}"${dir ? ` dir="${dir}"` : ''}>`);
88
+ return html;
89
+ }
90
+ /**
91
+ * Attempts to load the `@angular/localize/tools` module containing the functionality to
92
+ * perform the file translations.
93
+ * This module must be dynamically loaded as it is an ESM module and this file is CommonJS.
94
+ */
95
+ async #loadLocalizeTools() {
96
+ // Load ESM `@angular/localize/tools` using the TypeScript dynamic import workaround.
97
+ // Once TypeScript provides support for keeping the dynamic import this workaround can be
98
+ // changed to a direct dynamic import.
99
+ this.#localizeToolsModule ??=
100
+ await this.#loadEsmModule('@angular/localize/tools');
101
+ }
102
+ /**
103
+ * Creates the needed Babel plugins to inline a given locale and translation for a JavaScript file.
104
+ * @param locale A string containing the locale specifier to use.
105
+ * @param translation A object record containing locale specific messages to use.
106
+ * @returns An array of Babel plugins.
107
+ */
108
+ async #createI18nPlugins(locale, translation) {
109
+ await this.#loadLocalizeTools();
110
+ const { Diagnostics, makeEs2015TranslatePlugin } =
111
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
112
+ this.#localizeToolsModule;
113
+ const plugins = [];
114
+ const diagnostics = new Diagnostics();
115
+ plugins.push(makeEs2015TranslatePlugin(diagnostics, (translation || {}), {
116
+ missingTranslation: translation === undefined
117
+ ? 'ignore'
118
+ : this.#pluginOptions.i18nMissingTranslation,
119
+ }));
120
+ // Create a plugin to replace the locale specifier constant inject by the build system with the actual specifier
121
+ plugins.push({
122
+ visitor: {
123
+ StringLiteral(path) {
124
+ if (path.node.value === '___NG_LOCALE_INSERT___') {
125
+ path.replaceWith(core_2.types.stringLiteral(locale));
126
+ }
127
+ },
128
+ },
129
+ });
130
+ return { diagnostics, plugins };
131
+ }
132
+ #loadEsmModule(modulePath) {
133
+ const load = new Function('modulePath', `return import(modulePath);`);
134
+ return load(modulePath);
135
+ }
136
+ #assertIsError(value) {
137
+ const isError = value instanceof Error ||
138
+ // The following is needing to identify errors coming from RxJs.
139
+ (typeof value === 'object' &&
140
+ value &&
141
+ 'name' in value &&
142
+ 'message' in value);
143
+ (0, node_assert_1.default)(isError, 'catch clause variable is not an Error instance');
144
+ }
145
+ /**
146
+ * Transforms a JavaScript file using Babel to inline the request locale and translation.
147
+ * @param code A string containing the JavaScript code to transform.
148
+ * @param map A sourcemap object for the provided JavaScript code.
149
+ * @param options The inline request options to use.
150
+ * @returns An object containing the code, map, and diagnostics from the transformation.
151
+ */
152
+ async #transformWithBabel(code, map, filename, locale, translation, shouldOptimize) {
153
+ let ast;
154
+ try {
155
+ ast = (0, core_2.parseSync)(code, {
156
+ babelrc: false,
157
+ configFile: false,
158
+ sourceType: 'unambiguous',
159
+ filename,
160
+ });
161
+ }
162
+ catch (error) {
163
+ this.#assertIsError(error);
164
+ // Make the error more readable.
165
+ // Same errors will contain the full content of the file as the error message
166
+ // Which makes it hard to find the actual error message.
167
+ const index = error.message.indexOf(')\n');
168
+ const msg = index !== -1 ? error.message.slice(0, index + 1) : error.message;
169
+ throw new Error(`${msg}\nAn error occurred inlining file "${filename}"`);
170
+ }
171
+ if (!ast) {
172
+ throw new Error(`Unknown error occurred inlining file "${filename}"`);
173
+ }
174
+ const { diagnostics, plugins } = await this.#createI18nPlugins(locale, translation);
175
+ const transformResult = await (0, core_2.transformFromAstAsync)(ast, code, {
176
+ filename,
177
+ // false is a valid value but not included in the type definition
178
+ inputSourceMap: false,
179
+ sourceMaps: !!map,
180
+ compact: shouldOptimize,
181
+ configFile: false,
182
+ babelrc: false,
183
+ browserslistConfigFile: false,
184
+ plugins,
185
+ });
186
+ if (!transformResult || !transformResult.code) {
187
+ throw new Error(`Unknown error occurred processing bundle for "${filename}".`);
188
+ }
189
+ let outputMap;
190
+ if (map && transformResult.map) {
191
+ outputMap = (0, remapping_1.default)([transformResult.map, map], () => null);
192
+ }
193
+ return {
194
+ code: transformResult.code,
195
+ map: outputMap && JSON.stringify(outputMap),
196
+ diagnostics,
197
+ };
198
+ }
199
+ async #getLanguageDirection(locale, warnings) {
200
+ const dir = await this.#getLanguageDirectionFromLocales(locale);
201
+ if (!dir) {
202
+ warnings.push(`Locale data for '${locale}' cannot be found. 'dir' attribute will not be set for this locale.`);
203
+ }
204
+ return dir;
205
+ }
206
+ async #getLanguageDirectionFromLocales(locale) {
207
+ try {
208
+ const localeData = (await this.#loadEsmModule(`@angular/common/locales/${locale}`)).default;
209
+ const dir = localeData[localeData.length - 2];
210
+ return this.#isString(dir) ? dir : undefined;
211
+ }
212
+ catch {
213
+ // In some cases certain locales might map to files which are named only with language id.
214
+ // Example: `en-US` -> `en`.
215
+ const [languageId] = locale.split('-', 1);
216
+ if (languageId !== locale) {
217
+ return this.#getLanguageDirectionFromLocales(languageId);
218
+ }
219
+ }
220
+ return undefined;
221
+ }
222
+ #isString(value) {
223
+ return typeof value === 'string';
224
+ }
225
+ }
226
+ exports.I18nInlinePlugin = I18nInlinePlugin;
@@ -1,8 +1,9 @@
1
1
  import { Compiler, RspackPluginInstance } from '@rspack/core';
2
- import { NormalizedAngularRspackPluginOptions } from '../models';
2
+ import { I18nOptions, NormalizedAngularRspackPluginOptions } from '../models';
3
3
  export declare class NgRspackPlugin implements RspackPluginInstance {
4
4
  pluginOptions: NormalizedAngularRspackPluginOptions;
5
- constructor(options: NormalizedAngularRspackPluginOptions);
5
+ i18n: I18nOptions | undefined;
6
+ constructor(options: NormalizedAngularRspackPluginOptions, i18nOptions?: I18nOptions);
6
7
  apply(compiler: Compiler): void;
7
8
  }
8
9
  //# sourceMappingURL=ng-rspack.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ng-rspack.d.ts","sourceRoot":"","sources":["../../../src/lib/plugins/ng-rspack.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAMR,oBAAoB,EACrB,MAAM,cAAc,CAAC;AAItB,OAAO,EAAE,oCAAoC,EAAc,MAAM,WAAW,CAAC;AAG7E,qBAAa,cAAe,YAAW,oBAAoB;IACzD,aAAa,EAAE,oCAAoC,CAAC;gBAExC,OAAO,EAAE,oCAAoC;IAIzD,KAAK,CAAC,QAAQ,EAAE,QAAQ;CA2GzB"}
1
+ {"version":3,"file":"ng-rspack.d.ts","sourceRoot":"","sources":["../../../src/lib/plugins/ng-rspack.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAMR,oBAAoB,EACrB,MAAM,cAAc,CAAC;AAKtB,OAAO,EACL,WAAW,EACX,oCAAoC,EAErC,MAAM,WAAW,CAAC;AAGnB,qBAAa,cAAe,YAAW,oBAAoB;IACzD,aAAa,EAAE,oCAAoC,CAAC;IACpD,IAAI,EAAE,WAAW,GAAG,SAAS,CAAC;gBAG5B,OAAO,EAAE,oCAAoC,EAC7C,WAAW,CAAC,EAAE,WAAW;IAM3B,KAAK,CAAC,QAAQ,EAAE,QAAQ;CA+GzB"}
@@ -5,11 +5,14 @@ const core_1 = require("@rspack/core");
5
5
  const node_path_1 = require("node:path");
6
6
  const rxjs_esm_resolution_1 = require("./rxjs-esm-resolution");
7
7
  const angular_rspack_plugin_1 = require("./angular-rspack-plugin");
8
+ const i18n_inline_plugin_1 = require("./i18n-inline-plugin");
8
9
  const angular_ssr_dev_server_1 = require("./angular-ssr-dev-server");
9
10
  class NgRspackPlugin {
10
11
  pluginOptions;
11
- constructor(options) {
12
+ i18n;
13
+ constructor(options, i18nOptions) {
12
14
  this.pluginOptions = options;
15
+ this.i18n = i18nOptions;
13
16
  }
14
17
  apply(compiler) {
15
18
  const root = this.pluginOptions.root;
@@ -58,6 +61,7 @@ class NgRspackPlugin {
58
61
  ngDevMode: isProduction ? 'false' : {},
59
62
  ngJitMode: this.pluginOptions.aot ? undefined : 'true',
60
63
  ngServerMode: this.pluginOptions.hasServer,
64
+ ...(this.pluginOptions.define ?? {}),
61
65
  }).apply(compiler);
62
66
  if (this.pluginOptions.assets) {
63
67
  new core_1.CopyRspackPlugin({
@@ -100,8 +104,11 @@ class NgRspackPlugin {
100
104
  skipChildCompilers: true,
101
105
  }).apply(compiler);
102
106
  }
107
+ if (this.i18n?.shouldInline) {
108
+ new i18n_inline_plugin_1.I18nInlinePlugin(this.pluginOptions, this.i18n).apply(compiler);
109
+ }
103
110
  new rxjs_esm_resolution_1.RxjsEsmResolutionPlugin().apply(compiler);
104
- new angular_rspack_plugin_1.AngularRspackPlugin(this.pluginOptions).apply(compiler);
111
+ new angular_rspack_plugin_1.AngularRspackPlugin(this.pluginOptions, this.i18n).apply(compiler);
105
112
  }
106
113
  }
107
114
  exports.NgRspackPlugin = NgRspackPlugin;
@@ -0,0 +1,16 @@
1
+ import { ProjectGraphProjectNode } from '@nx/devkit';
2
+ type ProjectRootMappings = Map<string, string>;
3
+ /**
4
+ * This creates a map of project roots to project names to easily look up the project of a file
5
+ * @param nodes This is the nodes from the project graph
6
+ */
7
+ export declare function createProjectRootMappings(nodes: Record<string, ProjectGraphProjectNode>): ProjectRootMappings;
8
+ /**
9
+ * Locates a project in projectRootMap based on a file within it
10
+ * @param filePath path that is inside of projectName. This should be relative from the workspace root
11
+ * @param projectRootMap Map<projectRoot, projectName> Use {@link createProjectRootMappings} to create this
12
+ */
13
+ export declare function findProjectForPath(filePath: string, projectRootMap: ProjectRootMappings): string | undefined;
14
+ export declare function normalizeProjectRoot(root: string): string;
15
+ export {};
16
+ //# sourceMappingURL=find-project-for-path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-project-for-path.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/find-project-for-path.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAiB,MAAM,YAAY,CAAC;AAGpE,KAAK,mBAAmB,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE/C;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,GAC7C,mBAAmB,CAQrB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,mBAAmB,GAClC,MAAM,GAAG,SAAS,CAkBpB;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,UAGhD"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createProjectRootMappings = createProjectRootMappings;
4
+ exports.findProjectForPath = findProjectForPath;
5
+ exports.normalizeProjectRoot = normalizeProjectRoot;
6
+ // TODO: Remove this once migrated to Nx
7
+ const devkit_1 = require("@nx/devkit");
8
+ const node_path_1 = require("node:path");
9
+ /**
10
+ * This creates a map of project roots to project names to easily look up the project of a file
11
+ * @param nodes This is the nodes from the project graph
12
+ */
13
+ function createProjectRootMappings(nodes) {
14
+ const projectRootMappings = new Map();
15
+ for (const projectName of Object.keys(nodes)) {
16
+ const root = nodes[projectName].data.root;
17
+ projectRootMappings.set(normalizeProjectRoot(root), projectName);
18
+ }
19
+ return projectRootMappings;
20
+ }
21
+ /**
22
+ * Locates a project in projectRootMap based on a file within it
23
+ * @param filePath path that is inside of projectName. This should be relative from the workspace root
24
+ * @param projectRootMap Map<projectRoot, projectName> Use {@link createProjectRootMappings} to create this
25
+ */
26
+ function findProjectForPath(filePath, projectRootMap) {
27
+ /**
28
+ * Project Mappings are in UNIX-style file paths
29
+ * Windows may pass Win-style file paths
30
+ * Ensure filePath is in UNIX-style
31
+ */
32
+ let currentPath = (0, devkit_1.normalizePath)(filePath);
33
+ for (; currentPath != (0, node_path_1.dirname)(currentPath); currentPath = (0, node_path_1.dirname)(currentPath)) {
34
+ const p = projectRootMap.get(currentPath);
35
+ if (p) {
36
+ return p;
37
+ }
38
+ }
39
+ return projectRootMap.get(currentPath);
40
+ }
41
+ function normalizeProjectRoot(root) {
42
+ root = root === '' ? '.' : root;
43
+ return root && root.endsWith('/') ? root.substring(0, root.length - 1) : root;
44
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/angular-rspack",
3
- "version": "20.6.2-beta.0",
3
+ "version": "20.7.0-beta.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -44,6 +44,8 @@
44
44
  }
45
45
  },
46
46
  "dependencies": {
47
+ "@ampproject/remapping": "2.3.0",
48
+ "@babel/core": "7.26.10",
47
49
  "@nx/devkit": "^20.0.0",
48
50
  "express": "4.21.1",
49
51
  "css-loader": "^7.1.2",
@@ -57,7 +59,7 @@
57
59
  "tslib": "^2.3.0",
58
60
  "webpack-merge": "^6.0.1",
59
61
  "ws": "^8.18.0",
60
- "@nx/angular-rspack-compiler": "20.6.2-beta.0"
62
+ "@nx/angular-rspack-compiler": "20.7.0-beta.0"
61
63
  },
62
64
  "devDependencies": {
63
65
  "@ng-rspack/testing-setup": "0.0.1"
@@ -65,7 +67,9 @@
65
67
  "peerDependencies": {
66
68
  "@rspack/core": ">=1.0.5 <2.0.0",
67
69
  "@angular/common": ">=19.0.0 <20.0.0",
68
- "@angular/ssr": ">=19.0.0 <20.0.0"
70
+ "@angular/ssr": ">=19.0.0 <20.0.0",
71
+ "@angular/build": ">=19.0.0 <20.0.0",
72
+ "@angular/localize": ">=19.0.0 <20.0.0"
69
73
  },
70
74
  "nx": {
71
75
  "name": "angular-rspack",