Skip to content

Commit

Permalink
replace webpack with rsbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
felixmosh committed Oct 10, 2024
1 parent 2fe92ef commit a6869f1
Show file tree
Hide file tree
Showing 7 changed files with 879 additions and 3,049 deletions.
6 changes: 3 additions & 3 deletions example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function setupBullProcessor(bullQueue: Bull.Queue) {
});
}

async function setupBullMQProcessor(queueName: string) {
function setupBullMQProcessor(queueName: string) {
new Worker(
queueName,
async (job) => {
Expand All @@ -56,8 +56,8 @@ const run = async () => {
const exampleBullMq = createQueueMQ('ExampleBullMQ');
const flow = new FlowProducer({ connection: redisOptions });

await setupBullProcessor(exampleBull); // needed only for example proposes
await setupBullMQProcessor(exampleBullMq.name); // needed only for example proposes
setupBullProcessor(exampleBull); // needed only for example proposes
setupBullMQProcessor(exampleBullMq.name); // needed only for example proposes

app.use('/add', (req, res) => {
const opts = req.query.opts || ({} as any);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"lint": "eslint \"./packages/**/*.ts*\"",
"build": "lerna run build",
"start:dev:docker": "docker-compose up -d",
"start:dev:ui": "lerna run --stream --scope @bull-board/ui start",
"start:dev:ui": "lerna run --stream --scope @bull-board/ui dev",
"start:dev:server": "ts-node-dev --rs example.ts",
"start:dev": "concurrently --names \"UI,API\" -c \"bgBlue.bold,bgMagenta.bold\" \"yarn start:dev:ui\" \"yarn start:dev:server\"",
"test": "lerna run test",
Expand Down
61 changes: 19 additions & 42 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
"typings"
],
"scripts": {
"start": "NODE_ENV=development webpack serve",
"build": "NODE_ENV=production webpack --mode=production",
"build:analyze": "NODE_ENV=production ANALYZE=true webpack --mode=production",
"dev": "rsbuild dev",
"build": "rsbuild build",
"build:analyze": "BUNDLE_ANALYZE=true rsbuild build",
"clean": "rm -rf dist",
"sync:locales": "npx i18next-locales-sync -c ./localesSync.config.js",
"gen:jsonSchema": "npm run gen:jsonSchema:bullmq && npm run gen:jsonSchema:bull",
Expand All @@ -35,66 +35,43 @@
"@bull-board/api": "6.0.1"
},
"devDependencies": {
"@babel/core": "^7.17.9",
"@babel/plugin-proposal-class-properties": "^7.13.0",
"@babel/plugin-proposal-object-rest-spread": "^7.17.3",
"@babel/plugin-transform-runtime": "^7.17.0",
"@babel/preset-env": "^7.16.11",
"@babel/preset-react": "^7.12.13",
"@babel/preset-typescript": "^7.13.0",
"@babel/runtime": "^7.17.9",
"@codemirror/commands": "^6.5.0",
"@codemirror/lang-json": "^6.0.1",
"@codemirror/language": "^6.10.1",
"@codemirror/lint": "^6.7.1",
"@codemirror/state": "^6.4.1",
"@codemirror/view": "^6.26.3",
"@lezer/common": "^1.2.1",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.5",
"@lezer/common": "^1.2.2",
"@radix-ui/react-alert-dialog": "^1.0.4",
"@radix-ui/react-collapsible": "^1.0.3",
"@radix-ui/react-dialog": "^1.0.4",
"@radix-ui/react-dropdown-menu": "^2.0.5",
"@radix-ui/react-switch": "^1.0.3",
"@rsbuild/core": "^1.0.11",
"@rsbuild/plugin-react": "^1.0.3",
"@rsbuild/plugin-type-check": "^1.0.1",
"@types/react": "^17.0.14",
"@types/react-dom": "^17.0.14",
"@types/react-paginate": "^7.1.1",
"@types/react-paginate": "^7.1.4",
"@types/react-router-dom": "^5.3.3",
"axios": "^1.6.0",
"babel-loader": "^9.1.3",
"clean-webpack-plugin": "^4.0.0",
"axios": "^1.7.7",
"clsx": "^1.1.1",
"codemirror-json-schema": "^0.7.2",
"copy-webpack-plugin": "^10.2.4",
"css-loader": "^6.7.1",
"css-minimizer-webpack-plugin": "^3.4.1",
"date-fns": "2.28.0",
"fork-ts-checker-webpack-plugin": "^7.2.7",
"codemirror-json-schema": "^0.7.8",
"date-fns": "2.29.3",
"highlight.js": "^11.5.1",
"html-webpack-plugin": "^5.5.0",
"i18next": "^23.7.7",
"i18next-hmr": "^3.0.3",
"i18next-http-backend": "^2.4.2",
"i18next-locales-sync": "^2.0.1",
"mini-css-extract-plugin": "^2.6.0",
"i18next": "^23.15.2",
"i18next-hmr": "^3.1.3",
"i18next-http-backend": "^2.6.2",
"i18next-locales-sync": "^2.1.0",
"nanoid": "^4.0.1",
"postcss": "^8.4.12",
"postcss-loader": "^6.1.1",
"postcss-preset-env": "^7.4.3",
"pretty-bytes": "^6.0.0",
"pretty-bytes": "^6.1.1",
"react": "^17.0.0",
"react-dom": "^17.0.0",
"react-i18next": "^13.5.0",
"react-paginate": "^8.1.3",
"react-refresh": "^0.12.0",
"react-i18next": "^15.0.2",
"react-paginate": "^8.2.0",
"react-router-dom": "^5.3.1",
"react-toastify": "^7.0.4",
"style-loader": "^3.3.3",
"webpack": "^5.72.0",
"webpack-bundle-analyzer": "^4.10.1",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.1",
"zustand": "^4.1.1"
"zustand": "^4.5.5"
},
"publishConfig": {
"access": "public"
Expand Down
75 changes: 75 additions & 0 deletions packages/ui/rsbuild.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { defineConfig } from '@rsbuild/core';
import { pluginReact } from '@rsbuild/plugin-react';
import { pluginTypeCheck } from '@rsbuild/plugin-type-check';
import { I18NextHMRPlugin } from 'i18next-hmr/webpack';

import path from 'node:path';
import pkgJson from './package.json';

export default defineConfig({
performance: {
bundleAnalyze:
process.env.BUNDLE_ANALYZE === 'true'
? { analyzerMode: 'static', openAnalyzer: true }
: undefined,
},
source: {
entry: {
main: path.resolve(__dirname, './src/index.tsx'),
},
define: {
'process.env.APP_VERSION': JSON.stringify(pkgJson.version),
},
},
output: {
cleanDistPath: true,
copy: [{ from: './src/static/', to: './static', info: { hotModuleReplacement: false } }],
assetPrefix: 'auto',
target: 'web',
},
plugins: [pluginReact(), pluginTypeCheck()],
tools: {
htmlPlugin: {
filename: 'index.ejs',
},
rspack: (config, { isDev }) => {
config.output = config.output || {};
config.output.hotUpdateMainFilename = 'static/hot/[runtime].[fullhash].hot-update.json';
config.output.hotUpdateChunkFilename = 'static/hot/[id].[fullhash].hot-update.js';

if (isDev) {
config.plugins?.push(
new I18NextHMRPlugin({ localesDir: path.join(__dirname, 'src/static/locales') })
);
}
},
},
html: {
template: path.resolve(__dirname, './src/index.ejs'),
templateParameters: {
basePath: '<%= basePath %>',
uiConfig: '<%- uiConfig %>',
title: '<%= title %>',
favIconDefault: '<%= favIconDefault %>',
favIconAlternative: '<%= favIconAlternative %>',
},
inject: 'body',
},
dev: {
assetPrefix: 'auto',
writeToDisk: true,
hmr: true,
liveReload: false,
client: {
host: '127.0.0.1',
port: 9000,
},
},
server: {
open: 'http://localhost:3000/ui',
port: 9000,
proxy: {
'*': 'http://127.0.0.1:3000',
},
},
});
6 changes: 3 additions & 3 deletions packages/ui/src/utils/highlight/highlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ const messageQueue = new Map<string, { resolve: any; reject: any }>();
export async function asyncHighlight(code: string, language: string): Promise<string> {
if (isWebworkerSupported) {
if (!highlightWorker) {
highlightWorker = new Worker(
/* webpackChunkName: "highlight-worker" */ new URL('./worker.ts', import.meta.url)
);
highlightWorker = new Worker(new URL('./worker.ts', import.meta.url), {
name: 'highlight-worker',
});
highlightWorker.onmessage = ({ data }) => {
const { id, code } = data;
if (messageQueue.has(id)) {
Expand Down
9 changes: 5 additions & 4 deletions packages/ui/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
"compilerOptions": {
"outDir": "dist",
"esModuleInterop": true,
"lib": ["es2019", "dom"],
"lib": ["es2021", "dom"],
"module": "ESNext",
"moduleResolution": "node",
"moduleResolution": "Bundler",
"noImplicitAny": true,
"sourceMap": true,
"strict": true,
"jsx": "react",
"target": "es2019",
"target": "es2021",
"noUnusedParameters": true,
"noUnusedLocals": true,
"resolveJsonModule": true,
"declaration": true
"declaration": true,
"noEmit": true
},
"include": ["./src", "./typings/*.d.ts"]
}
Loading

0 comments on commit a6869f1

Please sign in to comment.