@nx/angular-rspack 0.0.0-pr-32422-a3285be

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 (193) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +98 -0
  3. package/README.md__tpl__ +48 -0
  4. package/dist/lib/config/config-utils/browser-config.d.ts +4 -0
  5. package/dist/lib/config/config-utils/browser-config.d.ts.map +1 -0
  6. package/dist/lib/config/config-utils/browser-config.js +83 -0
  7. package/dist/lib/config/config-utils/common-config.d.ts +3 -0
  8. package/dist/lib/config/config-utils/common-config.d.ts.map +1 -0
  9. package/dist/lib/config/config-utils/common-config.js +144 -0
  10. package/dist/lib/config/config-utils/dev-server-config-utils.d.ts +4 -0
  11. package/dist/lib/config/config-utils/dev-server-config-utils.d.ts.map +1 -0
  12. package/dist/lib/config/config-utils/dev-server-config-utils.js +258 -0
  13. package/dist/lib/config/config-utils/entry-points.d.ts +9 -0
  14. package/dist/lib/config/config-utils/entry-points.d.ts.map +1 -0
  15. package/dist/lib/config/config-utils/entry-points.js +36 -0
  16. package/dist/lib/config/config-utils/get-stats-options.d.ts +3 -0
  17. package/dist/lib/config/config-utils/get-stats-options.d.ts.map +1 -0
  18. package/dist/lib/config/config-utils/get-stats-options.js +39 -0
  19. package/dist/lib/config/config-utils/helpers.d.ts +13 -0
  20. package/dist/lib/config/config-utils/helpers.d.ts.map +1 -0
  21. package/dist/lib/config/config-utils/helpers.js +106 -0
  22. package/dist/lib/config/config-utils/optimization-config.d.ts +5 -0
  23. package/dist/lib/config/config-utils/optimization-config.d.ts.map +1 -0
  24. package/dist/lib/config/config-utils/optimization-config.js +69 -0
  25. package/dist/lib/config/config-utils/server-config.d.ts +4 -0
  26. package/dist/lib/config/config-utils/server-config.d.ts.map +1 -0
  27. package/dist/lib/config/config-utils/server-config.js +92 -0
  28. package/dist/lib/config/config-utils/sourcemap-utils.d.ts +7 -0
  29. package/dist/lib/config/config-utils/sourcemap-utils.d.ts.map +1 -0
  30. package/dist/lib/config/config-utils/sourcemap-utils.js +48 -0
  31. package/dist/lib/config/config-utils/style-config-utils.d.ts +7 -0
  32. package/dist/lib/config/config-utils/style-config-utils.d.ts.map +1 -0
  33. package/dist/lib/config/config-utils/style-config-utils.js +353 -0
  34. package/dist/lib/config/config-utils/user-defined-config-helpers.d.ts +73 -0
  35. package/dist/lib/config/config-utils/user-defined-config-helpers.d.ts.map +1 -0
  36. package/dist/lib/config/config-utils/user-defined-config-helpers.js +23 -0
  37. package/dist/lib/config/create-config.d.ts +11 -0
  38. package/dist/lib/config/create-config.d.ts.map +1 -0
  39. package/dist/lib/config/create-config.js +35 -0
  40. package/dist/lib/config/i18n/create-i18n-options.d.ts +6 -0
  41. package/dist/lib/config/i18n/create-i18n-options.d.ts.map +1 -0
  42. package/dist/lib/config/i18n/create-i18n-options.js +124 -0
  43. package/dist/lib/index.d.ts +7 -0
  44. package/dist/lib/index.d.ts.map +1 -0
  45. package/dist/lib/index.js +14 -0
  46. package/dist/lib/models/angular-rspack-plugin-options.d.ts +344 -0
  47. package/dist/lib/models/angular-rspack-plugin-options.d.ts.map +1 -0
  48. package/dist/lib/models/angular-rspack-plugin-options.js +2 -0
  49. package/dist/lib/models/augmented-compilation.d.ts +13 -0
  50. package/dist/lib/models/augmented-compilation.d.ts.map +1 -0
  51. package/dist/lib/models/augmented-compilation.js +4 -0
  52. package/dist/lib/models/i18n.d.ts +33 -0
  53. package/dist/lib/models/i18n.d.ts.map +1 -0
  54. package/dist/lib/models/i18n.js +41 -0
  55. package/dist/lib/models/index.d.ts +5 -0
  56. package/dist/lib/models/index.d.ts.map +1 -0
  57. package/dist/lib/models/index.js +7 -0
  58. package/dist/lib/models/normalize-options.d.ts +16 -0
  59. package/dist/lib/models/normalize-options.d.ts.map +1 -0
  60. package/dist/lib/models/normalize-options.js +424 -0
  61. package/dist/lib/plugins/angular-rspack-plugin.d.ts +9 -0
  62. package/dist/lib/plugins/angular-rspack-plugin.d.ts.map +1 -0
  63. package/dist/lib/plugins/angular-rspack-plugin.js +234 -0
  64. package/dist/lib/plugins/angular-ssr-dev-server.d.ts +8 -0
  65. package/dist/lib/plugins/angular-ssr-dev-server.d.ts.map +1 -0
  66. package/dist/lib/plugins/angular-ssr-dev-server.js +62 -0
  67. package/dist/lib/plugins/any-component-style-budget-checker-plugin.d.ts +19 -0
  68. package/dist/lib/plugins/any-component-style-budget-checker-plugin.d.ts.map +1 -0
  69. package/dist/lib/plugins/any-component-style-budget-checker-plugin.js +64 -0
  70. package/dist/lib/plugins/client/ssr-reload-client.d.ts +2 -0
  71. package/dist/lib/plugins/client/ssr-reload-client.d.ts.map +1 -0
  72. package/dist/lib/plugins/client/ssr-reload-client.js +15 -0
  73. package/dist/lib/plugins/i18n-inline-plugin.d.ts +8 -0
  74. package/dist/lib/plugins/i18n-inline-plugin.d.ts.map +1 -0
  75. package/dist/lib/plugins/i18n-inline-plugin.js +201 -0
  76. package/dist/lib/plugins/index-html-plugin.d.ts +21 -0
  77. package/dist/lib/plugins/index-html-plugin.d.ts.map +1 -0
  78. package/dist/lib/plugins/index-html-plugin.js +107 -0
  79. package/dist/lib/plugins/loaders/angular-partial-transform.loader.d.ts +3 -0
  80. package/dist/lib/plugins/loaders/angular-partial-transform.loader.d.ts.map +1 -0
  81. package/dist/lib/plugins/loaders/angular-partial-transform.loader.js +39 -0
  82. package/dist/lib/plugins/loaders/angular-transform.loader.d.ts +7 -0
  83. package/dist/lib/plugins/loaders/angular-transform.loader.d.ts.map +1 -0
  84. package/dist/lib/plugins/loaders/angular-transform.loader.js +40 -0
  85. package/dist/lib/plugins/loaders/hmr-accept-loader.d.ts +11 -0
  86. package/dist/lib/plugins/loaders/hmr-accept-loader.d.ts.map +1 -0
  87. package/dist/lib/plugins/loaders/hmr-accept-loader.js +24 -0
  88. package/dist/lib/plugins/loaders/hmr-accept.d.ts +9 -0
  89. package/dist/lib/plugins/loaders/hmr-accept.d.ts.map +1 -0
  90. package/dist/lib/plugins/loaders/hmr-accept.js +183 -0
  91. package/dist/lib/plugins/loaders/platform-server-exports.loader.d.ts +5 -0
  92. package/dist/lib/plugins/loaders/platform-server-exports.loader.d.ts.map +1 -0
  93. package/dist/lib/plugins/loaders/platform-server-exports.loader.js +18 -0
  94. package/dist/lib/plugins/ng-rspack.d.ts +13 -0
  95. package/dist/lib/plugins/ng-rspack.d.ts.map +1 -0
  96. package/dist/lib/plugins/ng-rspack.js +134 -0
  97. package/dist/lib/plugins/prerender-plugin.d.ts +8 -0
  98. package/dist/lib/plugins/prerender-plugin.d.ts.map +1 -0
  99. package/dist/lib/plugins/prerender-plugin.js +216 -0
  100. package/dist/lib/plugins/progress-plugin.d.ts +12 -0
  101. package/dist/lib/plugins/progress-plugin.d.ts.map +1 -0
  102. package/dist/lib/plugins/progress-plugin.js +36 -0
  103. package/dist/lib/plugins/rxjs-esm-resolution.d.ts +5 -0
  104. package/dist/lib/plugins/rxjs-esm-resolution.d.ts.map +1 -0
  105. package/dist/lib/plugins/rxjs-esm-resolution.js +15 -0
  106. package/dist/lib/plugins/server/ssr-reload-server.d.ts +6 -0
  107. package/dist/lib/plugins/server/ssr-reload-server.d.ts.map +1 -0
  108. package/dist/lib/plugins/server/ssr-reload-server.js +21 -0
  109. package/dist/lib/plugins/stats-json-plugin.d.ts +14 -0
  110. package/dist/lib/plugins/stats-json-plugin.d.ts.map +1 -0
  111. package/dist/lib/plugins/stats-json-plugin.js +69 -0
  112. package/dist/lib/plugins/suppress-js-for-css-chunks-plugin.d.ts +5 -0
  113. package/dist/lib/plugins/suppress-js-for-css-chunks-plugin.d.ts.map +1 -0
  114. package/dist/lib/plugins/suppress-js-for-css-chunks-plugin.js +34 -0
  115. package/dist/lib/plugins/tools/dev-tools-ignore-plugin.d.ts +17 -0
  116. package/dist/lib/plugins/tools/dev-tools-ignore-plugin.d.ts.map +1 -0
  117. package/dist/lib/plugins/tools/dev-tools-ignore-plugin.js +57 -0
  118. package/dist/lib/plugins/tools/render-worker.d.ts +31 -0
  119. package/dist/lib/plugins/tools/render-worker.d.ts.map +1 -0
  120. package/dist/lib/plugins/tools/render-worker.js +105 -0
  121. package/dist/lib/plugins/tools/routes-extractor-worker.d.ts +21 -0
  122. package/dist/lib/plugins/tools/routes-extractor-worker.d.ts.map +1 -0
  123. package/dist/lib/plugins/tools/routes-extractor-worker.js +48 -0
  124. package/dist/lib/plugins/tools/worker-pool.d.ts +13 -0
  125. package/dist/lib/plugins/tools/worker-pool.d.ts.map +1 -0
  126. package/dist/lib/plugins/tools/worker-pool.js +23 -0
  127. package/dist/lib/plugins/transfer-size-plugin.d.ts +12 -0
  128. package/dist/lib/plugins/transfer-size-plugin.d.ts.map +1 -0
  129. package/dist/lib/plugins/transfer-size-plugin.js +49 -0
  130. package/dist/lib/plugins/watch-file-logs-plugin.d.ts +12 -0
  131. package/dist/lib/plugins/watch-file-logs-plugin.d.ts.map +1 -0
  132. package/dist/lib/plugins/watch-file-logs-plugin.js +27 -0
  133. package/dist/lib/utils/async-chunks.d.ts +17 -0
  134. package/dist/lib/utils/async-chunks.d.ts.map +1 -0
  135. package/dist/lib/utils/async-chunks.js +44 -0
  136. package/dist/lib/utils/color.d.ts +11 -0
  137. package/dist/lib/utils/color.d.ts.map +1 -0
  138. package/dist/lib/utils/color.js +41 -0
  139. package/dist/lib/utils/find-project-for-path.d.ts +16 -0
  140. package/dist/lib/utils/find-project-for-path.d.ts.map +1 -0
  141. package/dist/lib/utils/find-project-for-path.js +42 -0
  142. package/dist/lib/utils/get-locale-base-href.d.ts +3 -0
  143. package/dist/lib/utils/get-locale-base-href.d.ts.map +1 -0
  144. package/dist/lib/utils/get-locale-base-href.js +17 -0
  145. package/dist/lib/utils/graph.d.ts +3 -0
  146. package/dist/lib/utils/graph.d.ts.map +1 -0
  147. package/dist/lib/utils/graph.js +25 -0
  148. package/dist/lib/utils/i18n.d.ts +4 -0
  149. package/dist/lib/utils/i18n.d.ts.map +1 -0
  150. package/dist/lib/utils/i18n.js +25 -0
  151. package/dist/lib/utils/index-file/add-body-script.d.ts +2 -0
  152. package/dist/lib/utils/index-file/add-body-script.d.ts.map +1 -0
  153. package/dist/lib/utils/index-file/add-body-script.js +15 -0
  154. package/dist/lib/utils/index-file/add-event-dispatch-contract.d.ts +9 -0
  155. package/dist/lib/utils/index-file/add-event-dispatch-contract.d.ts.map +1 -0
  156. package/dist/lib/utils/index-file/add-event-dispatch-contract.js +27 -0
  157. package/dist/lib/utils/index-file/get-index-input-file.d.ts +3 -0
  158. package/dist/lib/utils/index-file/get-index-input-file.d.ts.map +1 -0
  159. package/dist/lib/utils/index-file/get-index-input-file.js +9 -0
  160. package/dist/lib/utils/index-file/get-index-output-file.d.ts +3 -0
  161. package/dist/lib/utils/index-file/get-index-output-file.d.ts.map +1 -0
  162. package/dist/lib/utils/index-file/get-index-output-file.js +10 -0
  163. package/dist/lib/utils/index-file/html-rewriting-stream.d.ts +16 -0
  164. package/dist/lib/utils/index-file/html-rewriting-stream.d.ts.map +1 -0
  165. package/dist/lib/utils/index-file/html-rewriting-stream.js +27 -0
  166. package/dist/lib/utils/max-workers.d.ts +2 -0
  167. package/dist/lib/utils/max-workers.d.ts.map +1 -0
  168. package/dist/lib/utils/max-workers.js +21 -0
  169. package/dist/lib/utils/misc-helpers.d.ts +7 -0
  170. package/dist/lib/utils/misc-helpers.d.ts.map +1 -0
  171. package/dist/lib/utils/misc-helpers.js +34 -0
  172. package/dist/lib/utils/postcss-cli-resources.d.ts +22 -0
  173. package/dist/lib/utils/postcss-cli-resources.d.ts.map +1 -0
  174. package/dist/lib/utils/postcss-cli-resources.js +159 -0
  175. package/dist/lib/utils/postcss-configuration.d.ts +18 -0
  176. package/dist/lib/utils/postcss-configuration.d.ts.map +1 -0
  177. package/dist/lib/utils/postcss-configuration.js +92 -0
  178. package/dist/lib/utils/rspack-diagnostics.d.ts +4 -0
  179. package/dist/lib/utils/rspack-diagnostics.d.ts.map +1 -0
  180. package/dist/lib/utils/rspack-diagnostics.js +22 -0
  181. package/dist/lib/utils/spinner.d.ts +21 -0
  182. package/dist/lib/utils/spinner.d.ts.map +1 -0
  183. package/dist/lib/utils/spinner.js +54 -0
  184. package/dist/lib/utils/stats.d.ts +35 -0
  185. package/dist/lib/utils/stats.d.ts.map +1 -0
  186. package/dist/lib/utils/stats.js +313 -0
  187. package/dist/lib/utils/tty.d.ts +9 -0
  188. package/dist/lib/utils/tty.d.ts.map +1 -0
  189. package/dist/lib/utils/tty.js +22 -0
  190. package/dist/lib/utils/url-join.d.ts +9 -0
  191. package/dist/lib/utils/url-join.d.ts.map +1 -0
  192. package/dist/lib/utils/url-join.js +17 -0
  193. package/package.json +150 -0
