@nx/angular-rspack 23.1.0 → 23.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/lib/config/config-utils/browser-config.d.ts +4 -1
  2. package/dist/lib/config/config-utils/browser-config.d.ts.map +1 -1
  3. package/dist/lib/config/config-utils/browser-config.js +5 -18
  4. package/dist/lib/config/config-utils/server-config.d.ts +4 -1
  5. package/dist/lib/config/config-utils/server-config.d.ts.map +1 -1
  6. package/dist/lib/config/config-utils/server-config.js +10 -18
  7. package/dist/lib/config/config-utils/swc-transpilation.d.ts +16 -0
  8. package/dist/lib/config/config-utils/swc-transpilation.d.ts.map +1 -0
  9. package/dist/lib/config/config-utils/swc-transpilation.js +50 -0
  10. package/dist/lib/config/create-config.d.ts.map +1 -1
  11. package/dist/lib/config/create-config.js +20 -2
  12. package/dist/lib/models/augmented-compilation.d.ts +6 -0
  13. package/dist/lib/models/augmented-compilation.d.ts.map +1 -1
  14. package/dist/lib/plugins/angular-rspack-plugin.d.ts +9 -0
  15. package/dist/lib/plugins/angular-rspack-plugin.d.ts.map +1 -1
  16. package/dist/lib/plugins/angular-rspack-plugin.js +245 -83
  17. package/dist/lib/plugins/extract-licenses-plugin.d.ts +78 -0
  18. package/dist/lib/plugins/extract-licenses-plugin.d.ts.map +1 -0
  19. package/dist/lib/plugins/extract-licenses-plugin.js +217 -0
  20. package/dist/lib/plugins/loaders/angular-partial-transform.loader.d.ts +2 -2
  21. package/dist/lib/plugins/loaders/angular-partial-transform.loader.d.ts.map +1 -1
  22. package/dist/lib/plugins/loaders/angular-partial-transform.loader.js +78 -16
  23. package/dist/lib/plugins/loaders/angular-transform.loader.d.ts.map +1 -1
  24. package/dist/lib/plugins/loaders/angular-transform.loader.js +49 -20
  25. package/dist/lib/plugins/loaders/inline-source-map.d.ts +34 -0
  26. package/dist/lib/plugins/loaders/inline-source-map.d.ts.map +1 -0
  27. package/dist/lib/plugins/loaders/inline-source-map.js +76 -0
  28. package/dist/lib/plugins/ng-rspack.d.ts +18 -0
  29. package/dist/lib/plugins/ng-rspack.d.ts.map +1 -1
  30. package/dist/lib/plugins/ng-rspack.js +43 -9
  31. package/dist/lib/plugins/prerender-plugin.d.ts.map +1 -1
  32. package/dist/lib/plugins/prerender-plugin.js +26 -3
  33. package/dist/lib/utils/postcss-cli-resources.d.ts.map +1 -1
  34. package/dist/lib/utils/postcss-cli-resources.js +8 -4
  35. package/package.json +5 -11
  36. package/LICENSE +0 -22
@@ -9,6 +9,7 @@ const misc_helpers_1 = require("../utils/misc-helpers");
9
9
  const rspack_serve_env_1 = require("../utils/rspack-serve-env");
10
10
  const angular_rspack_plugin_1 = require("./angular-rspack-plugin");
11
11
  const angular_ssr_dev_server_1 = require("./angular-ssr-dev-server");
12
+ const extract_licenses_plugin_1 = require("./extract-licenses-plugin");
12
13
  const i18n_inline_plugin_1 = require("./i18n-inline-plugin");
13
14
  const index_html_plugin_1 = require("./index-html-plugin");
14
15
  const progress_plugin_1 = require("./progress-plugin");
