rslib icon indicating copy to clipboard operation
rslib copied to clipboard

[Feature]: jsx runtime should be synced between tsconfig and swc

Open fi3ework opened this issue 1 year ago • 3 comments

What problem does this feature solve?

See https://github.com/web-infra-dev/rslib/blob/f9f1751a304051947ea27d47146d072b9c448da1/examples/react-component-bundle/rslib.config.ts#L39

When tsconfigjson.jsx is set to react. We need to set swc react runtime to classic explicitly. It's pretty error-prone and trivial.

What does the proposed API look like?

  1. Automatically read from tsconfig: @rsbuild/pluigin-react's config automatically follows tsconfig.
  2. Or, only check're the configuration are matched and emit a warning when conflict.

fi3ework avatar Oct 17 '24 08:10 fi3ework

Rsbuild does not want to be associated with the fields in tsconfig.json, we may do config check in Rslib.

Timeless0911 avatar Oct 17 '24 09:10 Timeless0911

I don't want to make Rslib detect and modify @rsbuild/plugin-react's existence, as React is not a built-in solution nor anything special in Rslib.

I prefer to check the consistency of tsconfigjson.jsx and jsc.transform.react.runtime and emit warning.

fi3ework avatar Oct 17 '24 09:10 fi3ework

jsx related tests in Modern.js Module: https://github.com/web-infra-dev/modern.js/blob/main/tests/integration/module/fixtures/build/jsx

Timeless0911 avatar Oct 22 '24 06:10 Timeless0911