@@ -0,0 +1,8 @@
1
+ import { Compiler, RspackPluginInstance } from '@rspack/core';
2
+ import { NormalizedAngularRspackPluginOptions } from '../models';
3
+ export declare class AngularSsrDevServer implements RspackPluginInstance {
4
+ #private;
5
+ constructor(options: NormalizedAngularRspackPluginOptions);
6
+ apply(compiler: Compiler): void;
7
+ }
8
+ //# sourceMappingURL=angular-ssr-dev-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"angular-ssr-dev-server.d.ts","sourceRoot":"","sources":["../../../src/lib/plugins/angular-ssr-dev-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EACR,oBAAoB,EAErB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,oCAAoC,EAAE,MAAM,WAAW,CAAC;AAQjE,qBAAa,mBAAoB,YAAW,oBAAoB;;gBAKlD,OAAO,EAAE,oCAAoC;IAKzD,KAAK,CAAC,QAAQ,EAAE,QAAQ;CA6DzB"}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var _AngularSsrDevServer_instances, _AngularSsrDevServer_devServerProcess, _AngularSsrDevServer_wsServer, _AngularSsrDevServer_options, _AngularSsrDevServer_attachSSRReloadClient;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.AngularSsrDevServer = void 0;
5
+ const tslib_1 = require("tslib");
6
+ const core_1 = require("@rspack/core");
7
+ const child_process_1 = require("child_process");
8
+ const ssr_reload_server_1 = require("./server/ssr-reload-server");
9
+ const node_path_1 = require("node:path");
10
+ const node_fs_1 = require("node:fs");
11
+ const get_index_output_file_1 = require("../utils/index-file/get-index-output-file");
12
+ const add_body_script_1 = require("../utils/index-file/add-body-script");
13
+ const PLUGIN_NAME = 'AngularSsrDevServer';
14
+ class AngularSsrDevServer {
15
+ constructor(options) {
16
+ _AngularSsrDevServer_instances.add(this);
17
+ _AngularSsrDevServer_devServerProcess.set(this, void 0);
18
+ _AngularSsrDevServer_wsServer.set(this, void 0);
19
+ _AngularSsrDevServer_options.set(this, void 0);
20
+ tslib_1.__classPrivateFieldSet(this, _AngularSsrDevServer_wsServer, new ssr_reload_server_1.SsrReloadServer(), "f");
21
+ tslib_1.__classPrivateFieldSet(this, _AngularSsrDevServer_options, options, "f");
22
+ }
23
+ apply(compiler) {
24
+ compiler.hooks.entryOption.tap(PLUGIN_NAME, (context, entry) => {
25
+ const keys = Object.keys(entry);
26
+ for (const key of keys) {
27
+ const entryValue = entry[key];
28
+ entryValue.import = [...entryValue.import];
29
+ }
30
+ });
31
+ compiler.hooks.watchRun.tapAsync(PLUGIN_NAME, async (compiler, callback) => {
32
+ compiler.hooks.afterEmit.tapAsync(PLUGIN_NAME, async (compilation, callback) => {
33
+ await tslib_1.__classPrivateFieldGet(this, _AngularSsrDevServer_instances, "m", _AngularSsrDevServer_attachSSRReloadClient).call(this, compilation);
34
+ const serverPath = (0, node_path_1.join)(tslib_1.__classPrivateFieldGet(this, _AngularSsrDevServer_options, "f").outputPath.server, 'server.js');
35
+ if (tslib_1.__classPrivateFieldGet(this, _AngularSsrDevServer_devServerProcess, "f")) {
36
+ tslib_1.__classPrivateFieldGet(this, _AngularSsrDevServer_devServerProcess, "f").kill();
37
+ tslib_1.__classPrivateFieldSet(this, _AngularSsrDevServer_devServerProcess, undefined, "f");
38
+ await new Promise((res) => setTimeout(res, 50));
39
+ }
40
+ if (!(0, node_fs_1.existsSync)(serverPath)) {
41
+ await new Promise((res) => setTimeout(res, 50));
42
+ }
43
+ tslib_1.__classPrivateFieldSet(this, _AngularSsrDevServer_devServerProcess, (0, child_process_1.fork)(serverPath), "f");
44
+ tslib_1.__classPrivateFieldGet(this, _AngularSsrDevServer_devServerProcess, "f").on('spawn', () => {
45
+ tslib_1.__classPrivateFieldGet(this, _AngularSsrDevServer_wsServer, "f").sendReload();
46
+ });
47
+ callback();
48
+ });
49
+ callback();
50
+ });
51
+ }
52
+ }
53
+ exports.AngularSsrDevServer = AngularSsrDevServer;
54
+ _AngularSsrDevServer_devServerProcess = new WeakMap(), _AngularSsrDevServer_wsServer = new WeakMap(), _AngularSsrDevServer_options = new WeakMap(), _AngularSsrDevServer_instances = new WeakSet(), _AngularSsrDevServer_attachSSRReloadClient = async function _AngularSsrDevServer_attachSSRReloadClient(compilation) {
55
+ const clientPath = require.resolve(`${__dirname}/client/ssr-reload-client.js`);
56
+ const pathToIndex = (0, node_path_1.join)(tslib_1.__classPrivateFieldGet(this, _AngularSsrDevServer_options, "f").outputPath.browser, (0, get_index_output_file_1.getIndexOutputFile)(tslib_1.__classPrivateFieldGet(this, _AngularSsrDevServer_options, "f").index));
57
+ const html = (0, node_fs_1.readFileSync)(pathToIndex, 'utf-8');
58
+ const updatedHtml = await (0, add_body_script_1.addBodyScript)(html, (0, node_fs_1.readFileSync)(clientPath, 'utf-8'));
59
+ const source = new core_1.sources.RawSource(updatedHtml);
60
+ const relativePathToIndex = pathToIndex.replace(tslib_1.__classPrivateFieldGet(this, _AngularSsrDevServer_options, "f").outputPath.browser, '');
61
+ compilation.emitAsset(relativePathToIndex, source);
62
+ };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.dev/license
7
+ */
8
+ import { BudgetEntry } from '@angular/build/private';
9
+ import { type Compiler, RspackPluginInstance } from '@rspack/core';
10
+ /**
11
+ * Check budget sizes for component styles by emitting a warning or error if a
12
+ * budget is exceeded by a particular component's styles.
13
+ */
14
+ export declare class AnyComponentStyleBudgetChecker implements RspackPluginInstance {
15
+ private readonly budgets;
16
+ constructor(budgets: BudgetEntry[]);
17
+ apply(compiler: Compiler): void;
18
+ }
19
+ //# sourceMappingURL=any-component-style-budget-checker-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"any-component-style-budget-checker-plugin.d.ts","sourceRoot":"","sources":["../../../src/lib/plugins/any-component-style-budget-checker-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAEL,WAAW,EAIZ,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAe,KAAK,QAAQ,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAMhF;;;GAGG;AACH,qBAAa,8BAA+B,YAAW,oBAAoB;IACzE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;gBAE5B,OAAO,EAAE,WAAW,EAAE;IAMlC,KAAK,CAAC,QAAQ,EAAE,QAAQ;CAgDzB"}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ * Copyright Google LLC All Rights Reserved.
5
+ *
6
+ * Use of this source code is governed by an MIT-style license that can be
7
+ * found in the LICENSE file at https://angular.dev/license
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.AnyComponentStyleBudgetChecker = void 0;
11
+ const tslib_1 = require("tslib");
12
+ const private_1 = require("@angular/build/private");
13
+ const path = tslib_1.__importStar(require("node:path"));
14
+ const core_1 = require("@rspack/core");
15
+ const rspack_diagnostics_1 = require("../utils/rspack-diagnostics");
16
+ const misc_helpers_1 = require("../utils/misc-helpers");
17
+ const PLUGIN_NAME = 'AnyComponentStyleBudgetChecker';
18
+ /**
19
+ * Check budget sizes for component styles by emitting a warning or error if a
20
+ * budget is exceeded by a particular component's styles.
21
+ */
22
+ class AnyComponentStyleBudgetChecker {
23
+ constructor(budgets) {
24
+ this.budgets = budgets.filter((budget) => budget.type === private_1.BudgetType.AnyComponentStyle);
25
+ }
26
+ apply(compiler) {
27
+ compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
28
+ compilation.hooks.processAssets.tap({
29
+ name: PLUGIN_NAME,
30
+ stage: core_1.Compilation.PROCESS_ASSETS_STAGE_ANALYSE,
31
+ }, () => {
32
+ // No budgets.
33
+ if (this.budgets.length === 0) {
34
+ return;
35
+ }
36
+ // In AOT compilations component styles get processed in child compilations.
37
+ if (!compilation.compiler.parentCompilation) {
38
+ return;
39
+ }
40
+ const cssExtensions = ['.css', '.scss', '.less', '.sass'];
41
+ const componentStyles = Object.keys(compilation.assets)
42
+ .filter((name) => cssExtensions.includes(path.extname(name)))
43
+ .map((name) => ({
44
+ name,
45
+ size: compilation.assets[name].size(),
46
+ componentStyle: true,
47
+ }));
48
+ for (const { severity, message } of (0, private_1.checkBudgets)(this.budgets, { chunks: [], assets: componentStyles }, true)) {
49
+ switch (severity) {
50
+ case private_1.ThresholdSeverity.Warning:
51
+ (0, rspack_diagnostics_1.addWarning)(compilation, message);
52
+ break;
53
+ case private_1.ThresholdSeverity.Error:
54
+ (0, rspack_diagnostics_1.addError)(compilation, message);
55
+ break;
56
+ default:
57
+ (0, misc_helpers_1.assertNever)(severity);
58
+ }
59
+ }
60
+ });
61
+ });
62
+ }
63
+ }
64
+ exports.AnyComponentStyleBudgetChecker = AnyComponentStyleBudgetChecker;
@@ -0,0 +1,2 @@
1
+ declare const socket: any;
2
+ //# sourceMappingURL=ssr-reload-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ssr-reload-client.d.ts","sourceRoot":"","sources":["../../../../src/lib/plugins/client/ssr-reload-client.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,MAAM,KAAwC,CAAC"}
@@ -0,0 +1,15 @@
1
+ // @ts-expect-error: This is a client-side file
2
+ const socket = new WebSocket(`ws://localhost:60000`);
3
+ socket.addEventListener('message', (event) => {
4
+ if (event.data === 'ssr-reload') {
5
+ console.log('[AngularSSRDevServer] Reloading the page...');
6
+ // @ts-expect-error: This is a client-side file
7
+ window.location.reload();
8
+ }
9
+ });
10
+ socket.addEventListener('open', () => {
11
+ console.log('[AngularSSRDevServer] WebSocket connection established.');
12
+ });
13
+ socket.addEventListener('close', () => {
14
+ console.warn('[AngularSSRDevServer] WebSocket connection closed.');
15
+ });
@@ -0,0 +1,8 @@
1
+ import { type Compiler, type RspackPluginInstance } from '@rspack/core';
2
+ import type { 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":"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;CA4OzB"}
@@ -0,0 +1,201 @@
1
+ "use strict";
2
+ var _I18nInlinePlugin_instances, _I18nInlinePlugin_pluginOptions, _I18nInlinePlugin_i18n, _I18nInlinePlugin_localizeToolsModule, _I18nInlinePlugin_outputPaths, _I18nInlinePlugin_checkAssetHasBeenProcessed, _I18nInlinePlugin_loadLocalizeTools, _I18nInlinePlugin_createI18nPlugins, _I18nInlinePlugin_assertIsError, _I18nInlinePlugin_transformWithBabel;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.I18nInlinePlugin = void 0;
5
+ const tslib_1 = require("tslib");
6
+ const remapping_1 = tslib_1.__importDefault(require("@ampproject/remapping"));
7
+ const core_1 = require("@babel/core");
8
+ const core_2 = require("@rspack/core");
9
+ const node_assert_1 = tslib_1.__importDefault(require("node:assert"));
10
+ const i18n_1 = require("../utils/i18n");
11
+ const misc_helpers_1 = require("../utils/misc-helpers");
12
+ const PLUGIN_NAME = 'I18nInlinePlugin';
13
+ class I18nInlinePlugin {
14
+ constructor(pluginOptions, i18nOptions) {
15
+ _I18nInlinePlugin_instances.add(this);
16
+ _I18nInlinePlugin_pluginOptions.set(this, void 0);
17
+ _I18nInlinePlugin_i18n.set(this, void 0);
18
+ /**
19
+ * Cached instance of the `@angular/localize/tools` module.
20
+ * This is used to remove the need to repeatedly import the module per file translation.
21
+ */
22
+ _I18nInlinePlugin_localizeToolsModule.set(this, void 0);
23
+ _I18nInlinePlugin_outputPaths.set(this, void 0);
24
+ tslib_1.__classPrivateFieldSet(this, _I18nInlinePlugin_pluginOptions, pluginOptions, "f");
25
+ tslib_1.__classPrivateFieldSet(this, _I18nInlinePlugin_i18n, i18nOptions, "f");
26
+ tslib_1.__classPrivateFieldSet(this, _I18nInlinePlugin_outputPaths, new Set((0, i18n_1.getLocaleOutputPaths)(i18nOptions).values()), "f");
27
+ }
28
+ apply(compiler) {
29
+ compiler.hooks.emit.tapAsync(PLUGIN_NAME, async (compilation, callback) => {
30
+ const filesToInline = new Map();
31
+ const additionalFiles = new Map();
32
+ for (const [filename, source] of Object.entries(compilation.assets)) {
33
+ let contents = source.source();
34
+ if (typeof contents !== 'string') {
35
+ contents = contents.toString();
36
+ }
37
+ if (!filename.endsWith('.map') && contents.includes('$localize')) {
38
+ filesToInline.set(filename, { text: contents, map: source.map() });
39
+ }
40
+ else {
41
+ additionalFiles.set(filename, source);
42
+ }
43
+ }
44
+ // Map of locales to Map of files to output
45
+ const filesToOutput = new Map();
46
+ for (const localeKey of tslib_1.__classPrivateFieldGet(this, _I18nInlinePlugin_i18n, "f").inlineLocales) {
47
+ const locale = tslib_1.__classPrivateFieldGet(this, _I18nInlinePlugin_i18n, "f").locales[localeKey];
48
+ const localeFiles = new Map();
49
+ for (const [filename, { text, map }] of filesToInline.entries()) {
50
+ if (tslib_1.__classPrivateFieldGet(this, _I18nInlinePlugin_instances, "m", _I18nInlinePlugin_checkAssetHasBeenProcessed).call(this, filename)) {
51
+ continue;
52
+ }
53
+ const result = await tslib_1.__classPrivateFieldGet(this, _I18nInlinePlugin_instances, "m", _I18nInlinePlugin_transformWithBabel).call(this, text, map, filename, localeKey, locale.translation, tslib_1.__classPrivateFieldGet(this, _I18nInlinePlugin_pluginOptions, "f").advancedOptimizations);
54
+ const sourceMap = result.map
55
+ ? new core_2.sources.SourceMapSource(result.code, filename, result.map)
56
+ : undefined;
57
+ localeFiles.set(filename, {
58
+ text: result.code,
59
+ map: sourceMap ? sourceMap.map() : undefined,
60
+ });
61
+ // TODO: Add support for diagnostics
62
+ }
63
+ for (const [filename, source] of additionalFiles.entries()) {
64
+ if (tslib_1.__classPrivateFieldGet(this, _I18nInlinePlugin_instances, "m", _I18nInlinePlugin_checkAssetHasBeenProcessed).call(this, filename)) {
65
+ continue;
66
+ }
67
+ localeFiles.set(filename, {
68
+ text: source.source(),
69
+ map: source.map(),
70
+ });
71
+ }
72
+ filesToOutput.set(locale.subPath, localeFiles);
73
+ }
74
+ for (const [localeSubPath, files] of filesToOutput.entries()) {
75
+ for (const [filename, { text, map }] of files.entries()) {
76
+ const localeFileName = `${localeSubPath}/${filename}`;
77
+ const asset = compilation.getAsset(filename);
78
+ const assetInfo = asset ? asset.info : undefined;
79
+ if (map) {
80
+ compilation.emitAsset(localeFileName, new core_2.sources.SourceMapSource(text, localeFileName, map), (newAssetInfo) => ({ ...assetInfo, ...newAssetInfo }));
81
+ }
82
+ compilation.emitAsset(localeFileName, new core_2.sources.RawSource(text), (newAssetInfo) => ({ ...assetInfo, ...newAssetInfo }));
83
+ if (asset) {
84
+ compilation.deleteAsset(filename);
85
+ }
86
+ }
87
+ }
88
+ callback();
89
+ });
90
+ }
91
+ }
92
+ exports.I18nInlinePlugin = I18nInlinePlugin;
93
+ _I18nInlinePlugin_pluginOptions = new WeakMap(), _I18nInlinePlugin_i18n = new WeakMap(), _I18nInlinePlugin_localizeToolsModule = new WeakMap(), _I18nInlinePlugin_outputPaths = new WeakMap(), _I18nInlinePlugin_instances = new WeakSet(), _I18nInlinePlugin_checkAssetHasBeenProcessed = function _I18nInlinePlugin_checkAssetHasBeenProcessed(filename) {
94
+ return tslib_1.__classPrivateFieldGet(this, _I18nInlinePlugin_outputPaths, "f").has(filename.split('/')[0]);
95
+ }, _I18nInlinePlugin_loadLocalizeTools =
96
+ /**
97
+ * Attempts to load the `@angular/localize/tools` module containing the functionality to
98
+ * perform the file translations.
99
+ * This module must be dynamically loaded as it is an ESM module and this file is CommonJS.
100
+ */
101
+ async function _I18nInlinePlugin_loadLocalizeTools() {
102
+ // Load ESM `@angular/localize/tools` using the TypeScript dynamic import workaround.
103
+ // Once TypeScript provides support for keeping the dynamic import this workaround can be
104
+ // changed to a direct dynamic import.
105
+ tslib_1.__classPrivateFieldSet(this, _I18nInlinePlugin_localizeToolsModule, tslib_1.__classPrivateFieldGet(this, _I18nInlinePlugin_localizeToolsModule, "f") ?? await (0, misc_helpers_1.loadEsmModule)('@angular/localize/tools'), "f");
106
+ }, _I18nInlinePlugin_createI18nPlugins =
107
+ /**
108
+ * Creates the needed Babel plugins to inline a given locale and translation for a JavaScript file.
109
+ * @param locale A string containing the locale specifier to use.
110
+ * @param translation A object record containing locale specific messages to use.
111
+ * @returns An array of Babel plugins.
112
+ */
113
+ async function _I18nInlinePlugin_createI18nPlugins(locale, translation) {
114
+ await tslib_1.__classPrivateFieldGet(this, _I18nInlinePlugin_instances, "m", _I18nInlinePlugin_loadLocalizeTools).call(this);
115
+ const { Diagnostics, makeEs2015TranslatePlugin } =
116
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
117
+ tslib_1.__classPrivateFieldGet(this, _I18nInlinePlugin_localizeToolsModule, "f");
118
+ const plugins = [];
119
+ const diagnostics = new Diagnostics();
120
+ plugins.push(makeEs2015TranslatePlugin(diagnostics, (translation || {}), {
121
+ missingTranslation: translation === undefined
122
+ ? 'ignore'
123
+ : tslib_1.__classPrivateFieldGet(this, _I18nInlinePlugin_pluginOptions, "f").i18nMissingTranslation,
124
+ }));
125
+ // Create a plugin to replace the locale specifier constant inject by the build system with the actual specifier
126
+ plugins.push({
127
+ visitor: {
128
+ StringLiteral(path) {
129
+ if (path.node.value === '___NG_LOCALE_INSERT___') {
130
+ path.replaceWith(core_1.types.stringLiteral(locale));
131
+ }
132
+ },
133
+ },
134
+ });
135
+ return { diagnostics, plugins };
136
+ }, _I18nInlinePlugin_assertIsError = function _I18nInlinePlugin_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
+ }, _I18nInlinePlugin_transformWithBabel =
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 filename The filename of the JavaScript file to transform.
150
+ * @param locale The locale to inline.
151
+ * @param translation The translation to inline.
152
+ * @param shouldOptimize Whether to optimize the transformed code.
153
+ * @returns An object containing the code, map, and diagnostics from the transformation.
154
+ */
155
+ async function _I18nInlinePlugin_transformWithBabel(code, map, filename, locale, translation, shouldOptimize) {
156
+ let ast;
157
+ try {
158
+ ast = (0, core_1.parseSync)(code, {
159
+ babelrc: false,
160
+ configFile: false,
161
+ sourceType: 'unambiguous',
162
+ filename,
163
+ });
164
+ }
165
+ catch (error) {
166
+ tslib_1.__classPrivateFieldGet(this, _I18nInlinePlugin_instances, "m", _I18nInlinePlugin_assertIsError).call(this, error);
167
+ // Make the error more readable.
168
+ // Same errors will contain the full content of the file as the error message
169
+ // Which makes it hard to find the actual error message.
170
+ const index = error.message.indexOf(')\n');
171
+ const msg = index !== -1 ? error.message.slice(0, index + 1) : error.message;
172
+ throw new Error(`${msg}\nAn error occurred inlining file "${filename}"`);
173
+ }
174
+ if (!ast) {
175
+ throw new Error(`Unknown error occurred inlining file "${filename}"`);
176
+ }
177
+ const { diagnostics, plugins } = await tslib_1.__classPrivateFieldGet(this, _I18nInlinePlugin_instances, "m", _I18nInlinePlugin_createI18nPlugins).call(this, locale, translation);
178
+ const transformResult = await (0, core_1.transformFromAstAsync)(ast, code, {
179
+ filename,
180
+ // false is a valid value but not included in the type definition
181
+ inputSourceMap: false,
182
+ sourceMaps: !!map,
183
+ compact: shouldOptimize,
184
+ configFile: false,
185
+ babelrc: false,
186
+ browserslistConfigFile: false,
187
+ plugins,
188
+ });
189
+ if (!transformResult || !transformResult.code) {
190
+ throw new Error(`Unknown error occurred processing bundle for "${filename}".`);
191
+ }
192
+ let outputMap;
193
+ if (map && transformResult.map) {
194
+ outputMap = (0, remapping_1.default)([transformResult.map, map], () => null);
195
+ }
196
+ return {
197
+ code: transformResult.code,
198
+ map: outputMap && JSON.stringify(outputMap),
199
+ diagnostics,
200
+ };
201
+ };
@@ -0,0 +1,21 @@
1
+ import { IndexHtmlGenerator, type IndexHtmlGeneratorOptions } from '@angular/build/private';
2
+ import { Compilation, RspackPluginInstance, type Compiler } from '@rspack/core';
3
+ import type { I18nOptions, IndexExpandedDefinition } from '../models';
4
+ export interface IndexHtmlPluginOptions extends IndexHtmlGeneratorOptions {
5
+ baseHref: string | undefined;
6
+ i18n: I18nOptions;
7
+ index: IndexExpandedDefinition;
8
+ isSsr: boolean;
9
+ outputPath: string;
10
+ }
11
+ export declare class IndexHtmlPlugin extends IndexHtmlGenerator implements RspackPluginInstance {
12
+ readonly options: IndexHtmlPluginOptions;
13
+ private _compilation;
14
+ get compilation(): Compilation;
15
+ constructor(options: IndexHtmlPluginOptions);
16
+ apply(compiler: Compiler): void;
17
+ readAsset(path: string): Promise<string>;
18
+ protected readIndex(path: string): Promise<string>;
19
+ getLocaleBaseHref(locale: string): string | undefined;
20
+ }
21
+ //# sourceMappingURL=index-html-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-html-plugin.d.ts","sourceRoot":"","sources":["../../../src/lib/plugins/index-html-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAElB,KAAK,yBAAyB,EAC/B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEhF,OAAO,KAAK,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAQtE,MAAM,WAAW,sBAAuB,SAAQ,yBAAyB;IACvE,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,uBAAuB,CAAC;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB;AAID,qBAAa,eACX,SAAQ,kBACR,YAAW,oBAAoB;aAWD,OAAO,EAAE,sBAAsB;IAT7D,OAAO,CAAC,YAAY,CAA0B;IAC9C,IAAI,WAAW,IAAI,WAAW,CAM7B;gBAE6B,OAAO,EAAE,sBAAsB;IAI7D,KAAK,CAAC,QAAQ,EAAE,QAAQ;IAoET,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;cAM9B,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAsBjE,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAgBtD"}
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IndexHtmlPlugin = void 0;
4
+ const private_1 = require("@angular/build/private");
5
+ const core_1 = require("@rspack/core");
6
+ const node_path_1 = require("node:path");
7
+ const add_event_dispatch_contract_1 = require("../utils/index-file/add-event-dispatch-contract");
8
+ const misc_helpers_1 = require("../utils/misc-helpers");
9
+ const i18n_1 = require("../utils/i18n");
10
+ const rspack_diagnostics_1 = require("../utils/rspack-diagnostics");
11
+ const url_join_1 = require("../utils/url-join");
12
+ const get_index_output_file_1 = require("../utils/index-file/get-index-output-file");
13
+ const PLUGIN_NAME = 'IndexHtmlPlugin';
14
+ class IndexHtmlPlugin extends private_1.IndexHtmlGenerator {
15
+ get compilation() {
16
+ if (this._compilation) {
17
+ return this._compilation;
18
+ }
19
+ throw new Error('compilation is undefined.');
20
+ }
21
+ constructor(options) {
22
+ super(options);
23
+ this.options = options;
24
+ }
25
+ apply(compiler) {
26
+ compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
27
+ this._compilation = compilation;
28
+ compilation.hooks.processAssets.tapPromise({
29
+ name: PLUGIN_NAME,
30
+ stage: core_1.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE,
31
+ }, async () => {
32
+ const files = [];
33
+ try {
34
+ for (const chunk of compilation.chunks) {
35
+ for (const file of chunk.files) {
36
+ // https://github.com/web-infra-dev/rspack/blob/a2e1e21c7e1ed0f34e476ec270e3c5460c4a1a36/packages/rspack/src/config/defaults.ts#L606
37
+ if (file.endsWith('.hot-update.js') ||
38
+ file.endsWith('.hot-update.mjs')) {
39
+ continue;
40
+ }
41
+ files.push({
42
+ name: chunk.name,
43
+ file,
44
+ extension: (0, node_path_1.extname)(file),
45
+ });
46
+ }
47
+ }
48
+ const outputPaths = (0, i18n_1.ensureOutputPaths)(this.options.outputPath, this.options.i18n);
49
+ for (const [locale, outputPath] of outputPaths.entries()) {
50
+ const { csrContent, warnings, errors } = await this.process({
51
+ files,
52
+ outputPath,
53
+ baseHref: this.getLocaleBaseHref(locale) ?? this.options.baseHref,
54
+ lang: locale || undefined,
55
+ });
56
+ let html = csrContent;
57
+ if (this.options.isSsr) {
58
+ html = await (0, add_event_dispatch_contract_1.addEventDispatchContract)(csrContent);
59
+ }
60
+ const { RawSource } = compiler.rspack.sources;
61
+ compilation.emitAsset((0, node_path_1.join)(outputPath, (0, get_index_output_file_1.getIndexOutputFile)(this.options.index)), new RawSource(html));
62
+ warnings.forEach((msg) => (0, rspack_diagnostics_1.addWarning)(compilation, msg));
63
+ errors.forEach((msg) => (0, rspack_diagnostics_1.addError)(compilation, msg));
64
+ }
65
+ }
66
+ catch (error) {
67
+ (0, misc_helpers_1.assertIsError)(error);
68
+ (0, rspack_diagnostics_1.addError)(compilation, error.message);
69
+ }
70
+ });
71
+ });
72
+ }
73
+ async readAsset(path) {
74
+ const data = this.compilation.assets[(0, node_path_1.basename)(path)].source();
75
+ return typeof data === 'string' ? data : data.toString();
76
+ }
77
+ async readIndex(path) {
78
+ return new Promise((resolve, reject) => {
79
+ if (!this.compilation.inputFileSystem) {
80
+ super.readIndex(path).then(resolve).catch(reject);
81
+ return;
82
+ }
83
+ this.compilation.inputFileSystem.readFile(path, (err, data) => {
84
+ if (err) {
85
+ reject(err);
86
+ return;
87
+ }
88
+ this.compilation.fileDependencies.add(path);
89
+ resolve(data?.toString() ?? '');
90
+ });
91
+ });
92
+ }
93
+ getLocaleBaseHref(locale) {
94
+ if (this.options.i18n.flatOutput) {
95
+ return undefined;
96
+ }
97
+ const localeData = this.options.i18n.locales[locale];
98
+ if (!localeData) {
99
+ return undefined;
100
+ }
101
+ const baseHrefSuffix = localeData.baseHref ?? localeData.subPath + '/';
102
+ return baseHrefSuffix !== ''
103
+ ? (0, url_join_1.urlJoin)(this.options.baseHref || '', baseHrefSuffix)
104
+ : undefined;
105
+ }
106
+ }
107
+ exports.IndexHtmlPlugin = IndexHtmlPlugin;
@@ -0,0 +1,3 @@
1
+ import { LoaderContext } from '@rspack/core';
2
+ export default function loader(this: LoaderContext<unknown>, content: string): void;
3
+ //# sourceMappingURL=angular-partial-transform.loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"angular-partial-transform.loader.d.ts","sourceRoot":"","sources":["../../../../src/lib/plugins/loaders/angular-partial-transform.loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,MAAM,QA2C3E"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = loader;
4
+ const models_1 = require("../../models");
5
+ function loader(content) {
6
+ const callback = this.async();
7
+ if (this._compilation[models_1.NG_RSPACK_SYMBOL_NAME] ===
8
+ undefined) {
9
+ callback(null, content);
10
+ }
11
+ else {
12
+ const { javascriptTransformer, typescriptFileCache } = this._compilation[models_1.NG_RSPACK_SYMBOL_NAME]();
13
+ const request = this.resourcePath;
14
+ if (request.startsWith('data:text/javascript') &&
15
+ request.includes('__module_federation_bundler_runtime__')) {
16
+ callback(null, content);
17
+ return;
18
+ }
19
+ if (!content.includes('@angular')) {
20
+ callback(null, content);
21
+ return;
22
+ }
23
+ const existingTransform = typescriptFileCache.get(request);
24
+ if (existingTransform) {
25
+ const existingContents = typeof existingTransform === 'string'
26
+ ? existingTransform
27
+ : Buffer.from(existingTransform).toString('utf8');
28
+ callback(null, existingContents);
29
+ return;
30
+ }
31
+ javascriptTransformer
32
+ .transformFile(request, false, false)
33
+ .then((contents) => {
34
+ const transformedCode = Buffer.from(contents).toString('utf8');
35
+ typescriptFileCache.set(request, transformedCode);
36
+ callback(null, transformedCode);
37
+ });
38
+ }
39
+ }
@@ -0,0 +1,7 @@
1
+ import type { LoaderContext } from '@rspack/core';
2
+ import { StyleUrlsResolver, TemplateUrlsResolver } from '@nx/angular-rspack-compiler';
3
+ export default function loader(this: LoaderContext<unknown>, content: string, opt?: {
4
+ styleUrlsResolver: StyleUrlsResolver;
5
+ templateUrlsResolver: TemplateUrlsResolver;
6
+ }): void;
7
+ //# sourceMappingURL=angular-transform.loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"angular-transform.loader.d.ts","sourceRoot":"","sources":["../../../../src/lib/plugins/loaders/angular-transform.loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGlD,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,6BAA6B,CAAC;AAKrC,MAAM,CAAC,OAAO,UAAU,MAAM,CAC5B,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,EAC5B,OAAO,EAAE,MAAM,EACf,GAAG,CAAC,EAAE;IACJ,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,oBAAoB,EAAE,oBAAoB,CAAC;CAC5C,QA0CF"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = loader;
4
+ const path_1 = require("path");
5
+ const models_1 = require("../../models");
6
+ const angular_rspack_compiler_1 = require("@nx/angular-rspack-compiler");
7
+ const _styleUrlsResolver = new angular_rspack_compiler_1.StyleUrlsResolver();
8
+ const _templateUrlsResolver = new angular_rspack_compiler_1.TemplateUrlsResolver();
9
+ function loader(content, opt) {
10
+ const { styleUrlsResolver = _styleUrlsResolver, templateUrlsResolver = _templateUrlsResolver, } = opt ?? {};
11
+ const callback = this.async();
12
+ if (this._compilation[models_1.NG_RSPACK_SYMBOL_NAME] ===
13
+ undefined) {
14
+ callback(null, content);
15
+ }
16
+ else {
17
+ const { typescriptFileCache } = this._compilation[models_1.NG_RSPACK_SYMBOL_NAME]();
18
+ const request = this.resourcePath.replace(/^[A-Z]:/, '');
19
+ const normalizedRequest = (0, path_1.normalize)(request);
20
+ const templateUrls = templateUrlsResolver.resolve(content, normalizedRequest);
21
+ const styleUrls = styleUrlsResolver.resolve(content, normalizedRequest);
22
+ for (const urlSet of [...templateUrls, ...styleUrls]) {
23
+ // `urlSet` is a string where a relative path is joined with an
24
+ // absolute path using the `|` symbol.
25
+ // For example: `./app.component.html|/home/projects/analog/src/app/app.component.html`.
26
+ const [, absoluteFileUrl] = urlSet.split('|');
27
+ this.addDependency(absoluteFileUrl);
28
+ }
29
+ const contents = typescriptFileCache.get(normalizedRequest);
30
+ if (contents === undefined) {
31
+ callback(null, content);
32
+ }
33
+ else if (typeof contents === 'string') {
34
+ callback(null, contents);
35
+ }
36
+ else {
37
+ callback(null, Buffer.from(contents));
38
+ }
39
+ }
40
+ }