Skip to content

Commit 866c636

Browse files
authored
Replace webpack with rspack (#35460)
Given that this bundler is almost a drop-in replacement to webpack, it might be worth switching. So far it seems everything is working, but more testing is needed, so I'm setting draft. - Dev build time is reduced from 10s to 5s - Prod build time is reduced from 16s to 10s - JS output size is reduced from 21.3MB to 19.8MB - CSS output size is increased from 778kB to 818kB
1 parent 7a474d1 commit 866c636

File tree

5 files changed

+1746
-281
lines changed

5 files changed

+1746
-281
lines changed

Makefile

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,10 @@ LINUX_ARCHS ?= linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64,linux/r
135135
GO_TEST_PACKAGES ?= $(filter-out $(shell $(GO) list code.gitea.io/gitea/models/migrations/...) code.gitea.io/gitea/tests/integration/migration-test code.gitea.io/gitea/tests code.gitea.io/gitea/tests/integration code.gitea.io/gitea/tests/e2e,$(shell $(GO) list ./... | grep -v /vendor/))
136136
MIGRATE_TEST_PACKAGES ?= $(shell $(GO) list code.gitea.io/gitea/models/migrations/...)
137137

138-
WEBPACK_SOURCES := $(shell find web_src/js web_src/css -type f)
139-
WEBPACK_CONFIGS := webpack.config.ts tailwind.config.ts
140-
WEBPACK_DEST := public/assets/js/index.js public/assets/css/index.css
141-
WEBPACK_DEST_ENTRIES := public/assets/js public/assets/css public/assets/fonts
138+
RSPACK_SOURCES := $(shell find web_src/js web_src/css -type f)
139+
RSPACK_CONFIGS := rspack.config.ts tailwind.config.ts
140+
RSPACK_DEST := public/assets/js/index.js public/assets/css/index.css
141+
RSPACK_DEST_ENTRIES := public/assets/js public/assets/css public/assets/fonts
142142

143143
BINDATA_DEST_WILDCARD := modules/migration/bindata.* modules/public/bindata.* modules/options/bindata.* modules/templates/bindata.*
144144

@@ -238,7 +238,7 @@ node-check:
238238

239239
.PHONY: clean-all
240240
clean-all: clean ## delete backend, frontend and integration files
241-
rm -rf $(WEBPACK_DEST_ENTRIES) node_modules
241+
rm -rf $(RSPACK_DEST_ENTRIES) node_modules
242242

243243
.PHONY: clean
244244
clean: ## delete backend and integration files
@@ -428,8 +428,8 @@ watch: ## watch everything and continuously rebuild
428428

429429
.PHONY: watch-frontend
430430
watch-frontend: node-check node_modules ## watch frontend files and continuously rebuild
431-
@rm -rf $(WEBPACK_DEST_ENTRIES)
432-
NODE_ENV=development $(NODE_VARS) pnpm exec webpack --watch --progress --disable-interpret
431+
@rm -rf $(RSPACK_DEST_ENTRIES)
432+
NODE_ENV=development $(NODE_VARS) pnpm exec rspack --watch
433433

434434
.PHONY: watch-backend
435435
watch-backend: go-check ## watch backend files and continuously rebuild
@@ -747,7 +747,7 @@ install: $(wildcard *.go)
747747
build: frontend backend ## build everything
748748

749749
.PHONY: frontend
750-
frontend: $(WEBPACK_DEST) ## build frontend files
750+
frontend: $(RSPACK_DEST) ## build frontend files
751751

752752
.PHONY: backend
753753
backend: go-check generate-backend $(EXECUTABLE) ## build backend files
@@ -878,15 +878,15 @@ update-py: node-check | node_modules ## update py dependencies
878878
uv sync
879879
@touch .venv
880880

881-
.PHONY: webpack
882-
webpack: $(WEBPACK_DEST) ## build webpack files
881+
.PHONY: rspack
882+
rspack: $(RSPACK_DEST) ## build rspack files
883883

884-
$(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) pnpm-lock.yaml
884+
$(RSPACK_DEST): $(RSPACK_SOURCES) $(RSPACK_CONFIGS) pnpm-lock.yaml
885885
@$(MAKE) -s node-check node_modules
886-
@rm -rf $(WEBPACK_DEST_ENTRIES)
887-
@echo "Running webpack..."
888-
@BROWSERSLIST_IGNORE_OLD_DATA=true $(NODE_VARS) pnpm exec webpack --disable-interpret
889-
@touch $(WEBPACK_DEST)
886+
@rm -rf $(RSPACK_DEST_ENTRIES)
887+
@echo "Running rspack..."
888+
@$(NODE_VARS) pnpm exec rspack
889+
@touch $(RSPACK_DEST)
890890

891891
.PHONY: svg
892892
svg: node-check | node_modules ## build svg files

package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616
"@mcaptcha/vanilla-glue": "0.1.0-alpha-3",
1717
"@primer/octicons": "19.18.0",
1818
"@resvg/resvg-wasm": "2.6.2",
19+
"@rspack/cli": "1.5.3",
20+
"@rspack/core": "1.5.3",
1921
"@silverwind/vue3-calendar-heatmap": "2.0.6",
2022
"@techknowlogick/license-checker-webpack-plugin": "0.3.0",
21-
"add-asset-webpack-plugin": "3.0.0",
23+
"add-asset-webpack-plugin": "3.1.0",
2224
"ansi_up": "6.0.6",
2325
"asciinema-player": "3.10.0",
2426
"chart.js": "4.5.0",
@@ -30,13 +32,11 @@
3032
"dayjs": "1.11.18",
3133
"dropzone": "6.0.0-beta.2",
3234
"easymde": "2.20.0",
33-
"esbuild-loader": "4.3.0",
3435
"htmx.org": "2.0.7",
3536
"idiomorph": "0.7.3",
3637
"jquery": "3.7.1",
3738
"katex": "0.16.22",
3839
"mermaid": "11.11.0",
39-
"mini-css-extract-plugin": "2.9.4",
4040
"minimatch": "10.0.3",
4141
"monaco-editor": "0.53.0",
4242
"monaco-editor-webpack-plugin": "7.1.0",
@@ -61,8 +61,6 @@
6161
"vue-bar-graph": "2.2.0",
6262
"vue-chartjs": "5.3.2",
6363
"vue-loader": "17.4.2",
64-
"webpack": "5.101.3",
65-
"webpack-cli": "6.0.1",
6664
"wrap-ansi": "9.0.2"
6765
},
6866
"devDependencies": {

0 commit comments

Comments
 (0)