Skip to content

Commit

Permalink
Merge pull request #2812 from sibelius/feat/rspack
Browse files Browse the repository at this point in the history
feat(rspack): rspack
  • Loading branch information
sibelius authored Nov 15, 2023
2 parents d6c05a4 + 046169f commit 35a995e
Show file tree
Hide file tree
Showing 4 changed files with 838 additions and 48 deletions.
9 changes: 7 additions & 2 deletions apps/web-react-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@
"relay-runtime": "15.0.0",
"styled-components": "5.3.11",
"styled-system": "5.1.5",
"yup": "^1.0.2"
"yup": "^1.0.2",
"@rspack/cli": "latest",
"@rspack/core": "latest",
"@rspack/plugin-node-polyfill": "latest"
},
"devDependencies": {
"@pmmmwh/react-refresh-webpack-plugin": "0.5.11",
Expand Down Expand Up @@ -68,6 +71,8 @@
"razzle:start": "node_modules/.bin/razzle start",
"relay": "node_modules/.bin/relay-compiler",
"start": "webpack serve --hot --config webpack.dev.config.js",
"build": "webpack --config webpack.prod.config.js"
"build": "webpack --config webpack.prod.config.js",
"rspack:dev": "rspack serve",
"rspack:build": "rspack build"
}
}
73 changes: 73 additions & 0 deletions apps/web-react-router/rspack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
const rspack = require('@rspack/core');
const NodePolyfill = require('@rspack/plugin-node-polyfill');

const cwd = process.cwd();

/**
* @type {import('@rspack/cli').Configuration}
*/
module.exports = {
context: cwd,
entry: {
main: './src/index.tsx',
},
module: {
rules: [
{
test: /\.(js|jsx|ts|tsx)?$/,
exclude: [/node_modules/],
loader: 'builtin:swc-loader',
options: {
rspackExperiments: {
relay: true,
},
jsc: {
experimental: {
plugins: [
[
'@swc/plugin-relay',
{
rootDir: cwd,
language: 'typescript',
},
],
],
},
parser: {
syntax: 'typescript',
tsx: true,
},
transform: {
react: {
runtime: 'automatic',
},
},
},
},
type: 'javascript/auto',
},
{
test: /\.(jpe?g|png|gif|svg|mp3|pdf|csv|xlsx|ttf|woff(2)?)$/i,
type: 'asset',
},
],
},
plugins: [
new NodePolyfill(),
new rspack.HtmlRspackPlugin({
template: './src/index.html',
}),
],
devServer: {
historyApiFallback: true,
open: true,
},
builtins: {
relay: true,
},
resolve: {
fallback: {
fs: false,
},
},
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
"w": "yarn b webpackx.ts",
"web": "yarn workspace @workshop/web start",
"web-react-router": "yarn workspace @workshop/web-react-router start",
"web:rspack": "yarn workspace @workshop/web-react-router rspack:dev",
"next:dev": "yarn workspace @workshop/next dev",
"next:build": "yarn workspace @workshop/next build",
"nextapp:dev": "yarn workspace @workshop/nextapp dev",
Expand Down
Loading

0 comments on commit 35a995e

Please sign in to comment.