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

[Refactor] Load Rslib config file / package.json / tsconfig.json with better javascript-api design #456

Open
Timeless0911 opened this issue Nov 20, 2024 · 0 comments

Comments

@Timeless0911
Copy link
Collaborator

What problem does this feature solve?

We should unify the logic of loading Rslib config file / package.json / tsconfig.json in javascript-api and CLI to avoid passing root param.

When we read tsconfig.json from config.source.tsconfigPath when we compose configs, it may be different from Rsbuild internal logic:

https://github.com/web-infra-dev/rsbuild/blob/660af78835597f486ea06b1c9baf87ad1bc795df/packages/core/src/createContext.ts#L189-L192

  • In DTS plugin ,we get tsconfig.json from config.source.tsconfigPath that be processed by Rsbuild which is an absolute path with join root config in Rsbuild config or process.cwd()

  • When we loading tsconfig.json in compose configs, we get raw value of config.source.tsconfigPath field which maybe a relative path without concating base dir. The root we now use is from root options in Rslib CLI or function params in build javascript api.

We can pass absolute tsconfigPath to Rsbuild with concat our root base to preventing users config root in Rsbuild config to influence the tsconfigPath value in DTS.

We should handle root well in these situations:

What does the proposed API look like?

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

1 participant