Skip to content

Commit a48d545

Browse files
committed
refactor: cleanup & migrate to rspack
1 parent b669e7c commit a48d545

23 files changed

+1463
-1670
lines changed

.babelrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"presets": ["@babel/preset-typescript", ["@babel/preset-react", { "runtime": "automatic" }]],
3+
"plugins": ["@emotion/babel-plugin", "babel-plugin-macros"]
4+
}

babel.config.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

package.json

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
{
2+
"private": true,
3+
"packageManager": "[email protected]",
24
"scripts": {
3-
"build:chrome": "webpack --env platform=chrome --mode=production",
4-
"build:firefox": "webpack --env platform=firefox --mode=production",
5-
"develop:chrome": "webpack --env platform=chrome --mode=development --watch",
6-
"develop:firefox": "webpack --env platform=firefox --mode=development --watch",
5+
"build:chrome": "rspack --env platform=chrome --mode=production",
6+
"build:firefox": "rspack --env platform=firefox --mode=production",
7+
"develop:chrome": "rspack --env platform=chrome --mode=development --watch",
8+
"develop:firefox": "rspack --env platform=firefox --mode=development --watch",
79
"prepare": "husky install",
810
"test": "tsc --noEmit && eslint --ext=tsx,ts ."
911
},
@@ -14,7 +16,7 @@
1416
"@emotion/styled": "^11.10.8",
1517
"@floating-ui/react": "^0.25.0",
1618
"@tabler/icons-react": "^2.30.0",
17-
"lodash-es": "^4.17.21",
19+
"es-toolkit": "^1.38.0",
1820
"overlayscrollbars": "^2.2.1",
1921
"overlayscrollbars-react": "^0.5.1",
2022
"react": "^18.2.0",
@@ -27,15 +29,14 @@
2729
},
2830
"devDependencies": {
2931
"@babel/core": "^7.22.9",
30-
"@babel/plugin-transform-runtime": "^7.22.9",
31-
"@babel/preset-env": "^7.22.9",
3232
"@babel/preset-react": "^7.22.5",
3333
"@babel/preset-typescript": "^7.22.5",
3434
"@commitlint/cli": "^17.6.7",
3535
"@commitlint/config-conventional": "^17.6.7",
3636
"@emotion/babel-plugin": "^11.10.8",
37+
"@rspack/cli": "^1.3.12",
38+
"@rspack/core": "^1.3.12",
3739
"@seldszar/yael": "^2.2.0",
38-
"@types/lodash-es": "^4.17.8",
3940
"@types/react": "^18.2.18",
4041
"@types/react-dom": "^18.2.7",
4142
"@types/webextension-polyfill": "^0.10.1",
@@ -44,26 +45,17 @@
4445
"autoprefixer": "^10.4.14",
4546
"babel-loader": "^9.1.3",
4647
"babel-plugin-macros": "^3.1.0",
47-
"copy-webpack-plugin": "^11.0.0",
48-
"css-loader": "^6.8.1",
4948
"dotenv": "^16.3.1",
5049
"eslint": "^8.46.0",
5150
"eslint-config-prettier": "^8.10.0",
5251
"eslint-plugin-prettier": "^5.0.0",
5352
"eslint-plugin-react": "^7.33.1",
54-
"html-webpack-plugin": "^5.5.3",
5553
"husky": "^8.0.3",
5654
"lint-staged": "^13.2.3",
57-
"mini-css-extract-plugin": "^2.7.6",
58-
"postcss": "^8.4.27",
59-
"postcss-loader": "^7.3.3",
6055
"prettier": "^3.0.1",
61-
"style-loader": "^3.3.3",
6256
"tailwindcss": "^3.3.3",
6357
"twin.macro": "^3.4.0",
6458
"typescript": "^5.1.6",
65-
"webpack": "^5.88.2",
66-
"webpack-cli": "^5.1.4",
6759
"webpack-merge": "^5.9.0"
6860
},
6961
"babelMacros": {

postcss.config.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

webpack.config.js renamed to rspack.config.js

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@ require("dotenv/config");
22

33
const fs = require("fs");
44
const path = require("path");
5-
const webpack = require("webpack");
6-
const { merge } = require("webpack-merge");
75

6+
const { rspack } = require("@rspack/core");
87
const { EntryWrapperPlugin } = require("@seldszar/yael");
9-
10-
const CopyWebpackPlugin = require("copy-webpack-plugin");
11-
const HtmlWebpackPlugin = require("html-webpack-plugin");
8+
const { merge } = require("webpack-merge");
129

1310
const localeReplacements = [
1411
{
@@ -24,13 +21,10 @@ module.exports = (env, argv) => {
2421
devtool: isDevelopment ? "inline-cheap-source-map" : false,
2522
output: {
2623
path: path.resolve("dist"),
27-
publicPath: "",
2824
},
2925
resolve: {
30-
extensions: [".tsx", ".ts", ".jsx", ".js", ".json"],
31-
alias: {
32-
"~": path.resolve("src"),
33-
},
26+
extensions: [".tsx", ".ts", ".js", ".json", ".wasm"],
27+
tsConfig: path.resolve("tsconfig.json"),
3428
},
3529
module: {
3630
rules: [
@@ -42,15 +36,14 @@ module.exports = (env, argv) => {
4236
],
4337
},
4438
plugins: [
45-
new webpack.EnvironmentPlugin({
39+
new rspack.EnvironmentPlugin({
4640
TWITCH_CLIENT_ID: undefined,
4741
TWITCH_REDIRECT_URI: undefined,
48-
SENTRY_DSN: null,
4942
}),
50-
new webpack.ProvidePlugin({
43+
new rspack.ProvidePlugin({
5144
browser: "webextension-polyfill",
5245
}),
53-
new CopyWebpackPlugin({
46+
new rspack.CopyRspackPlugin({
5447
patterns: [
5548
{
5649
from: "**/*",
@@ -88,12 +81,6 @@ module.exports = (env, argv) => {
8881
],
8982
}),
9083
],
91-
cache: {
92-
type: "filesystem",
93-
buildDependencies: {
94-
config: [__filename],
95-
},
96-
},
9784
};
9885

9986
return [
@@ -103,31 +90,20 @@ module.exports = (env, argv) => {
10390
popup: "./src/browser/pages/popup.tsx",
10491
settings: "./src/browser/pages/settings.tsx",
10592
},
106-
module: {
107-
rules: [
108-
{
109-
test: /\.css$/,
110-
use: ["style-loader", "css-loader", "postcss-loader"],
111-
},
112-
],
113-
},
114-
optimization: {
115-
splitChunks: {
116-
name: "commons",
117-
chunks: "all",
118-
},
93+
experiments: {
94+
css: true,
11995
},
12096
plugins: [
12197
new EntryWrapperPlugin({
12298
template: "./src/browser/entry-template.tsx",
12399
test: /\.tsx$/,
124100
}),
125-
new HtmlWebpackPlugin({
101+
new rspack.HtmlRspackPlugin({
126102
template: "./src/browser/entry-template.html",
127103
filename: "popup.html",
128104
chunks: ["popup"],
129105
}),
130-
new HtmlWebpackPlugin({
106+
new rspack.HtmlRspackPlugin({
131107
template: "./src/browser/entry-template.html",
132108
filename: "settings.html",
133109
chunks: ["settings"],

src/background/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { get } from "lodash-es";
1+
import { get } from "es-toolkit/compat";
22

33
import { openUrl } from "~/common/helpers";
44
import { stores } from "~/common/stores";

src/background/modules/maintenance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { get } from "lodash-es";
1+
import { get } from "es-toolkit/compat";
22

33
import { stores, StoreState } from "~/common/stores";
44
import { Dictionary } from "~/common/types";

src/background/modules/twitch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { camelCase, castArray, chunk, find, get, snakeCase, toString } from "lodash-es";
1+
import { camelCase, castArray, chunk, find, get, snakeCase, toString } from "es-toolkit/compat";
22

33
import { allPromises, changeCase, isRerunStream, matchString, openUrl, t } from "~/common/helpers";
44
import { stores } from "~/common/stores";

src/browser/components/CheckboxGrid.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { map, xor } from "lodash-es";
1+
import { map, xor } from "es-toolkit/compat";
22
import { ReactNode } from "react";
33
import tw, { styled } from "twin.macro";
44

src/browser/components/CollectionList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { IconPencil, IconSettings, IconTrash } from "@tabler/icons-react";
2-
import { reject } from "lodash-es";
2+
import { reject } from "es-toolkit/compat";
33
import { Fragment, ReactNode, useMemo, useState } from "react";
44
import tw, { styled } from "twin.macro";
55

0 commit comments

Comments
 (0)