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

[Bug]: wrong tsconfig.json#paths output when bundle: false #407

Closed
carlosmfreitas2409 opened this issue Nov 11, 2024 · 8 comments · Fixed by #535
Closed

[Bug]: wrong tsconfig.json#paths output when bundle: false #407

carlosmfreitas2409 opened this issue Nov 11, 2024 · 8 comments · Fixed by #535

Comments

@carlosmfreitas2409
Copy link

carlosmfreitas2409 commented Nov 11, 2024

Version

Rslib 0.0.16

Details

When using bundle: false, the TS path aliases are not being correctly generated in the build.
When using bundle: true, it generates correctly, but it is not what I want.

  • tsconfig.json
{
  "extends": "@repo/tsconfig/react.json",
  "include": ["src", "stories"],
  "compilerOptions": {
    "paths": {
      "@/*": ["./src/*"]
    }
  }
}
  • rslib config
    Image

  • rslib output
    Image

  • build script
    rslib build

@fi3ework
Copy link
Member

Since the request is externalized, it won't follow Rsbuild's default alias behavior(https://rsbuild.dev/guide/advanced/alias). It's better to be aligned.

@carlosmfreitas2409
Copy link
Author

Hi @fi3ework.

Sorry, I didn't quite understand what you meant.
Are you saying to use source.alias and source.aliasStrategy in rslib config?
If so, I've tried using them too, but it didn't change anything.

@fi3ework
Copy link
Member

source.alias or source.aliasStraategy won't make it work. The alias to an source path (which means it's dynamic after resolved) need getResolve function #238 (comment).

@Timeless0911
Copy link
Collaborator

web-infra-dev/rspack#7348 external function getResolve will be supported after this pr merged.

@yf-yang
Copy link

yf-yang commented Nov 26, 2024

Sorry, I cannot keep up with your terminology. Does this mean that when using path aliases and building bundless DTS, the aliases would be replaced with the correct relative paths after web-infra-dev/rspack#7348 is done?

@Timeless0911
Copy link
Collaborator

Timeless0911 commented Nov 27, 2024

Does this mean that when using path aliases and building bundless DTS, the aliases would be replaced with the correct relative paths after web-infra-dev/rspack#7348 is done?

For bundleless DTS, the alias redirect should be another issue, tracking in #409. You can use tsc-alias currently.

@noshower
Copy link

noshower commented Dec 18, 2024

Since the request is externalized, it won't follow Rsbuild's default alias behavior(https://rsbuild.dev/guide/advanced/alias). It's better to be aligned.

you can use https://github.com/noshower/ts-paths-to-relative-path-rspack-plugin

this plugin can convert ts paths alias to relative paths

@Timeless0911
Copy link
Collaborator

this plugin can convert ts paths alias to relative paths

#535 will solve this issue in Rslib internally.

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

Successfully merging a pull request may close this issue.

5 participants