rspack icon indicating copy to clipboard operation
rspack copied to clipboard

[Feature Request]: Write rspack config in typescript

Open marco2216 opened this issue 1 year ago • 1 comments

What problem does this feature solve?

Webpack config can be written in a ts file (webpack.config.ts). It would be very helpful to be able to do this for rspack as well, since we get type and ESM syntax support, and it makes it much easier to migrate existing configs to rspack. (existing webpack config may also have dependencies on other TS files, so it's not good to have to convert those to JS as well.)

What does the proposed API of configuration look like?

rspack.config.ts - follow webpack.

marco2216 avatar Mar 12 '23 12:03 marco2216

you can use ts-node/register to handle ts config support right now, we will support ts config out of box in the future

  • rspack.config.js
require('ts-node/register');
your config here

hardfist avatar Mar 12 '23 12:03 hardfist

Hi @hardfist , can I take this issue?

HerringtonDarkholme avatar Mar 13 '23 09:03 HerringtonDarkholme

Hi rspack team, I found webpack uses rechoir and interpret to load JS variants. Is it the desirable way to do it? Or do you prefer using minimal dependencies?

https://github.com/webpack/webpack-cli/blob/master/packages/webpack-cli/src/webpack-cli.ts#L1723

HerringtonDarkholme avatar Mar 13 '23 10:03 HerringtonDarkholme

we prefer minimal

hardfist avatar Mar 13 '23 11:03 hardfist

@hardfist What is the performance of using .js vs .ts rspack configuration files?

leimonio avatar Aug 01 '24 15:08 leimonio

Also might be bit early, but any idea how the NodeJS experimental Typescript Support will change the current approach?

leimonio avatar Aug 01 '24 15:08 leimonio