web-infra-dev / rslib

The Rsbuild powered package build tool.
https://lib.rsbuild.dev/
MIT License
367 stars 17 forks source link

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

Open fi3ework opened 5 days ago

fi3ework commented 5 days ago

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.
Timeless0911 commented 5 days ago

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

fi3ework commented 5 days ago

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.

Timeless0911 commented 1 day ago

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