Skip to content

Commit

Permalink
fix(rspack): add useTsconfigPaths to NxAppRspackPluginOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
ndcunningham committed Dec 10, 2024
1 parent b859795 commit fc3a733
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/rspack/src/plugins/utils/apply-base-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,9 @@ function applyNxDependentConfig(
root: options.root,
};

plugins.push(new NxTsconfigPathsRspackPlugin({ ...options, tsConfig }));
if (options.useTsconfigPaths) {
plugins.push(new NxTsconfigPathsRspackPlugin({ ...options, tsConfig }));
}

// New TS Solution already has a typecheck target
if (!options?.skipTypeChecking && !isUsingTsSolutionSetup()) {
Expand Down
4 changes: 4 additions & 0 deletions packages/rspack/src/plugins/utils/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ export interface NxAppRspackPluginOptions {
* List of TypeScript Compiler Transformers Plugins.
*/
transformers?: TransformerEntry[];
/**
* Use tsconfig-paths-webpack-plugin to resolve modules using paths in the tsconfig file.
*/
useTsconfigPaths?: boolean;
/**
* Generate a separate vendor chunk for 3rd party packages.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
NxAppRspackPluginOptions,
NormalizedNxAppRspackPluginOptions,
} from '../models';
import { isUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';

export function normalizeOptions(
options: NxAppRspackPluginOptions
Expand All @@ -38,6 +39,10 @@ export function normalizeOptions(
const projectNode = projectGraph.nodes[projectName];
const targetConfig = projectNode.data.targets[targetName];

// If the project is using ts solutions setup, the paths are not in tsconfig and we should not use the plugin's paths.
options.useTsconfigPaths =
options.useTsconfigPaths ?? !isUsingTsSolutionSetup();

normalizeRelativePaths(projectNode.data.root, options);

// Merge options from `@nx/rspack:rspack` into plugin options.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export function normalizeOptions(

const projectNode = projectGraph.nodes[projectName];
const targetConfig = projectNode.data.targets[targetName];

// If the project is using ts solutions setup, the paths are not in tsconfig and we should not use the plugin's paths.
options.useTsconfigPaths =
options.useTsconfigPaths ?? !isUsingTsSolutionSetup();

Expand Down

0 comments on commit fc3a733

Please sign in to comment.