@nx/rspack 20.3.0-beta.0 → 20.3.0-beta.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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nx/rspack",
3
3
  "description": "The Nx Plugin for Rspack contains executors and generators that support building applications using Rspack.",
4
- "version": "20.3.0-beta.0",
4
+ "version": "20.3.0-beta.1",
5
5
  "type": "commonjs",
6
6
  "repository": {
7
7
  "type": "git",
@@ -24,10 +24,10 @@
24
24
  "generators": "./generators.json",
25
25
  "executors": "./executors.json",
26
26
  "dependencies": {
27
- "@nx/js": "20.3.0-beta.0",
28
- "@nx/devkit": "20.3.0-beta.0",
29
- "@nx/web": "20.3.0-beta.0",
30
- "@nx/module-federation": "20.3.0-beta.0",
27
+ "@nx/js": "20.3.0-beta.1",
28
+ "@nx/devkit": "20.3.0-beta.1",
29
+ "@nx/web": "20.3.0-beta.1",
30
+ "@nx/module-federation": "20.3.0-beta.1",
31
31
  "@phenomnomnominal/tsquery": "~5.0.1",
32
32
  "@rspack/core": "^1.1.5",
33
33
  "@rspack/dev-server": "^1.0.9",
@@ -4,9 +4,11 @@ exports.normalizeOptions = normalizeOptions;
4
4
  exports.normalizePluginPath = normalizePluginPath;
5
5
  const path_1 = require("path");
6
6
  const normalize_options_1 = require("../../../plugins/utils/plugins/normalize-options");
7
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
7
8
  function normalizeOptions(options, root, projectRoot, sourceRoot) {
8
9
  const normalizedOptions = {
9
10
  ...options,
11
+ useTsconfigPaths: !(0, ts_solution_setup_1.isUsingTsSolutionSetup)(),
10
12
  root,
11
13
  projectRoot,
12
14
  sourceRoot,
@@ -69,4 +69,5 @@ export interface NormalizedRspackExecutorSchema extends RspackExecutorSchema {
69
69
  root: string;
70
70
  projectRoot: string;
71
71
  sourceRoot: string;
72
+ useTsconfigPaths: boolean;
72
73
  }
@@ -164,6 +164,7 @@ function applyNxIndependentConfig(options, config) {
164
164
  function applyNxDependentConfig(options, config, { useNormalizedEntry } = {}) {
165
165
  const tsConfig = options.tsConfig ?? (0, js_1.getRootTsConfigPath)();
166
166
  const plugins = [];
167
+ const isUsingTsSolution = (0, ts_solution_setup_1.isUsingTsSolutionSetup)();
167
168
  const executorContext = {
168
169
  projectName: options.projectName,
169
170
  targetName: options.targetName,
@@ -171,9 +172,13 @@ function applyNxDependentConfig(options, config, { useNormalizedEntry } = {}) {
171
172
  configurationName: options.configurationName,
172
173
  root: options.root,
173
174
  };
174
- plugins.push(new nx_tsconfig_paths_rspack_plugin_1.NxTsconfigPathsRspackPlugin({ ...options, tsConfig }));
175
+ options.useTsconfigPaths ??= !isUsingTsSolution;
176
+ // If the project is using ts solutions setup, the paths are not in tsconfig and we should not use the plugin's paths.
177
+ if (options.useTsconfigPaths) {
178
+ plugins.push(new nx_tsconfig_paths_rspack_plugin_1.NxTsconfigPathsRspackPlugin({ ...options, tsConfig }));
179
+ }
175
180
  // New TS Solution already has a typecheck target
176
- if (!options?.skipTypeChecking && !(0, ts_solution_setup_1.isUsingTsSolutionSetup)()) {
181
+ if (!options?.skipTypeChecking && !isUsingTsSolution) {
177
182
  const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
178
183
  plugins.push(new ForkTsCheckerWebpackPlugin({
179
184
  typescript: {
@@ -16,11 +16,11 @@ function applyReactConfig(options, config = {}) {
16
16
  config.module.rules.push({
17
17
  test: /\.svg$/i,
18
18
  type: 'asset',
19
- resourceQuery: /react/, // *.svg?react
19
+ resourceQuery: /url/, // *.svg?url
20
20
  }, {
21
21
  test: /\.svg$/i,
22
22
  issuer: /\.[jt]sx?$/,
23
- resourceQuery: { not: [/react/] }, // exclude react component if *.svg?react
23
+ resourceQuery: { not: [/url/] }, // exclude react component if not *.svg?url
24
24
  use: [{ loader: '@svgr/webpack', options: svgrOptions }],
25
25
  });
26
26
  }
@@ -31,7 +31,7 @@ function applyReactConfig(options, config = {}) {
31
31
  };
32
32
  }
33
33
  function removeSvgLoaderIfPresent(config) {
34
- const svgLoaderIdx = config.module.rules.findIndex((rule) => typeof rule === 'object' && rule.test.toString().includes('svg'));
34
+ const svgLoaderIdx = config.module.rules.findIndex((rule) => typeof rule === 'object' && rule.test?.toString().includes('svg'));
35
35
  if (svgLoaderIdx === -1)
36
36
  return;
37
37
  config.module.rules.splice(svgLoaderIdx, 1);
@@ -196,6 +196,10 @@ export interface NxAppRspackPluginOptions {
196
196
  * List of TypeScript Compiler Transformers Plugins.
197
197
  */
198
198
  transformers?: TransformerEntry[];
199
+ /**
200
+ * Use tsconfig-paths-webpack-plugin to resolve modules using paths in the tsconfig file.
201
+ */
202
+ useTsconfigPaths?: boolean;
199
203
  /**
200
204
  * Generate a separate vendor chunk for 3rd party packages.
201
205
  */
@@ -55,6 +55,7 @@ function ensureNxRspackExecutionContext(ctx) {
55
55
  outputFileName: undefined,
56
56
  outputPath: undefined,
57
57
  rspackConfig: undefined,
58
+ useTsconfigPaths: undefined,
58
59
  };
59
60
  ctx.context ??= {
60
61
  projectName,
@@ -28,6 +28,7 @@ async function readRspackOptions(rspackConfig) {
28
28
  tsConfig: '',
29
29
  outputPath: '',
30
30
  rspackConfig: '',
31
+ useTsconfigPaths: undefined,
31
32
  },
32
33
  context: {
33
34
  root: devkit_1.workspaceRoot,