@@ -18,6 +19,8 @@ class NgRspackPlugin {
18
19
  this.pluginOptions = pluginOptions;
19
20
  this.i18n = extraOptions.i18nOptions;
20
21
  this.isPlatformServer = extraOptions.platform === 'server';
22
+ this.sharedLicenseInputs = extraOptions.sharedLicenseInputs;
23
+ this.sharedAngularPlugin = extraOptions.sharedAngularPlugin;
21
24
  }
22
25
  apply(compiler) {
23
26
  const root = this.pluginOptions.root;
@@ -29,6 +32,32 @@ class NgRspackPlugin {
29
32
  new angular_ssr_dev_server_1.AngularSsrDevServer(this.pluginOptions).apply(compiler);
30
33
  }
31
34
  }
35
+ if (this.isPlatformServer) {
36
+ // The server bundle is CommonJS; the marker keeps Node loading it as
37
+ // such under a `"type": "module"` workspace package.json.
38
+ compiler.hooks.thisCompilation.tap('NgRspackPlugin', (compilation) => {
39
+ compilation.hooks.processAssets.tap({
40
+ name: 'NgRspackPlugin',
41
+ stage: compiler.rspack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
42
+ }, () => {
43
+ if (!compilation.getAsset('package.json')) {
44
+ compilation.emitAsset('package.json', new compiler.rspack.sources.RawSource('{"type": "commonjs"}\n'));
45
+ }
46
+ });
47
+ });
48
+ }
49
+ else {
50
+ // Deployment tooling reads this at the output root of every build; the
51
+ // PrerenderPlugin overwrites it with the rendered routes after emit.
52
+ compiler.hooks.thisCompilation.tap('NgRspackPlugin', (compilation) => {
53
+ compilation.hooks.processAssets.tap({
54
+ name: 'NgRspackPlugin',
55
+ stage: compiler.rspack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
56
+ }, () => {
57
+ compilation.emitAsset(node_path_1.posix.join(...(0, node_path_1.relative)(this.pluginOptions.outputPath.browser, this.pluginOptions.outputPath.base).split(node_path_1.sep), 'prerendered-routes.json'), new compiler.rspack.sources.RawSource(JSON.stringify({ routes: {} }, null, 2)));
58
+ });
59
+ });
60
+ }
32
61
  if (!isDevServer && this.pluginOptions.progress) {
33
62
  new progress_plugin_1.ProgressPlugin(this.isPlatformServer ? 'server' : 'browser').apply(compiler);
34
63
  }
@@ -75,22 +104,27 @@ class NgRspackPlugin {
75
104
  }).apply(compiler);
76
105
  }
