Skip to content

Commit

Permalink
feat: rspack 1.0.0 (#84)
Browse files Browse the repository at this point in the history
* deps: upgrade to rspack 1.0.0

* Fix proxy type
  • Loading branch information
puehringer authored Sep 4, 2024
1 parent f01689b commit 6d2c68a
Show file tree
Hide file tree
Showing 4 changed files with 1,423 additions and 1,263 deletions.
3 changes: 2 additions & 1 deletion config/eslintrc.template.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ module.exports = ({ tsconfigRootDir }) => ({
'plugin:react/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
'plugin:lodash/recommended',
],
plugins: ['react', '@typescript-eslint', 'react-compiler'],
plugins: ['react', '@typescript-eslint', 'react-compiler', 'lodash'],
ignorePatterns: ['*.js'],
env: {
browser: true,
Expand Down
36 changes: 19 additions & 17 deletions config/rspack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const dotenv = require('dotenv');
const { DotenvPlugin } = require('rspack-plugin-dotenv');
const dotenvExpand = require('dotenv-expand');
const {
CopyRspackPlugin, DefinePlugin, SwcJsMinimizerRspackPlugin, SwcCssMinimizerRspackPlugin,
CopyRspackPlugin, DefinePlugin, SwcJsMinimizerRspackPlugin, LightningCssMinimizerRspackPlugin,
} = require('@rspack/core');
const ReactRefreshPlugin = require('@rspack/plugin-react-refresh');
const HtmlWebpackPlugin = require('html-webpack-plugin');
Expand All @@ -31,7 +31,7 @@ module.exports = (webpackEnv, argv) => {
}

const isDevServerOnly = env.dev_server_only?.toLowerCase() === 'true';
const devtool = env.devtool?.toLowerCase() === 'false' ? false : (env.devtool || (isEnvDevelopment ? 'eval-cheap-module-source-map' : 'source-map'));
const devtool = env.devtool?.toLowerCase() === 'false' ? false : (env.devtool || (isEnvDevelopment ? 'eval-source-map' : 'source-map'));
const isReactRefresh = isDevServer && isEnvDevelopment;

const now = new Date();
Expand Down Expand Up @@ -114,23 +114,22 @@ module.exports = (webpackEnv, argv) => {
open: true,
// Needs to be enabled to make SPAs work: https://stackoverflow.com/questions/31945763/how-to-tell-webpack-dev-server-to-serve-index-html-for-any-route
historyApiFallback: historyApiFallback == null ? true : historyApiFallback,
proxy: {
proxy: [
// Append on top to allow overriding /api/v1/ for example
...(devServerProxy || {}),
...{
'/api/*': {
target: 'http://localhost:9000',
secure: false,
ws: true,
// Explicitly forward close events for properly closing SSE (server-side events). See https://github.com/webpack/webpack-dev-server/issues/2769#issuecomment-1517290190
onProxyReq: (proxyReq, req, res) => {
res.on('close', () => proxyReq.destroy());
},
...(devServerProxy || []),
{
context: ['/api/'],
target: 'http://localhost:9000',
secure: false,
ws: true,
// Explicitly forward close events for properly closing SSE (server-side events). See https://github.com/webpack/webpack-dev-server/issues/2769#issuecomment-1517290190
onProxyReq: (proxyReq, req, res) => {
res.on('close', () => proxyReq.destroy());
},
// Append on bottom to allow override of exact key matches like /api/*
...(devServerProxy || {}),
},
},
// Append on bottom to allow override of exact key matches like /api/*
...(devServerProxy || []),
],
client: {
// Do not show the full-page error overlay
overlay: false,
Expand Down Expand Up @@ -182,9 +181,12 @@ module.exports = (webpackEnv, argv) => {
compress: false,
mangle: false,
}),
new SwcCssMinimizerRspackPlugin(),
new LightningCssMinimizerRspackPlugin(),
],
},
experiments: {
css: true,
},
module: {
rules: [
{
Expand Down
57 changes: 29 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,29 @@
"dist": "npm run lint && npm run test"
},
"dependencies": {
"@rsdoctor/cli": "^0.3.10",
"@rsdoctor/rspack-plugin": "^0.3.10",
"@rspack/cli": "~0.7.5",
"@rspack/core": "~0.7.5",
"@rsdoctor/cli": "^0.3.11",
"@rsdoctor/rspack-plugin": "^0.3.11",
"@rspack/cli": "~1.0.0",
"@rspack/core": "~1.0.0",
"@rspack/plugin-minify": "~0.7.5",
"@rspack/plugin-react-refresh": "~0.7.5",
"@storybook/addon-actions": "^7.6.17",
"@storybook/addon-essentials": "^7.6.17",
"@storybook/addon-interactions": "^7.6.17",
"@storybook/addon-links": "^7.6.17",
"@rspack/plugin-react-refresh": "~1.0.0",
"@storybook/addon-actions": "^7.6.20",
"@storybook/addon-essentials": "^7.6.20",
"@storybook/addon-interactions": "^7.6.20",
"@storybook/addon-links": "^7.6.20",
"@storybook/addon-styling": "^1.3.7",
"@storybook/addon-styling-webpack": "^0.0.6",
"@storybook/cli": "^7.6.17",
"@storybook/react": "^7.6.17",
"@storybook/react-webpack5": "^7.6.17",
"@storybook/addon-styling-webpack": "^1.0.0",
"@storybook/cli": "^7.6.20",
"@storybook/react": "^7.6.20",
"@storybook/react-webpack5": "^7.6.20",
"@storybook/testing-library": "0.2.2",
"@swc/core": "~1.7.2",
"@swc/core": "~1.7.21",
"@swc/helpers": "~0.5.12",
"@swc/jest": "~0.2.36",
"@types/jest": "~27.4.1",
"@types/node": "^20.14.12",
"@typescript-eslint/eslint-plugin": "~7.17.0",
"@typescript-eslint/parser": "~7.17.0",
"@typescript-eslint/eslint-plugin": "~8.3.0",
"@typescript-eslint/parser": "~8.3.0",
"dotenv": "^16.4.5",
"dotenv-expand": "^11.0.6",
"eslint": "^8.57.0",
Expand All @@ -64,14 +64,15 @@
"eslint-config-airbnb-typescript": "^18.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-react-app": "^7.0.1",
"eslint-plugin-chai-friendly": "^1.0.0",
"eslint-plugin-cypress": "^3.4.0",
"eslint-plugin-chai-friendly": "^1.0.1",
"eslint-plugin-cypress": "^3.5.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-jsx-a11y": "^6.9.0",
"eslint-plugin-lodash": "^8.0.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react": "^7.35.0",
"eslint-plugin-react-compiler": "0.0.0-experimental-9ed098e-20240725",
"eslint-plugin-react-compiler": "0.0.0-experimental-0924e7a-20240827",
"eslint-plugin-react-hooks": "^4.6.2",
"fork-ts-checker-webpack-plugin": "^9.0.2",
"fs-extra": "^11.2.0",
Expand All @@ -82,36 +83,36 @@
"jest": "^27.5.1",
"jest-raw-loader": "~1.0.1",
"jest-resolve": "^27.4.2",
"postcss": "^8.4.35",
"postcss": "^8.4.41",
"postcss-flexbugs-fixes": "^5.0.2",
"postcss-loader": "^8.1.1",
"postcss-normalize": "^10.0.1",
"postcss-preset-env": "^9.6.0",
"postcss-preset-env": "^10.0.2",
"prettier": "^3.3.3",
"react-dev-utils": "^12.0.1",
"react-refresh": "^0.14.2",
"resolve-url-loader": "^5.0.0",
"rimraf": "~6.0.1",
"rspack-plugin-dotenv": "^0.0.3",
"sass-embedded": "~1.77.8",
"sass-loader": "^16.0.0",
"sass-loader": "^16.0.1",
"shx": "~0.3.4",
"storybook": "^7.6.17",
"storybook": "^7.6.20",
"storybook-addon-swc": "^1.2.0",
"tailwindcss": "^3.4.7",
"tailwindcss": "^3.4.10",
"ts-node": "^10.9.2",
"tslib": "~2.6.3",
"tslib": "~2.7.0",
"typescript": "~5.5.4",
"util": "^0.12.5",
"yargs": "^17.7.2"
},
"devDependencies": {
"@types/yargs": "^17.0.32",
"@types/yargs": "^17.0.33",
"http-server": "^14.1.1",
"jest-dev-server": "^6.1.1"
"jest-dev-server": "^6.2.0"
},
"peerDependencies": {
"@types/react": "^18.3.3",
"@types/react": "^18.3.4",
"@types/react-dom": "^18.3.0",
"react": "^18.3.1",
"react-dom": "^18.3.1"
Expand Down
Loading

0 comments on commit 6d2c68a

Please sign in to comment.