Repository navigation
fix(rspack): apply React Compiler to .ts files in babel-ts example (#1) - #517
Conversation
* fix(rspack): apply React Compiler to .ts files in babel-ts example Hooks are commonly defined in .ts files, so babel-loader with babel-plugin-react-compiler should process those as well as .tsx. Adds a small useCounter.ts hook to demonstrate the pattern. Fixes rstackjs#331 Co-authored-by: Ari <mail@heyq02.cn> * style(rspack): make counter button readable in react-compiler-babel-ts Co-authored-by: Ari <mail@heyq02.cn> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>
|
Thanks for fixing this! Could we switch this example to Rspack's Rust React Compiler instead? Running Babel on every With |
|
Once this is updated, could you also open a PR in the Rspack repository to update the links in the React Compiler examples section to match the new directory names? For example, |
well |
#2) * refactor(rspack): switch React Compiler examples to builtin:swc-loader Use Rspack's Rust React Compiler via jsc.transform.reactCompiler instead of babel-loader. Consolidate JS/TS/JSX/TSX into a single rule with detectSyntax: 'auto', remove Babel config/deps, and rename examples to react-compiler and react-compiler-ts. Addresses review feedback on rstackjs#517. Co-authored-by: Ari <mail@heyq02.cn> * chore(rspack): fix package.json conflict and update lockfile Resolve leftover rebase conflict markers in react-compiler-ts and refresh pnpm-lock.yaml after renaming the React Compiler examples. Co-authored-by: Ari <mail@heyq02.cn> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>
My pleasure. |
Summary
babel-loader/babel-plugin-react-compileron.tsfiles inrspack/react-compiler-babel-ts, not only.tsx(hooks are commonly defined in.ts)useCounter.tshook used byApp.tsxso the example demonstrates the patternFixes #331
Test plan
pnpm --filter "@rspack-example/react-compiler-babel-ts" buildsucceedsuseCounter.tsrewritten withreact/compiler-runtimememo cachepnpm --filter "@rspack-example/react-compiler-babel-ts" dev— counter button increments