Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 2 additions & 23 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions rspack/react-compiler-babel-ts/babel.config.js

This file was deleted.

66 changes: 0 additions & 66 deletions rspack/react-compiler-babel-ts/rspack.config.js

This file was deleted.

9 changes: 0 additions & 9 deletions rspack/react-compiler-babel/babel.config.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@rspack-example/react-compiler-babel-ts",
"name": "@rspack-example/react-compiler-ts",
"version": "1.0.0",
"private": true,
"license": "MIT",
Expand All @@ -15,16 +15,12 @@
"react-refresh": "0.19.0"
},
"devDependencies": {
"@babel/plugin-syntax-jsx": "^7.29.7",
"@babel/plugin-syntax-typescript": "^7.29.7",
"@rspack/cli": "2.2.8",
"@rspack/core": "2.2.8",
"@rspack/dev-server": "2.2.1",
"@types/node": "^24.19.2",
"@types/react": "^19.3.0",
"@types/react-dom": "^19.3.0",
"babel-loader": "^10.1.1",
"babel-plugin-react-compiler": "^1.0.0",
"typescript": "^5.9.3"
}
}
48 changes: 48 additions & 0 deletions rspack/react-compiler-ts/rspack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// @ts-check
import { defineConfig } from '@rspack/cli';
import { rspack } from '@rspack/core';

export default defineConfig({
entry: {
main: './src/index.tsx',
},
resolve: {
extensions: ['...', '.jsx', '.tsx', '.ts'],
},
module: {
rules: [
{
test: /\.css$/,
type: 'css',
},
{
test: /\.(?:js|mjs|jsx|ts|tsx)$/,
exclude: [/[\\/]node_modules[\\/]/],
use: {
loader: 'builtin:swc-loader',
options: {
detectSyntax: 'auto',
jsc: {
externalHelpers: true,
transform: {
react: {
runtime: 'automatic',
},
reactCompiler: true,
},
},
},
},
},
{
test: /\.(png|svg|jpg)$/,
type: 'asset/resource',
},
],
},
plugins: [
new rspack.HtmlRspackPlugin({
template: './index.html',
}),
],
});
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@
color: #61dafb;
}

.App-header button {
margin: 1rem 0;
padding: 0.5rem 1rem;
font-size: 1rem;
cursor: pointer;
}

@keyframes App-logo-spin {
from {
transform: rotate(0deg);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import React from 'react';
import logo from './logo.svg';
import './App.css';
import { useCounter } from './useCounter';

function App() {
const { count, increment } = useCounter();

return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
Edit <code>src/App.tsx</code> and save to reload.
</p>
<button type="button" onClick={increment}>
Count: {count}
</button>
<a
className="App-link"
href="https://reactjs.org"
Expand Down
7 changes: 7 additions & 0 deletions rspack/react-compiler-ts/src/useCounter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { useState } from 'react';

export function useCounter(initial = 0) {
const [count, setCount] = useState(initial);
const increment = () => setCount((c) => c + 1);
return { count, increment };
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@rspack-example/react-compiler-babel",
"name": "@rspack-example/react-compiler",
"version": "1.0.0",
"private": true,
"license": "MIT",
Expand All @@ -15,11 +15,8 @@
"react-refresh": "0.19.0"
},
"devDependencies": {
"@babel/plugin-syntax-jsx": "^7.29.7",
"@rspack/cli": "2.2.8",
"@rspack/core": "2.2.8",
"@rspack/dev-server": "2.2.1",
"babel-loader": "^10.1.1",
"babel-plugin-react-compiler": "^1.0.0"
"@rspack/dev-server": "2.2.1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,41 +22,23 @@ export default defineConfig({
type: 'css',
},
{
test: /\.(?:js|mjs|cjs)$/,
test: /\.(?:js|mjs|jsx)$/,
exclude: [/[\\/]node_modules[\\/]/],
use: [
{
loader: 'builtin:swc-loader',
options: {
detectSyntax: 'auto',
jsc: {
externalHelpers: true,
},
},
},
],
},
{
test: /\.jsx$/,
use: [
{
loader: 'builtin:swc-loader',
options: {
detectSyntax: 'auto',
jsc: {
externalHelpers: true,
transform: {
react: {
runtime: 'automatic',
},
use: {
loader: 'builtin:swc-loader',
options: {
detectSyntax: 'auto',
jsc: {
externalHelpers: true,
transform: {
react: {
runtime: 'automatic',
},
reactCompiler: true,
},
},
},
{
loader: 'babel-loader',
},
],
},
},
{
test: /\.(png|svg|jpg)$/,
Expand Down
Loading