Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rspack does not properly resolve tsconfig paths. #398

Open
1 of 4 tasks
RoyalHunt opened this issue May 14, 2024 · 7 comments
Open
1 of 4 tasks

rspack does not properly resolve tsconfig paths. #398

RoyalHunt opened this issue May 14, 2024 · 7 comments

Comments

@RoyalHunt
Copy link

RoyalHunt commented May 14, 2024

Current Behavior

tsconfig.json file:

{ "compilerOptions": { "paths": { "@app/themes/*": ["libs/themes/src/muiThemes/*"] } }, }

it resolves in rspack config as:
resolve: { alias: { '@app/themes/*': 'C:\\Users\\admin\\webApps\\libs\\themes\\src\\muiThemes\\*', }, },

Expected Behavior

tsconfig.json file:
{ "compilerOptions": { "paths": { "@app/themes/*": ["libs/themes/src/muiThemes/*"] } }, }

it should resolve in rspack config as:
{ resolve: { alias: { '@app/themes': 'C:\\Users\\admin\\webApps\\libs\\themes\\src\\muiThemes', }, }, }

GitHub Repo

No response

Steps to Reproduce

  1. Generate app: npx nx generate @nx/rspack:application --name=app
  2. add path to the tsconfig with /*
  3. check rspack config

Nx Report

Node   : 20.12.2
OS     : win32-x64
npm    : 10.5.0

nx                 : 18.3.3
@nx/js             : 18.3.3
@nx/jest           : 18.3.3
@nx/linter         : 18.3.3
@nx/eslint         : 18.3.3
@nx/workspace      : 18.3.3
@nx/cypress        : 18.3.3
@nx/devkit         : 18.3.3
@nx/eslint-plugin  : 18.3.3
@nx/react          : 18.3.3
@nx/storybook      : 18.3.3
@nx/web            : 18.3.3
@nx/webpack        : 18.3.3
@nx/rspack         : 18.3.3
typescript         : 5.4.5

Failure Logs

No response

Package Manager Version

10.5.0

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@AgentEnder AgentEnder transferred this issue from nrwl/nx May 14, 2024
@spartan-luc-le
Copy link

I'm having the same issue as you.

@rafakwolf
Copy link

same

@tomdglenn91
Copy link

Also having this issue

@luisnquin
Copy link

I'm struggling with this....

@artgoce
Copy link

artgoce commented Sep 11, 2024

My "workaround" was to update rspack config to use this:

https://rspack.dev/config/resolve#resolvetsconfigconfigfile

So, you point to you app/lib tsconfig file.

@jesperume
Copy link

I solved it with this workaround in rspack.config.ts:


export default composePlugins(
  withNx(),
  withReact(),
  withModuleFederation(config, { dts: false }),
  (config: any) => {
 
    // Fix to set correct configuration for alias
    const newAlias: Record<string, string> = {};
    for (const key in config.resolve.alias) {
      const newKey = key.replace(/\/\*/g, "");
      const newValue = config.resolve.alias[key].replace(/\\\*/g, "");
      newAlias[newKey] = newValue;
    }
    config.resolve.alias = newAlias;

    return config;
  },
);

@KhBaterdene
Copy link

it works for me

"paths": {
      "@/*": ["apps/core/src/modules/*"], // for vscode
      "@": ["apps/core/src/modules"], // for rspack
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants