@nx/angular-rspack 20.7.0 → 20.8.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 (65) hide show
  1. package/dist/lib/config/create-config.d.ts +75 -2
  2. package/dist/lib/config/create-config.d.ts.map +1 -1
  3. package/dist/lib/config/create-config.js +166 -138
  4. package/dist/lib/config/dev-server-config-utils.d.ts.map +1 -1
  5. package/dist/lib/config/dev-server-config-utils.js +3 -7
  6. package/dist/lib/config/entry-points.d.ts +9 -0
  7. package/dist/lib/config/entry-points.d.ts.map +1 -0
  8. package/dist/lib/config/entry-points.js +36 -0
  9. package/dist/lib/config/i18n/create-i18n-options.d.ts +1 -1
  10. package/dist/lib/config/i18n/create-i18n-options.d.ts.map +1 -1
  11. package/dist/lib/config/i18n/create-i18n-options.js +8 -6
  12. package/dist/lib/config/style-config-utils.d.ts +12 -306
  13. package/dist/lib/config/style-config-utils.d.ts.map +1 -1
  14. package/dist/lib/config/style-config-utils.js +180 -93
  15. package/dist/lib/models/angular-rspack-plugin-options.d.ts +39 -1
  16. package/dist/lib/models/angular-rspack-plugin-options.d.ts.map +1 -1
  17. package/dist/lib/models/normalize-options.d.ts +2 -2
  18. package/dist/lib/models/normalize-options.d.ts.map +1 -1
  19. package/dist/lib/models/normalize-options.js +68 -119
  20. package/dist/lib/models/unsupported-options.d.ts +0 -6
  21. package/dist/lib/models/unsupported-options.d.ts.map +1 -1
  22. package/dist/lib/models/unsupported-options.js +0 -6
  23. package/dist/lib/plugins/angular-rspack-plugin.d.ts +2 -2
  24. package/dist/lib/plugins/angular-rspack-plugin.d.ts.map +1 -1
  25. package/dist/lib/plugins/angular-rspack-plugin.js +33 -26
  26. package/dist/lib/plugins/i18n-inline-plugin.d.ts +2 -2
  27. package/dist/lib/plugins/i18n-inline-plugin.d.ts.map +1 -1
  28. package/dist/lib/plugins/i18n-inline-plugin.js +24 -58
  29. package/dist/lib/plugins/index-html-plugin.d.ts +21 -0
  30. package/dist/lib/plugins/index-html-plugin.d.ts.map +1 -0
  31. package/dist/lib/plugins/index-html-plugin.js +114 -0
  32. package/dist/lib/plugins/ng-rspack.d.ts +8 -4
  33. package/dist/lib/plugins/ng-rspack.d.ts.map +1 -1
  34. package/dist/lib/plugins/ng-rspack.js +41 -39
  35. package/dist/lib/utils/find-project-for-path.d.ts +1 -1
  36. package/dist/lib/utils/find-project-for-path.d.ts.map +1 -1
  37. package/dist/lib/utils/find-project-for-path.js +2 -4
  38. package/dist/lib/utils/get-locale-base-href.d.ts +3 -0
  39. package/dist/lib/utils/get-locale-base-href.d.ts.map +1 -0
  40. package/dist/lib/utils/get-locale-base-href.js +17 -0
  41. package/dist/lib/utils/graph.d.ts +3 -0
  42. package/dist/lib/utils/graph.d.ts.map +1 -0
  43. package/dist/lib/utils/graph.js +25 -0
  44. package/dist/lib/utils/i18n.d.ts +4 -0
  45. package/dist/lib/utils/i18n.d.ts.map +1 -0
  46. package/dist/lib/utils/i18n.js +25 -0
  47. package/dist/lib/utils/index-file/add-event-dispatch-contract.d.ts +9 -0
  48. package/dist/lib/utils/index-file/add-event-dispatch-contract.d.ts.map +1 -0
  49. package/dist/lib/utils/index-file/add-event-dispatch-contract.js +27 -0
  50. package/dist/lib/utils/index-file/html-rewriting-stream.d.ts +16 -0
  51. package/dist/lib/utils/index-file/html-rewriting-stream.d.ts.map +1 -0
  52. package/dist/lib/utils/index-file/html-rewriting-stream.js +27 -0
  53. package/dist/lib/utils/misc-helpers.d.ts +6 -0
  54. package/dist/lib/utils/misc-helpers.d.ts.map +1 -0
  55. package/dist/lib/utils/misc-helpers.js +30 -0
  56. package/dist/lib/utils/rspack-diagnostics.d.ts +4 -0
  57. package/dist/lib/utils/rspack-diagnostics.d.ts.map +1 -0
  58. package/dist/lib/utils/rspack-diagnostics.js +10 -0
  59. package/dist/lib/utils/tailwind.d.ts +2 -0
  60. package/dist/lib/utils/tailwind.d.ts.map +1 -0
  61. package/dist/lib/utils/tailwind.js +31 -0
  62. package/dist/lib/utils/url-join.d.ts +9 -0
  63. package/dist/lib/utils/url-join.d.ts.map +1 -0
  64. package/dist/lib/utils/url-join.js +17 -0
  65. package/package.json +23 -6
