build: migrate fossflow-lib from webpack to rslib

- Replace webpack + babel with rslib (Rspack-based library builder)
- Remove 122 packages (webpack, babel-loader, etc.)
- Build time reduced from minutes to ~0.7 seconds
- Remove redundant CSS import in app (quill CSS was imported twice)
This commit is contained in:
Stan
2026-01-14 06:38:15 +00:00
parent e1f1af0059
commit 45d91ec315
8 changed files with 453 additions and 2381 deletions
+399 -2116
View File
File diff suppressed because it is too large Load Diff
-1
View File
@@ -1,7 +1,6 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import 'fossflow/dist/styles.css';
import 'react-quill-new/dist/quill.snow.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
+7 -14
View File
@@ -14,10 +14,10 @@
"dist"
],
"scripts": {
"start": "webpack --watch",
"dev": "webpack --watch",
"build": "webpack && tsc --project tsconfig.declaration.json && tsc-alias",
"build:watch": "webpack --watch",
"start": "rslib build --watch",
"dev": "rslib build --watch",
"build": "rslib build && tsc --project tsconfig.declaration.json && tsc-alias",
"build:watch": "rslib build --watch",
"test": "jest",
"lint": "tsc --noEmit && eslint ./src/**/* --ext .ts,.tsx",
"lint:fix": "eslint --fix ./src/**/* --ext .ts,.tsx",
@@ -50,13 +50,11 @@
"react-dom": ">=17"
},
"devDependencies": {
"@babel/core": "^7.28.4",
"@babel/preset-env": "^7.28.3",
"@babel/preset-react": "^7.27.1",
"@babel/preset-typescript": "^7.27.1",
"@eslint/js": "^9.37.0",
"@isoflow/isopacks": "^0.0.10",
"@rsbuild/core": "^1.5.14",
"@rsbuild/plugin-react": "^1.4.1",
"@rslib/core": "^0.19.2",
"@testing-library/jest-dom": "^6.9.1",
"@testing-library/react": "^14.3.1",
"@testing-library/user-event": "^14.6.1",
@@ -68,10 +66,8 @@
"@types/pathfinding": "^0.0.6",
"@types/quill": "^2.0.14",
"@types/uuid": "^9.0.8",
"@eslint/js": "^9.37.0",
"@typescript-eslint/eslint-plugin": "^8.46.0",
"@typescript-eslint/parser": "^8.46.0",
"babel-loader": "^10.0.0",
"css-loader": "^6.11.0",
"eslint": "^9.37.0",
"eslint-config-prettier": "^10.1.8",
@@ -79,11 +75,9 @@
"eslint-plugin-prettier": "^5.5.4",
"eslint-plugin-react": "^7.37.5",
"eslint-plugin-react-hooks": "^7.0.0",
"typescript-eslint": "^8.46.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jsdom": "^21.1.2",
"mini-css-extract-plugin": "^2.9.4",
"prettier": "^3.6.2",
"react": "^18.3.1",
"react-dom": "^18.3.1",
@@ -91,7 +85,6 @@
"style-loader": "^3.3.4",
"ts-jest": "^29.4.4",
"tsc-alias": "^1.8.16",
"webpack": "^5.102.1",
"webpack-cli": "^6.0.1"
"typescript-eslint": "^8.46.0"
}
}
+47
View File
@@ -0,0 +1,47 @@
import { defineConfig } from '@rslib/core';
import { pluginReact } from '@rsbuild/plugin-react';
const packageJson = require('./package.json');
export default defineConfig({
lib: [
{
format: 'cjs',
syntax: 'es2021',
output: {
distPath: { root: './dist' },
},
style: {
inject: false,
},
},
],
plugins: [pluginReact()],
source: {
entry: {
index: './src/index.ts',
},
define: {
PACKAGE_VERSION: JSON.stringify(packageJson.version),
REPOSITORY_URL: JSON.stringify(packageJson.repository.url),
},
},
resolve: {
alias: {
src: './src',
components: './src/components',
stores: './src/stores',
styles: './src/styles',
utils: './src/utils',
hooks: './src/hooks',
types: './src/types',
},
},
output: {
externals: ['react', 'react-dom'],
target: 'node',
filename: {
css: 'styles.css',
},
},
});
-72
View File
@@ -1,72 +0,0 @@
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const webpack = require('webpack');
const packageJson = require('./package.json');
module.exports = {
mode: 'development',
entry: './src/index.ts',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'index.js',
library: {
type: 'commonjs2',
},
clean: true,
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx'],
alias: {
src: path.resolve(__dirname, 'src'),
components: path.resolve(__dirname, 'src/components'),
stores: path.resolve(__dirname, 'src/stores'),
styles: path.resolve(__dirname, 'src/styles'),
utils: path.resolve(__dirname, 'src/utils'),
hooks: path.resolve(__dirname, 'src/hooks'),
types: path.resolve(__dirname, 'src/types'),
},
},
module: {
rules: [
{
test: /\.(ts|tsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: [
'@babel/preset-env',
'@babel/preset-react',
'@babel/preset-typescript',
],
},
},
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
{
test: /\.svg$/,
type: 'asset/inline',
},
{
test: /\.(png|jpg|jpeg|gif)$/i,
type: 'asset/resource',
},
],
},
plugins: [
new MiniCssExtractPlugin({
filename: 'styles.css',
}),
new webpack.DefinePlugin({
PACKAGE_VERSION: JSON.stringify(packageJson.version),
REPOSITORY_URL: JSON.stringify(packageJson.repository.url),
}),
],
externals: {
react: 'commonjs react',
'react-dom': 'commonjs react-dom',
},
};
@@ -1,61 +0,0 @@
const path = require('path');
const HtmlWebPackPlugin = require('html-webpack-plugin');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const webpack = require('webpack');
module.exports = {
mode: 'development',
entry: './src/index.tsx',
devtool: 'eval-cheap-source-map',
target: 'web',
output: {
filename: 'main.js',
path: path.resolve(__dirname, 'build')
},
devServer: {
static: {
directory: path.join(__dirname, 'build')
},
allowedHosts: [
'.csb.app', // So Codesandbox.io can run the dev server
'.ngrok-free.app'
],
port: 3000
},
module: {
rules: [
{
test: /\.(ts|tsx)$/,
use: {
loader: 'ts-loader',
options: {
configFile: 'tsconfig.dev.json'
}
},
exclude: /node_modules/
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader']
},
{
test: /\.svg$/i,
type: 'asset/inline'
}
]
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
plugins: [new TsconfigPathsPlugin()]
},
plugins: [
new HtmlWebPackPlugin({
template: path.resolve(__dirname, '../src/index.html')
}),
new webpack.DefinePlugin({
PACKAGE_VERSION: JSON.stringify(require("../package.json").version),
REPOSITORY_URL: JSON.stringify(require("../package.json").repository.url),
})
]
};
@@ -1,45 +0,0 @@
const path = require('path');
const HtmlWebPackPlugin = require('html-webpack-plugin');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const webpack = require('webpack');
module.exports = {
mode: 'production',
entry: './src/index-docker.tsx',
target: 'web',
output: {
path: path.resolve(__dirname, '../dist'),
filename: 'main.js',
},
module: {
rules: [
{
test: /\.(ts|tsx)$/,
use: 'ts-loader',
exclude: /node_modules/
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader']
},
{
test: /\.svg$/i,
type: 'asset/inline'
}
]
},
plugins: [
new HtmlWebPackPlugin({
template: path.resolve(__dirname, '../src/index.html')
}),
new webpack.DefinePlugin({
PACKAGE_VERSION: JSON.stringify(require("../package.json").version),
REPOSITORY_URL: JSON.stringify(require("../package.json").repository.url),
})
],
resolve: {
extensions: ['.tsx', '.ts', '.js'],
plugins: [new TsconfigPathsPlugin()]
}
};
@@ -1,72 +0,0 @@
const path = require('path');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const webpack = require('webpack');
module.exports = {
mode: 'production',
target: 'web',
entry: {
'index': './src/index.ts',
'standaloneExports': './src/standaloneExports.ts',
},
output: {
path: path.resolve(__dirname, '../dist'),
filename: '[name].js',
libraryTarget: 'commonjs2',
clean: true
},
externals: {
react: {
commonjs: 'react',
commonjs2: 'react',
amd: 'React',
root: 'React'
},
'react-dom': {
commonjs: 'react-dom',
commonjs2: 'react-dom',
amd: 'ReactDOM',
root: 'ReactDOM'
},
'@mui/material': '@mui/material',
'@mui/icons-material': '@mui/icons-material',
'@emotion/react': '@emotion/react',
'@emotion/styled': '@emotion/styled'
},
module: {
rules: [
{
test: /\.(ts|tsx)$/,
use: {
loader: 'ts-loader',
options: {
transpileOnly: true,
compilerOptions: {
declaration: false,
emitDeclarationOnly: false
}
}
},
exclude: /node_modules/
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader']
},
{
test: /\.svg$/,
type: 'asset/inline'
}
]
},
plugins: [
new webpack.DefinePlugin({
PACKAGE_VERSION: JSON.stringify(require("../package.json").version),
REPOSITORY_URL: JSON.stringify(require("../package.json").repository.url),
})
],
resolve: {
extensions: ['.tsx', '.ts', '.js'],
plugins: [new TsconfigPathsPlugin()]
}
};