web-infra-dev / rslib

Create JavaScript libraries in a simple and intuitive way.
https://lib.rsbuild.dev/
MIT License
479 stars 26 forks source link

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

Open fi3ework opened 1 month ago

fi3ework commented 1 month 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 1 month ago

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

fi3ework commented 1 month 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 month ago

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