77
106
  if (this.pluginOptions.extractLicenses) {
78
- const { LicenseWebpackPlugin } = require('license-webpack-plugin');
79
- new LicenseWebpackPlugin({
80
- stats: {
81
- warnings: false,
82
- errors: false,
83
- },
84
- perChunkOutput: false,
107
+ new extract_licenses_plugin_1.ExtractLicensesPlugin({
85
108
  outputFilename: node_path_1.posix.join((0, node_path_1.relative)(this.pluginOptions.outputPath.browser, this.pluginOptions.outputPath.base), '3rdpartylicenses.txt'),
86
- skipChildCompilers: true,
109
+ rootDirectory: root,
110
+ sharedInputs: this.sharedLicenseInputs,
87
111
  }).apply(compiler);
88
112
  }
89
113
  if (this.i18n.shouldInline) {
90
114
  new i18n_inline_plugin_1.I18nInlinePlugin(this.pluginOptions, this.i18n).apply(compiler);
91
115
  }
92
116
  new rxjs_esm_resolution_1.RxjsEsmResolutionPlugin().apply(compiler);
93
- new angular_rspack_plugin_1.AngularRspackPlugin(this.pluginOptions, this.i18n).apply(compiler);
117
+ if (this.sharedAngularPlugin) {
118
+ if (this.isPlatformServer) {
119
+ this.sharedAngularPlugin.applyToDependentCompiler(compiler);
120
+ }
121
+ else {
122
+ this.sharedAngularPlugin.apply(compiler);
123
+ }
124
+ }
125
+ else {
126
+ new angular_rspack_plugin_1.AngularRspackPlugin(this.pluginOptions, this.i18n).apply(compiler);
127
+ }
94
128
  if (!this.isPlatformServer && this.pluginOptions.index) {
95
129
  new index_html_plugin_1.IndexHtmlPlugin({
96
130
  indexPath: this.pluginOptions.index.input,
@@ -1 +1 @@
1
- {"version":3,"file":"prerender-plugin.d.ts","sourceRoot":"","sources":["../../../src/lib/plugins/prerender-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,QAAQ,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAOhF,OAAO,EACL,KAAK,WAAW,EAEhB,oCAAoC,EACrC,MAAM,WAAW,CAAC;AAenB,qBAAa,eAAgB,YAAW,oBAAoB;;IAI1D,YACE,OAAO,EAAE,oCAAoC,EAC7C,WAAW,CAAC,EAAE,WAAW,EAI1B;IAED,KAAK,CAAC,QAAQ,EAAE,QAAQ,QAavB;CA2PF"}
1
+ {"version":3,"file":"prerender-plugin.d.ts","sourceRoot":"","sources":["../../../src/lib/plugins/prerender-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,QAAQ,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAOhF,OAAO,EACL,KAAK,WAAW,EAEhB,oCAAoC,EACrC,MAAM,WAAW,CAAC;AAenB,qBAAa,eAAgB,YAAW,oBAAoB;;IAI1D,YACE,OAAO,EAAE,oCAAoC,EAC7C,WAAW,CAAC,EAAE,WAAW,EAI1B;IAED,KAAK,CAAC,QAAQ,EAAE,QAAQ,QAuBvB;CAqRF"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- var _PrerenderPlugin_instances, _PrerenderPlugin__options, _PrerenderPlugin_i18n, _PrerenderPlugin_prerenderAppShell, _PrerenderPlugin_prerenderSSGUniversal, _PrerenderPlugin_getRoutes, _PrerenderPlugin_normalizePrerenderOptions, _PrerenderPlugin_resolveZonePackage;
2
+ var _PrerenderPlugin_instances, _PrerenderPlugin__options, _PrerenderPlugin_i18n, _PrerenderPlugin_writePrerenderedRoutesManifest, _PrerenderPlugin_prerenderAppShell, _PrerenderPlugin_prerenderSSGUniversal, _PrerenderPlugin_getRoutes, _PrerenderPlugin_normalizePrerenderOptions, _PrerenderPlugin_resolveZonePackage;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.PrerenderPlugin = void 0;
5
5
  const tslib_1 = require("tslib");
@@ -30,18 +30,40 @@ class PrerenderPlugin {
30
30
  }
31
31
  apply(compiler) {
32
32
  compiler.hooks.afterEmit.tapAsync('Angular Rspack', async (compilation, callback) => {
33
+ const prerenderedRoutes = new Set();
33
34
  if (tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").appShell) {
34
35
  await tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin_instances, "m", _PrerenderPlugin_prerenderAppShell).call(this, compilation);
36
+ prerenderedRoutes.add('/');
35
37
  }
36
38
  if (tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").prerender) {
37
- await tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin_instances, "m", _PrerenderPlugin_prerenderSSGUniversal).call(this, compilation);
39
+ for (const route of await tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin_instances, "m", _PrerenderPlugin_prerenderSSGUniversal).call(this, compilation)) {
40
+ // RoutesSet stores routes without the leading slash; the manifest
41
+ // keys carry it, matching the esbuild application builder.
42
+ prerenderedRoutes.add(`/${route}`);
43
+ }
38
44
  }
45
+ await tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin_instances, "m", _PrerenderPlugin_writePrerenderedRoutesManifest).call(this, compilation, prerenderedRoutes);
39
46
  callback();
40
47
  });
41
48
  }
42
49
  }
43
50
  exports.PrerenderPlugin = PrerenderPlugin;
44
- _PrerenderPlugin__options = new WeakMap(), _PrerenderPlugin_i18n = new WeakMap(), _PrerenderPlugin_instances = new WeakSet(), _PrerenderPlugin_prerenderAppShell = async function _PrerenderPlugin_prerenderAppShell(compilation) {
51
+ _PrerenderPlugin__options = new WeakMap(), _PrerenderPlugin_i18n = new WeakMap(), _PrerenderPlugin_instances = new WeakSet(), _PrerenderPlugin_writePrerenderedRoutesManifest =
52
+ /**
53
+ * Overwrites the empty `prerendered-routes.json` emitted at the output root
54
+ * by the browser compiler with the routes that were prerendered.
55
+ */
56
+ async function _PrerenderPlugin_writePrerenderedRoutesManifest(compilation, prerenderedRoutes) {
57
+ // fromEntries keeps a route literally named "__proto__" an own key.
58
+ const routes = Object.fromEntries([...prerenderedRoutes].sort().map((route) => [route, {}]));
59
+ try {
60
+ await (0, promises_1.writeFile)((0, path_1.join)(tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").outputPath.base, 'prerendered-routes.json'), JSON.stringify({ routes }, null, 2));
61
+ }
62
+ catch (error) {
63
+ (0, misc_helpers_1.assertIsError)(error);
64
+ (0, rspack_diagnostics_1.addError)(compilation, error.message);
65
+ }
66
+ }, _PrerenderPlugin_prerenderAppShell = async function _PrerenderPlugin_prerenderAppShell(compilation) {
45
67
  // Users can specify a different base html file e.g. "src/home.html"
46
68
  const indexFile = (0, get_index_output_file_1.getIndexOutputFile)(tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").index);
47
69
  const worker = new worker_pool_1.WorkerPool({
@@ -167,6 +189,7 @@ _PrerenderPlugin__options = new WeakMap(), _PrerenderPlugin_i18n = new WeakMap()
167
189
  finally {
168
190
  void worker.destroy();
169
191
  }
192
+ return routes ?? [];
170
193
  }, _PrerenderPlugin_getRoutes = async function _PrerenderPlugin_getRoutes(indexFile, outputPath, serverBundlePath, workspaceRoot) {
171
194
  const { routes: extraRoutes = [], routesFile, discoverRoutes, } = tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin_instances, "m", _PrerenderPlugin_normalizePrerenderOptions).call(this);
172
195
  const routes = new RoutesSet(extraRoutes);
@@ -1 +1 @@
1
- {"version":3,"file":"postcss-cli-resources.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/postcss-cli-resources.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAe,MAAM,EAAE,MAAM,SAAS,CAAC;AA0BnD,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B,mEAAmE;IACnE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,MAAM,CAAC;IAC3C,MAAM,EAAE,OAAO,cAAc,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IACtD,QAAQ,EAAE,OAAO,CAAC;CACnB;AAcD,eAAO,MAAM,OAAO,OAAO,CAAC;AAE5B,MAAM,CAAC,OAAO,WAAW,OAAO,CAAC,EAAE,0BAA0B,GAAG,MAAM,CA8KrE"}
1
+ {"version":3,"file":"postcss-cli-resources.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/postcss-cli-resources.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAe,MAAM,EAAE,MAAM,SAAS,CAAC;AA0BnD,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B,mEAAmE;IACnE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,MAAM,CAAC;IAC3C,MAAM,EAAE,OAAO,cAAc,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IACtD,QAAQ,EAAE,OAAO,CAAC;CACnB;AAcD,eAAO,MAAM,OAAO,OAAO,CAAC;AAE5B,MAAM,CAAC,OAAO,WAAW,OAAO,CAAC,EAAE,0BAA0B,GAAG,MAAM,CAmLrE"}
@@ -12,7 +12,6 @@ exports.default = default_1;
12
12
  const tslib_1 = require("tslib");
13
13
  const loader_utils_1 = require("loader-utils");
14
14
  const path = tslib_1.__importStar(require("node:path"));
15
- const node_url_1 = require("node:url");
16
15
  const misc_helpers_1 = require("./misc-helpers");
17
16
  function wrapUrl(url) {
18
17
  let wrappedUrl;
@@ -72,14 +71,19 @@ function default_1(options) {
72
71
  // Separate URL query/hash from the file path before resolving
73
72
  const [, filePath, urlSuffix] = inputUrl.match(/^([^?#]*)(.*)$/);
74
73
  const resolvedPath = path.resolve(context, filePath.replace(/\\/g, '/'));
75
- const { pathname } = (0, node_url_1.pathToFileURL)(resolvedPath);
74
+ // Resolve a relative filesystem path, not a file:// URL pathname: on Windows the
75
+ // pathname is `/C:/...` (spaces as %20), which the resolver cannot find. Relative
76
+ // (not absolute) lets `resolve()`'s `./`-prefixed lookup succeed on the first try.
77
+ const resolveRequest = path
78
+ .relative(context, resolvedPath)
79
+ .replace(/\\/g, '/');
76
80
  let hash = '';
77
81
  let search = '';
78
82
  if (urlSuffix) {
79
83
  ({ hash, search } = new URL(`file:///dummy${urlSuffix}`));
80
84
  }
81
85
  const resolver = (file, base) => new Promise((resolve, reject) => {
82
- loader.resolve(base, decodeURI(file), (err, result) => {
86
+ loader.resolve(base, file, (err, result) => {
83
87
  if (err) {
84
88
  reject(err);
85
89
  return;
@@ -87,7 +91,7 @@ function default_1(options) {
87
91
  resolve(result);
88
92
  });
89
93
  });
90
- const result = await resolve(pathname, context, resolver);
94
+ const result = await resolve(resolveRequest, context, resolver);
91
95
  return new Promise((resolve, reject) => {
92
96
  loader.fs.readFile(result, (err, content) => {
93
97
  if (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/angular-rspack",
3
- "version": "23.1.0",
3
+ "version": "23.1.1",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -62,7 +62,6 @@
62
62
  "css-loader": "^7.1.2",
63
63
  "jsonc-parser": "^3.2.0",
64
64
  "less-loader": "^12.2.0",
65
- "license-webpack-plugin": "^4.0.2",
66
65
  "loader-utils": "3.3.1",
67
66
  "open": "10.1.0",
68
67
  "ora": "^5.3.0",
@@ -78,8 +77,8 @@
78
77
  "tslib": "^2.3.0",
79
78
  "webpack-merge": "^6.0.1",
80
79
  "ws": "^8.18.0",
81
- "@nx/angular-rspack-compiler": "23.1.0",
82
- "@nx/devkit": "23.1.0"
80
+ "@nx/angular-rspack-compiler": "23.1.1",
81
+ "@nx/devkit": "23.1.1"
83
82
  },
84
83
  "devDependencies": {
85
84
  "jsonc-eslint-parser": "^2.4.0"
@@ -123,15 +122,10 @@
123
122
  },
124
123
  "test": {
125
124
  "dependsOn": [
125
+ "...",
126
126
  "build",
127
- "^build-native",
128
127
  "angular-rspack-compiler:build"
129
- ],
130
- "options": {
131
- "args": [
132
- "--passWithNoTests"
133
- ]
134
- }
128
+ ]
135
129
  }
136
130
  }
137
131
  },
package/LICENSE DELETED
@@ -1,22 +0,0 @@
1
- (The MIT License)
2
-
3
- Copyright (c) 2017-2026 Narwhal Technologies Inc.
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- 'Software'), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.