@@ -68,7 +68,6 @@ export type IndexExpandedDefinition = {
68
68
  export type IndexElement = IndexExpandedDefinition | string | false;
69
69
  export type IndexHtmlTransform = (content: string) => Promise<string>;
70
70
  export type NormalizedIndexElement = (IndexExpandedDefinition & {
71
- insertionOrder: [string, boolean][];
72
71
  transformer: IndexHtmlTransform | undefined;
73
72
  }) | false;
74
73
  export interface SourceMap {
@@ -80,8 +79,18 @@ export interface SourceMap {
80
79
  export interface AngularRspackPluginOptions extends PluginUnsupportedOptions {
81
80
  aot?: boolean;
82
81
  assets?: AssetElement[];
82
+ /**
83
+ * Base url for the application being built.
84
+ */
85
+ baseHref?: string;
83
86
  browser?: string;
84
87
  commonChunk?: boolean;
88
+ /**
89
+ * Define the `crossorigin` attribute setting of elements that provide CORS
90
+ * support.
91
+ * @default 'none'
92
+ */
93
+ crossOrigin?: 'none' | 'anonymous' | 'use-credentials';
85
94
  /**
86
95
  * Defines global identifiers that will be replaced with a specified constant value when found in any JavaScript or TypeScript code including libraries.
87
96
  * The value will be used directly.
@@ -92,6 +101,13 @@ export interface AngularRspackPluginOptions extends PluginUnsupportedOptions {
92
101
  * Delete the output path before building.
93
102
  */
94
103
  deleteOutputPath?: boolean;
104
+ /**
105
+ * Customize the base path for the URLs of resources in 'index.html' and
106
+ * component stylesheets. This option is only necessary for specific
107
+ * deployment scenarios, such as with Angular Elements or when utilizing
108
+ * different CDN locations.
109
+ */
110
+ deployUrl?: string;
95
111
  devServer?: DevServerOptions;
96
112
  /**
97
113
  * Exclude the listed external dependencies from being bundled into the bundle. Instead, the created bundle relies on these dependencies to be available during runtime.
@@ -118,6 +134,10 @@ export interface AngularRspackPluginOptions extends PluginUnsupportedOptions {
118
134
  */
119
135
  localize?: boolean | string[];
120
136
  namedChunks?: boolean;
137
+ /**
138
+ * Path to ngsw-config.json.
139
+ */
140
+ ngswConfigPath?: string;
121
141
  optimization?: boolean | OptimizationOptions;
122
142
  outputHashing?: OutputHashing;
123
143
  outputPath?: string | (Required<Pick<OutputPath, 'base'>> & Partial<OutputPath>);
@@ -129,6 +149,10 @@ export interface AngularRspackPluginOptions extends PluginUnsupportedOptions {
129
149
  root?: string;
130
150
  scripts?: ScriptOrStyleEntry[];
131
151
  server?: string;
152
+ /**
153
+ * Generates a service worker config for production builds.
154
+ */
155
+ serviceWorker?: boolean;
132
156
  skipTypeChecking?: boolean;
133
157
  sourceMap?: boolean | Partial<SourceMap>;
134
158
  ssr?: boolean | {
@@ -137,9 +161,19 @@ export interface AngularRspackPluginOptions extends PluginUnsupportedOptions {
137
161
  };
138
162
  stylePreprocessorOptions?: StylePreprocessorOptions;
139
163
  styles?: ScriptOrStyleEntry[];
164
+ /**
165
+ * Enables the use of subresource integrity validation.
166
+ * @default false
167
+ */
168
+ subresourceIntegrity?: boolean;
140
169
  tsConfig?: string;
141
170
  useTsProjectReferences?: boolean;
142
171
  vendorChunk?: boolean;
172
+ /**
173
+ * @deprecated This is a no-op and can be safely removed.
174
+ * The tsconfig file for web workers.
175
+ */
176
+ webWorkerTsConfig?: string;
143
177
  }
144
178
  export interface NormalizedAngularRspackPluginOptions extends Omit<AngularRspackPluginOptions, 'index' | 'scripts' | 'styles'> {
145
179
  advancedOptimizations: boolean;
@@ -147,6 +181,7 @@ export interface NormalizedAngularRspackPluginOptions extends Omit<AngularRspack
147
181
  assets: NormalizedAssetElement[];
148
182
  browser: string;
149
183
  commonChunk: boolean;
184
+ crossOrigin: 'none' | 'anonymous' | 'use-credentials';
150
185
  deleteOutputPath: boolean;
151
186
  devServer: NormalizedDevServerOptions;
152
187
  externalDependencies: string[];
@@ -162,8 +197,11 @@ export interface NormalizedAngularRspackPluginOptions extends Omit<AngularRspack
162
197
  outputHashing: OutputHashing;
163
198
  outputPath: OutputPath;
164
199
  polyfills: string[];
200
+ projectName: string | undefined;
165
201
  root: string;
166
202
  sourceMap: SourceMap;
203
+ subresourceIntegrity: boolean;
204
+ supportedBrowsers: string[];
167
205
  tsConfig: string;
168
206
  vendorChunk: boolean;
169
207
  }
@@ -1 +1 @@
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,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AACD,MAAM,WAAW,0BAA2B,SAAQ,gBAAgB;IAClE,YAAY,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,SAAS,CAAC;AACjE,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK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AAE,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,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AACD,MAAM,WAAW,0BAA2B,SAAQ,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AAC;IACrB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;CACtB"}
@@ -1,4 +1,4 @@
1
- import { FileReplacement } from '@nx/angular-rspack-compiler';
1
+ import type { FileReplacement } from '@nx/angular-rspack-compiler';
2
2
  import type { AngularRspackPluginOptions, NormalizedAngularRspackPluginOptions } from './angular-rspack-plugin-options';
3
3
  export declare const INDEX_HTML_CSR = "index.csr.html";
4
4
  /**
@@ -12,5 +12,5 @@ export declare function resolveFileReplacements(fileReplacements: FileReplacemen
12
12
  export declare function getHasServer(root: string, server: string | undefined, ssr: AngularRspackPluginOptions['ssr']): boolean;
13
13
  export declare function validateSsr(ssr: AngularRspackPluginOptions['ssr']): void;
14
14
  export declare function validateOptimization(optimization: AngularRspackPluginOptions['optimization']): void;
15
- export declare function normalizeOptions(options: AngularRspackPluginOptions): NormalizedAngularRspackPluginOptions;
15
+ export declare function normalizeOptions(options: AngularRspackPluginOptions): Promise<NormalizedAngularRspackPluginOptions>;
16
16
  //# sourceMappingURL=normalize-options.d.ts.map
@@ -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,CA6ItC"}
1
+ {"version":3,"file":"normalize-options.d.ts","sourceRoot":"","sources":["../../../src/lib/models/normalize-options.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAmBnE,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,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,oCAAoC,CAAC,CAyK/C"}
@@ -7,10 +7,13 @@ exports.validateSsr = validateSsr;
7
7
  exports.validateOptimization = validateOptimization;
8
8
  exports.normalizeOptions = normalizeOptions;
9
9
  const tslib_1 = require("tslib");
10
+ const private_1 = require("@angular/build/private");
10
11
  const devkit_1 = require("@nx/devkit");
11
12
  const node_assert_1 = tslib_1.__importDefault(require("node:assert"));
12
13
  const node_fs_1 = require("node:fs");
13
14
  const node_path_1 = require("node:path");
15
+ const find_project_for_path_1 = require("../utils/find-project-for-path");
16
+ const graph_1 = require("../utils/graph");
14
17
  const unsupported_options_1 = require("./unsupported-options");
15
18
  exports.INDEX_HTML_CSR = 'index.csr.html';
16
19
  /**
@@ -66,7 +69,7 @@ function validateGeneralUnsupportedOptions(options) {
66
69
  console.warn(`The following options are not yet supported:\n ${unsupportedOptions.join('\n ')}\n`);
67
70
  }
68
71
  }
69
- function normalizeOptions(options) {
72
+ async function normalizeOptions(options) {
70
73
  validateGeneralUnsupportedOptions(options);
71
74
  const { fileReplacements = [], server, ssr, optimization } = options;
72
75
  validateSsr(ssr);
@@ -88,7 +91,7 @@ function normalizeOptions(options) {
88
91
  // @TODO: use this once we support granular optimization options
89
92
  // const advancedOptimizations = aot && normalizedOptimization.scripts;
90
93
  const advancedOptimizations = aot && normalizedOptimization;
91
- const project = getProject(root);
94
+ const project = await getProject(root);
92
95
  const assets = project && options.assets?.length
93
96
  ? normalizeAssetPatterns(options.assets, root, project.data.root, project.data.sourceRoot)
94
97
  : [];
@@ -128,22 +131,29 @@ function normalizeOptions(options) {
128
131
  * This approach can also be applied to service workers, where the `index.csr.html` is served instead of the prerendered `index.html`.
129
132
  */
130
133
  const indexBaseName = (0, node_path_1.basename)(indexOutput);
131
- indexOutput =
132
- // @TODO: use this once we support prerenderOptions
133
- // (normalizedSsr || prerenderOptions) && indexBaseName === 'index.html'
134
- normalizedSsr && indexBaseName === 'index.html'
135
- ? exports.INDEX_HTML_CSR
136
- : indexBaseName;
134
+ // @TODO: use this once we properly support SSR/SSG options
135
+ // (normalizedSsr || prerenderOptions) && indexBaseName === 'index.html'
136
+ // ? INDEX_HTML_CSR
137
+ // : indexBaseName;
138
+ indexOutput = indexBaseName;
139
+ const entryPoints = [
140
+ // TODO: this should be true when !!devServer?.hot (HMR is supported)
141
+ ['runtime', false],
142
+ ['polyfills', true],
143
+ ...globalStyles.filter((s) => s.initial).map((s) => [s.name, false]),
144
+ ...globalScripts
145
+ .filter((s) => s.initial)
146
+ .map((s) => [s.name, false]),
147
+ ['vendor', true],
148
+ ['main', true],
149
+ ];
150
+ const duplicates = entryPoints.filter(([name]) => entryPoints[0].indexOf(name) !== entryPoints[0].lastIndexOf(name));
151
+ if (duplicates.length > 0) {
152
+ throw new Error(`Multiple bundles have been named the same: '${duplicates.join(`', '`)}'.`);
153
+ }
137
154
  index = {
138
155
  input: (0, node_path_1.resolve)(root, typeof options.index === 'string' ? options.index : options.index.input),
139
156
  output: indexOutput,
140
- insertionOrder: [
141
- ['polyfills', true],
142
- ...globalStyles.filter((s) => s.initial).map((s) => [s.name, false]),
143
- ...globalScripts.filter((s) => s.initial).map((s) => [s.name, false]),
144
- ['main', true],
145
- // [name, esm]
146
- ],
147
157
  // @TODO: Add support for transformer
148
158
  transformer: undefined,
149
159
  // Preload initial defaults to true
@@ -155,10 +165,13 @@ function normalizeOptions(options) {
155
165
  advancedOptimizations,
156
166
  assets,
157
167
  aot,
168
+ baseHref: options.baseHref,
158
169
  browser: options.browser ?? './src/main.ts',
159
170
  commonChunk: options.commonChunk ?? true,
171
+ crossOrigin: options.crossOrigin ?? 'none',
160
172
  define: options.define ?? {},
161
173
  deleteOutputPath: options.deleteOutputPath ?? true,
174
+ deployUrl: options.deployUrl,
162
175
  devServer: normalizeDevServer(options.devServer),
163
176
  externalDependencies: options.externalDependencies ?? [],
164
177
  extractLicenses: options.extractLicenses ?? true,
@@ -170,34 +183,39 @@ function normalizeOptions(options) {
170
183
  inlineStyleLanguage: options.inlineStyleLanguage ?? 'css',
171
184
  namedChunks: options.namedChunks ?? false,
172
185
  optimization: normalizedOptimization,
173
- outputHashing: options.outputHashing ?? 'all',
186
+ outputHashing: options.outputHashing ?? 'none',
174
187
  outputPath: normalizeOutputPath(root, options.outputPath),
175
188
  polyfills: options.polyfills ?? [],
189
+ projectName: project?.name ?? undefined,
176
190
  root,
191
+ serviceWorker: options.serviceWorker,
192
+ ngswConfigPath: options.ngswConfigPath,
177
193
  server,
178
194
  skipTypeChecking: options.skipTypeChecking ?? false,
179
195
  sourceMap: normalizeSourceMap(options.sourceMap),
180
196
  ssr: normalizedSsr,
197
+ subresourceIntegrity: options.subresourceIntegrity ?? false,
198
+ supportedBrowsers: (0, private_1.getSupportedBrowsers)(root, { warn: console.warn }),
181
199
  tsConfig,
182
200
  useTsProjectReferences: options.useTsProjectReferences ?? false,
183
201
  vendorChunk: options.vendorChunk ?? false,
184
202
  };
185
203
  }
186
204
  function normalizeSourceMap(sourceMap) {
187
- if (sourceMap === undefined || sourceMap === true) {
205
+ if (sourceMap === undefined) {
188
206
  return {
189
- scripts: true,
190
- styles: true,
207
+ scripts: false,
208
+ styles: false,
191
209
  hidden: false,
192
210
  vendor: false,
193
211
  };
194
212
  }
195
- if (sourceMap === false) {
213
+ if (typeof sourceMap === 'boolean') {
196
214
  return {
197
- scripts: false,
198
- styles: false,
199
- hidden: false,
200
- vendor: false,
215
+ scripts: sourceMap,
216
+ styles: sourceMap,
217
+ hidden: sourceMap,
218
+ vendor: sourceMap,
201
219
  };
202
220
  }
203
221
  return {
@@ -225,48 +243,20 @@ function normalizeDevServer(devServer) {
225
243
  };
226
244
  }
227
245
  function normalizeOutputPath(root, outputPath) {
228
- const defaultBase = (0, node_path_1.join)(root, 'dist');
229
- const defaultBrowser = (0, node_path_1.join)(defaultBase, 'browser');
230
- if (!outputPath) {
231
- return {
232
- base: defaultBase,
233
- browser: defaultBrowser,
234
- server: (0, node_path_1.join)(defaultBase, 'server'),
235
- media: (0, node_path_1.join)(defaultBrowser, 'media'),
236
- };
237
- }
238
- if (typeof outputPath === 'string') {
239
- if (!outputPath.startsWith(root)) {
240
- outputPath = (0, node_path_1.join)(root, outputPath);
241
- }
242
- return {
243
- base: outputPath,
244
- browser: (0, node_path_1.join)(outputPath, 'browser'),
245
- server: (0, node_path_1.join)(outputPath, 'server'),
246
- media: (0, node_path_1.join)(outputPath, 'browser', 'media'),
247
- };
248
- }
249
- if (outputPath.base && !outputPath.base.startsWith(root)) {
250
- outputPath.base = (0, node_path_1.join)(root, outputPath.base);
246
+ let base = typeof outputPath === 'string' ? outputPath : outputPath?.base ?? 'dist';
247
+ if (!base.startsWith(root)) {
248
+ base = (0, node_path_1.join)(root, base);
251
249
  }
252
- if (outputPath.browser && !outputPath.browser.startsWith(root)) {
253
- outputPath.browser = (0, node_path_1.join)(root, outputPath.browser);
254
- }
255
- if (outputPath.server && !outputPath.server.startsWith(root)) {
256
- outputPath.server = (0, node_path_1.join)(root, outputPath.server);
257
- }
258
- if (outputPath.browser &&
259
- !outputPath.browser.startsWith(outputPath.browser)) {
260
- outputPath.browser = (0, node_path_1.join)(outputPath.browser, outputPath.browser);
261
- }
262
- const providedBase = outputPath.base ?? defaultBase;
263
- const providedBrowser = outputPath.browser ?? (0, node_path_1.join)(providedBase, 'browser');
264
- return {
265
- base: providedBase,
266
- browser: providedBrowser,
267
- server: outputPath.server ?? (0, node_path_1.join)(outputPath.base ?? defaultBase, 'server'),
268
- media: outputPath.media ?? (0, node_path_1.join)(providedBrowser, 'media'),
269
- };
250
+ const browser = typeof outputPath === 'string' || !outputPath?.browser
251
+ ? (0, node_path_1.join)(base, 'browser')
252
+ : (0, node_path_1.join)(base, outputPath.browser);
253
+ const server = typeof outputPath === 'string' || !outputPath?.server
254
+ ? (0, node_path_1.join)(base, 'server')
255
+ : (0, node_path_1.join)(base, outputPath.server);
256
+ const media = typeof outputPath === 'string' || !outputPath?.media
257
+ ? (0, node_path_1.join)(browser, 'media')
258
+ : (0, node_path_1.join)(browser, outputPath.media);
259
+ return { base, browser, server, media };
270
260
  }
271
261
  function normalizeAssetPatterns(assets, root, projectRoot, projectSourceRoot) {
272
262
  if (assets.length === 0) {
@@ -319,13 +309,11 @@ function normalizeAssetPatterns(assets, root, projectRoot, projectSourceRoot) {
319
309
  return assetPattern;
320
310
  });
321
311
  }
322
- function normalizeGlobalEntries(rawEntries, _defaultName) {
312
+ function normalizeGlobalEntries(rawEntries, defaultName) {
323
313
  if (!rawEntries?.length) {
324
314
  return [];
325
315
  }
326
316
  const bundles = new Map();
327
- let warnForInject = false;
328
- let warnForBundleName = false;
329
317
  for (const rawEntry of rawEntries) {
330
318
  let entry;
331
319
  if (typeof rawEntry === 'string') {
@@ -336,52 +324,32 @@ function normalizeGlobalEntries(rawEntries, _defaultName) {
336
324
  entry = rawEntry;
337
325
  }
338
326
  const { bundleName, input, inject = true } = entry;
339
- // @TODO: remove this once we support inject
340
- if (inject === false) {
341
- warnForInject = true;
342
- }
343
- // @TODO: remove this once we support bundleName
344
- if (bundleName) {
345
- warnForBundleName = true;
346
- }
347
- // @TODO: use this once we support inject and bundleName
348
327
  // Non-injected entries default to the file name
349
- // const name =
350
- // bundleName || (inject ? defaultName : basename(input, extname(input)));
351
- const name = (0, node_path_1.basename)(input, (0, node_path_1.extname)(input));
328
+ const name = bundleName || (inject ? defaultName : (0, node_path_1.basename)(input, (0, node_path_1.extname)(input)));
352
329
  const existing = bundles.get(name);
353
330
  if (!existing) {
354
- // @TODO: use this once we support inject
355
- // bundles.set(name, { name, files: [input], initial: inject });
356
- bundles.set(name, { name, files: [input], initial: true });
331
+ bundles.set(name, { name, files: [input], initial: inject });
357
332
  continue;
358
333
  }
359
- // @TODO: uncomment this once we support inject
360
- // if (existing.initial !== inject) {
361
- // throw new Error(
362
- // `The "${name}" bundle is mixing injected and non-injected entries. ` +
363
- // 'Verify that the project options are correct.'
364
- // );
365
- // }
334
+ if (existing.initial !== inject) {
335
+ throw new Error(`The "${name}" bundle is mixing injected and non-injected entries. ` +
336
+ 'Verify that the project options are correct.');
337
+ }
366
338
  existing.files.push(input);
367
339
  }
368
- if (warnForInject) {
369
- console.warn(`The "inject" option for scripts/styles is not yet supported.`);
370
- }
371
- if (warnForBundleName) {
372
- console.warn(`The "bundleName" option for scripts/styles is not yet supported.`);
373
- }
374
340
  return [...bundles.values()];
375
341
  }
376
- function getProject(root) {
342
+ async function getProject(root) {
377
343
  if (global.NX_GRAPH_CREATION) {
378
344
  return undefined;
379
345
  }
380
- const projectGraph = (0, devkit_1.readCachedProjectGraph)();
346
+ const projectGraph = await (0, graph_1.retrieveOrCreateProjectGraph)();
347
+ (0, node_assert_1.default)(projectGraph, 'Cannot find the project. Please make sure to run this task with the Nx CLI and set "root" to a directory contained in a project.');
381
348
  let projectName = process.env.NX_TASK_TARGET_PROJECT;
382
349
  if (!projectName) {
383
350
  const projectRootMappings = createProjectRootMappings(projectGraph.nodes);
384
- projectName = findProjectForPath(root, projectRootMappings) ?? undefined;
351
+ projectName =
352
+ (0, find_project_for_path_1.findProjectForPath)(node_path_1.posix.relative(devkit_1.workspaceRoot, root), projectRootMappings) ?? undefined;
385
353
  }
386
354
  (0, node_assert_1.default)(projectName, 'Cannot find the project. Please make sure to run this task with the Nx CLI and set "root" to a directory contained in a project.');
387
355
  return projectGraph.nodes[projectName];
@@ -390,26 +358,7 @@ function createProjectRootMappings(nodes) {
390
358
  const projectRootMappings = new Map();
391
359
  for (const projectName of Object.keys(nodes)) {
392
360
  const root = nodes[projectName].data.root;
393
- projectRootMappings.set(normalizeProjectRoot(root), projectName);
361
+ projectRootMappings.set((0, find_project_for_path_1.normalizeProjectRoot)(root), projectName);
394
362
  }
395
363
  return projectRootMappings;
396
364
  }
397
- function findProjectForPath(filePath, projectRootMap) {
398
- /**
399
- * Project Mappings are in UNIX-style file paths
400
- * Windows may pass Win-style file paths
401
- * Ensure filePath is in UNIX-style
402
- */
403
- let currentPath = (0, devkit_1.normalizePath)(filePath);
404
- for (; currentPath != (0, node_path_1.dirname)(currentPath); currentPath = (0, node_path_1.dirname)(currentPath)) {
405
- const p = projectRootMap.get(currentPath);
406
- if (p) {
407
- return p;
408
- }
409
- }
410
- return projectRootMap.get(currentPath);
411
- }
412
- function normalizeProjectRoot(root) {
413
- root = root === '' ? '.' : root;
414
- return root && root.endsWith('/') ? root.substring(0, root.length - 1) : root;
415
- }
@@ -21,24 +21,18 @@ export interface DevServerUnsupportedOptions {
21
21
  };
22
22
  }
23
23
  export interface PluginUnsupportedOptions {
24
- deployUrl?: string;
25
24
  security?: {
26
25
  autoCsp?: boolean | {
27
26
  unsafeEval?: boolean;
28
27
  };
29
28
  };
30
29
  clearScreen?: boolean;
31
- baseHref?: string;
32
30
  verbose?: boolean;
33
31
  progress?: boolean;
34
32
  watch?: boolean;
35
33
  poll?: number;
36
- subresourceIntegrity?: boolean;
37
- serviceWorker?: string | false;
38
34
  statsJson?: boolean;
39
35
  budgets?: BudgetEntry[];
40
- webWorkerTsConfig?: string;
41
- crossOrigin?: 'none' | 'anonymous' | 'use-credentials';
42
36
  allowedCommonJsDependencies?: string[];
43
37
  prerender?: boolean | {
44
38
  routesFile?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"unsupported-options.d.ts","sourceRoot":"","sources":["../../../src/lib/models/unsupported-options.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EACA,KAAK,GACL,WAAW,GACX,KAAK,GACL,WAAW,GACX,mBAAmB,GACnB,QAAQ,GACR,SAAS,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,WAAW,2BAA2B;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3B,SAAS,CAAC,EACN,OAAO,GACP;QACE,OAAO,EAAE,MAAM,EAAE,CAAC;KACnB,CAAC;CACP;AAED,MAAM,WAAW,wBAAwB;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE;QACT,OAAO,CAAC,EACJ,OAAO,GACP;YACE,UAAU,CAAC,EAAE,OAAO,CAAC;SACtB,CAAC;KACP,CAAC;IACF,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,aAAa,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,WAAW,EAAE,CAAC;IACxB,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"}
1
+ {"version":3,"file":"unsupported-options.d.ts","sourceRoot":"","sources":["../../../src/lib/models/unsupported-options.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG;IAC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,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,UAa7C,CAAC;AAEF,eAAO,MAAM,kCAAkC,UAQ9C,CAAC"}
@@ -2,20 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DEV_SERVER_OPTIONS_PENDING_SUPPORT = exports.TOP_LEVEL_OPTIONS_PENDING_SUPPORT = void 0;
4
4
  exports.TOP_LEVEL_OPTIONS_PENDING_SUPPORT = [
5
- 'deployUrl',
6
5
  'security',
7
6
  'clearScreen',
8
- 'baseHref',
9
7
  'verbose',
10
8
  'progress',
11
9
  'watch',
12
10
  'poll',
13
- 'subresourceIntegrity',
14
- 'serviceWorker',
15
11
  'statsJson',
16
12
  'budgets',
17
- 'webWorkerTsConfig',
18
- 'crossOrigin',
19
13
  'allowedCommonJsDependencies',
20
14
  'prerender',
21
15
  'appShell',
@@ -1,5 +1,5 @@
1
- import { Compiler, RspackPluginInstance } from '@rspack/core';
2
- import { I18nOptions, type NormalizedAngularRspackPluginOptions } from '../models';
1
+ import { type Compiler, type RspackPluginInstance } from '@rspack/core';
2
+ import { type I18nOptions, type NormalizedAngularRspackPluginOptions } from '../models';
3
3
  export declare class AngularRspackPlugin implements RspackPluginInstance {
4
4
  #private;
5
5
  constructor(options: NormalizedAngularRspackPluginOptions, i18nOptions?: I18nOptions);
@@ -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,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"}
1
+ {"version":3,"file":"angular-rspack-plugin.d.ts","sourceRoot":"","sources":["../../../src/lib/plugins/angular-rspack-plugin.ts"],"names":[],"mappings":"AASA,OAAO,EACL,KAAK,QAAQ,EAEb,KAAK,oBAAoB,EAE1B,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,KAAK,WAAW,EAGhB,KAAK,oCAAoC,EAC1C,MAAM,WAAW,CAAC;AASnB,qBAAa,mBAAoB,YAAW,oBAAoB;;gBAa5D,OAAO,EAAE,oCAAoC,EAC7C,WAAW,CAAC,EAAE,WAAW;IAuB3B,KAAK,CAAC,QAAQ,EAAE,QAAQ;YAqNV,gBAAgB;CA0B/B"}
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AngularRspackPlugin = void 0;
4
- const tslib_1 = require("tslib");
4
+ const private_1 = require("@angular/build/private");
5
+ const angular_rspack_compiler_1 = require("@nx/angular-rspack-compiler");
6
+ const devkit_1 = require("@nx/devkit");
5
7
  const core_1 = require("@rspack/core");
8
+ const node_path_1 = require("node:path");
6
9
  const models_1 = require("../models");
7
- const angular_rspack_compiler_1 = require("@nx/angular-rspack-compiler");
8
- const path_1 = require("path");
9
- const fs_2 = tslib_1.__importDefault(require("fs"));
10
+ const get_locale_base_href_1 = require("../utils/get-locale-base-href");
10
11
  const PLUGIN_NAME = 'AngularRspackPlugin';
11
12
  class AngularRspackPlugin {
12
13
  #_options;
@@ -87,25 +88,19 @@ class AngularRspackPlugin {
87
88
  if (assetNameWithoutHash !== 'main.js') {
88
89
  continue;
89
90
  }
90
- const originalSource = asset.source.source();
91
- let updatedSourceContent = typeof originalSource === 'string'
92
- ? originalSource
93
- : originalSource.toString();
91
+ const originalSource = asset.source;
92
+ let setLocaleContent = '';
94
93
  if (this.#i18n?.shouldInline) {
95
94
  // When inlining, a placeholder is used to allow the post-processing step to inject the $localize locale identifier.
96
- updatedSourceContent +=
95
+ setLocaleContent +=
97
96
  '(globalThis.$localize ??= {}).locale = "___NG_LOCALE_INSERT___";\n';
98
97
  }
99
98
  else if (this.#i18n?.hasDefinedSourceLocale) {
100
99
  // If not inlining translations and source locale is defined, inject the locale specifier.
101
- updatedSourceContent += `(globalThis.$localize ??= {}).locale = "${this.#i18n.sourceLocale}";\n`;
100
+ setLocaleContent += `(globalThis.$localize ??= {}).locale = "${this.#i18n.sourceLocale}";\n`;
102
101
  }
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);
102
+ const concatLocaleSource = new core_1.sources.ConcatSource(setLocaleContent, originalSource);
103
+ compilation.updateAsset(assetName, concatLocaleSource);
109
104
  }
110
105
  });
111
106
  });
@@ -141,7 +136,7 @@ class AngularRspackPlugin {
141
136
  normalModuleFactory.hooks.beforeResolve.tap(PLUGIN_NAME, (data) => {
142
137
  if (data.request.startsWith('angular:jit:')) {
143
138
  const path = data.request.split(';')[1];
144
- data.request = `${(0, path_1.normalize)((0, path_1.resolve)((0, path_1.dirname)(data.contextInfo.issuer), path))}?raw`;
139
+ data.request = `${(0, node_path_1.normalize)((0, node_path_1.resolve)((0, node_path_1.dirname)(data.contextInfo.issuer), path))}?raw`;
145
140
  }
146
141
  });
147
142
  });
@@ -153,16 +148,28 @@ class AngularRspackPlugin {
153
148
  i18n: this.#i18n,
154
149
  });
155
150
  });
156
- compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
157
- const htmlRspackPluginHooks = core_1.HtmlRspackPlugin.getCompilationHooks(compilation);
158
- htmlRspackPluginHooks.beforeEmit.tap(PLUGIN_NAME, (data) => {
159
- const ngJsDispatchEvent = `<script type="text/javascript" id="ng-event-dispatch-contract">
160
- ${fs_2.default.readFileSync(require.resolve('@angular/core/event-dispatch-contract.min.js'), 'utf-8')}
161
- </script>`;
162
- data.html = data.html.replace('</body>', `${ngJsDispatchEvent}</body>`);
163
- return data;
151
+ if (this.#_options.serviceWorker) {
152
+ compiler.hooks.done.tapAsync(PLUGIN_NAME, async (compilation, callback) => {
153
+ let providedLocales = this.#_options.localize;
154
+ if (!providedLocales) {
155
+ await (0, private_1.augmentAppWithServiceWorker)(this.#_options.root, devkit_1.workspaceRoot, this.#_options.outputPath.browser, this.#_options.baseHref ?? '/', this.#_options.ngswConfigPath);
156
+ }
157
+ else if (providedLocales && this.#i18n) {
158
+ if (typeof providedLocales === 'string') {
159
+ providedLocales = [providedLocales];
160
+ }
161
+ else if (typeof providedLocales === 'boolean') {
162
+ providedLocales = Array.from(this.#i18n.inlineLocales);
163
+ }
164
+ for (const locale of providedLocales) {
165
+ await (0, private_1.augmentAppWithServiceWorker)(this.#_options.root, devkit_1.workspaceRoot, (0, node_path_1.join)(this.#_options.outputPath.browser, this.#i18n.locales[locale]?.subPath ?? locale), (0, get_locale_base_href_1.getLocaleBaseHref)(this.#i18n, locale, this.#_options.baseHref) ??
166
+ this.#_options.baseHref ??
167
+ '/', this.#_options.ngswConfigPath);
168
+ }
169
+ }
170
+ callback();
164
171
  });
165
- });
172
+ }
166
173
  }
167
174
  async setupCompilation(root, tsConfig) {
168
175
  const tsconfigPath = tsConfig
@@ -1,5 +1,5 @@
1
- import { RspackPluginInstance, Compiler } from '@rspack/core';
2
- import { I18nOptions, NormalizedAngularRspackPluginOptions } from '../models';
1
+ import { type Compiler, type RspackPluginInstance } from '@rspack/core';
2
+ import type { I18nOptions, NormalizedAngularRspackPluginOptions } from '../models';
3
3
  export declare class I18nInlinePlugin implements RspackPluginInstance {
4
4
  #private;
5
5
  constructor(pluginOptions: NormalizedAngularRspackPluginOptions, i18nOptions: I18nOptions);
@@ -1 +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"}
1
+ {"version":3,"file":"i18n-inline-plugin.d.ts","sourceRoot":"","sources":["../../../src/lib/plugins/i18n-inline-plugin.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,oBAAoB,EAE1B,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EACV,WAAW,EACX,oCAAoC,EACrC,MAAM,WAAW,CAAC;AAWnB,qBAAa,gBAAiB,YAAW,oBAAoB;;gBAWzD,aAAa,EAAE,oCAAoC,EACnD,WAAW,EAAE,WAAW;IAO1B,KAAK,CAAC,QAAQ,EAAE,QAAQ;CA8NzB"}