Skip to content

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

Open
@Timeless0911

Description

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?

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions