1
1
mirror of https://github.com/go-gitea/gitea synced 2025-09-15 21:28:15 +00:00

Revert the rspack change (#35482)

Partially revert https://github.com/go-gitea/gitea/pull/35460 until
rspack supports RISC-V
(https://github.com/web-infra-dev/rspack/issues/11656).
This commit is contained in:
silverwind
2025-09-14 08:37:07 +02:00
committed by GitHub
parent 4fe1066a17
commit e612b9744c
4 changed files with 283 additions and 1769 deletions

View File

@@ -135,10 +135,10 @@ LINUX_ARCHS ?= linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64,linux/r
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/)) 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/))
MIGRATE_TEST_PACKAGES ?= $(shell $(GO) list code.gitea.io/gitea/models/migrations/...) MIGRATE_TEST_PACKAGES ?= $(shell $(GO) list code.gitea.io/gitea/models/migrations/...)
RSPACK_SOURCES := $(shell find web_src/js web_src/css -type f) WEBPACK_SOURCES := $(shell find web_src/js web_src/css -type f)
RSPACK_CONFIGS := rspack.config.ts tailwind.config.ts WEBPACK_CONFIGS := webpack.config.ts tailwind.config.ts
RSPACK_DEST := public/assets/js/index.js public/assets/css/index.css WEBPACK_DEST := public/assets/js/index.js public/assets/css/index.css
RSPACK_DEST_ENTRIES := public/assets/js public/assets/css public/assets/fonts WEBPACK_DEST_ENTRIES := public/assets/js public/assets/css public/assets/fonts
BINDATA_DEST_WILDCARD := modules/migration/bindata.* modules/public/bindata.* modules/options/bindata.* modules/templates/bindata.* BINDATA_DEST_WILDCARD := modules/migration/bindata.* modules/public/bindata.* modules/options/bindata.* modules/templates/bindata.*
@@ -238,7 +238,7 @@ node-check:
.PHONY: clean-all .PHONY: clean-all
clean-all: clean ## delete backend, frontend and integration files clean-all: clean ## delete backend, frontend and integration files
rm -rf $(RSPACK_DEST_ENTRIES) node_modules rm -rf $(WEBPACK_DEST_ENTRIES) node_modules
.PHONY: clean .PHONY: clean
clean: ## delete backend and integration files clean: ## delete backend and integration files
@@ -428,8 +428,8 @@ watch: ## watch everything and continuously rebuild
.PHONY: watch-frontend .PHONY: watch-frontend
watch-frontend: node-check node_modules ## watch frontend files and continuously rebuild watch-frontend: node-check node_modules ## watch frontend files and continuously rebuild
@rm -rf $(RSPACK_DEST_ENTRIES) @rm -rf $(WEBPACK_DEST_ENTRIES)
NODE_ENV=development $(NODE_VARS) pnpm exec rspack --watch NODE_ENV=development $(NODE_VARS) pnpm exec webpack --watch --progress --disable-interpret
.PHONY: watch-backend .PHONY: watch-backend
watch-backend: go-check ## watch backend files and continuously rebuild watch-backend: go-check ## watch backend files and continuously rebuild
@@ -747,7 +747,7 @@ install: $(wildcard *.go)
build: frontend backend ## build everything build: frontend backend ## build everything
.PHONY: frontend .PHONY: frontend
frontend: $(RSPACK_DEST) ## build frontend files frontend: $(WEBPACK_DEST) ## build frontend files
.PHONY: backend .PHONY: backend
backend: go-check generate-backend $(EXECUTABLE) ## build backend files backend: go-check generate-backend $(EXECUTABLE) ## build backend files
@@ -878,15 +878,15 @@ update-py: node-check | node_modules ## update py dependencies
uv sync uv sync
@touch .venv @touch .venv
.PHONY: rspack .PHONY: webpack
rspack: $(RSPACK_DEST) ## build rspack files webpack: $(WEBPACK_DEST) ## build webpack files
$(RSPACK_DEST): $(RSPACK_SOURCES) $(RSPACK_CONFIGS) pnpm-lock.yaml $(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) pnpm-lock.yaml
@$(MAKE) -s node-check node_modules @$(MAKE) -s node-check node_modules
@rm -rf $(RSPACK_DEST_ENTRIES) @rm -rf $(WEBPACK_DEST_ENTRIES)
@echo "Running rspack..." @echo "Running webpack..."
@$(NODE_VARS) pnpm exec rspack @BROWSERSLIST_IGNORE_OLD_DATA=true $(NODE_VARS) pnpm exec webpack --disable-interpret
@touch $(RSPACK_DEST) @touch $(WEBPACK_DEST)
.PHONY: svg .PHONY: svg
svg: node-check | node_modules ## build svg files svg: node-check | node_modules ## build svg files

View File

@@ -16,11 +16,9 @@
"@mcaptcha/vanilla-glue": "0.1.0-alpha-3", "@mcaptcha/vanilla-glue": "0.1.0-alpha-3",
"@primer/octicons": "19.18.0", "@primer/octicons": "19.18.0",
"@resvg/resvg-wasm": "2.6.2", "@resvg/resvg-wasm": "2.6.2",
"@rspack/cli": "1.5.3",
"@rspack/core": "1.5.3",
"@silverwind/vue3-calendar-heatmap": "2.0.6", "@silverwind/vue3-calendar-heatmap": "2.0.6",
"@techknowlogick/license-checker-webpack-plugin": "0.3.0", "@techknowlogick/license-checker-webpack-plugin": "0.3.0",
"add-asset-webpack-plugin": "3.1.0", "add-asset-webpack-plugin": "3.1.1",
"ansi_up": "6.0.6", "ansi_up": "6.0.6",
"asciinema-player": "3.10.0", "asciinema-player": "3.10.0",
"chart.js": "4.5.0", "chart.js": "4.5.0",
@@ -32,11 +30,14 @@
"dayjs": "1.11.18", "dayjs": "1.11.18",
"dropzone": "6.0.0-beta.2", "dropzone": "6.0.0-beta.2",
"easymde": "2.20.0", "easymde": "2.20.0",
"esbuild-loader": "4.3.0",
"htmx.org": "2.0.7", "htmx.org": "2.0.7",
"idiomorph": "0.7.3", "idiomorph": "0.7.3",
"jquery": "3.7.1", "jquery": "3.7.1",
"katex": "0.16.22", "katex": "0.16.22",
"mermaid": "11.11.0", "mermaid": "11.11.0",
"mini-css-extract-plugin": "2.9.4",
"minimatch": "10.0.3",
"monaco-editor": "0.53.0", "monaco-editor": "0.53.0",
"monaco-editor-webpack-plugin": "7.1.0", "monaco-editor-webpack-plugin": "7.1.0",
"online-3d-viewer": "0.16.0", "online-3d-viewer": "0.16.0",
@@ -60,6 +61,8 @@
"vue-bar-graph": "2.2.0", "vue-bar-graph": "2.2.0",
"vue-chartjs": "5.3.2", "vue-chartjs": "5.3.2",
"vue-loader": "17.4.2", "vue-loader": "17.4.2",
"webpack": "5.101.3",
"webpack-cli": "6.0.1",
"wrap-ansi": "9.0.2" "wrap-ansi": "9.0.2"
}, },
"devDependencies": { "devDependencies": {

1945
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,17 +1,12 @@
import wrapAnsi from 'wrap-ansi'; import wrapAnsi from 'wrap-ansi';
import AddAssetPlugin from 'add-asset-webpack-plugin'; import AddAssetPlugin from 'add-asset-webpack-plugin';
import LicenseCheckerWebpackPlugin from '@techknowlogick/license-checker-webpack-plugin'; import LicenseCheckerWebpackPlugin from '@techknowlogick/license-checker-webpack-plugin';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import MonacoWebpackPlugin from 'monaco-editor-webpack-plugin'; import MonacoWebpackPlugin from 'monaco-editor-webpack-plugin';
import {VueLoaderPlugin} from 'vue-loader'; import {VueLoaderPlugin} from 'vue-loader';
import EsBuildLoader from 'esbuild-loader';
import {parse} from 'node:path'; import {parse} from 'node:path';
import { import webpack, {type Configuration, type EntryObject} from 'webpack';
SourceMapDevToolPlugin,
DefinePlugin,
EnvironmentPlugin,
CssExtractRspackPlugin,
type Configuration,
type EntryObject,
} from '@rspack/core';
import {fileURLToPath} from 'node:url'; import {fileURLToPath} from 'node:url';
import {readFileSync, globSync} from 'node:fs'; import {readFileSync, globSync} from 'node:fs';
import {env} from 'node:process'; import {env} from 'node:process';
@@ -20,6 +15,8 @@ import tailwindConfig from './tailwind.config.ts';
import tailwindcssNesting from 'tailwindcss/nesting/index.js'; import tailwindcssNesting from 'tailwindcss/nesting/index.js';
import postcssNesting from 'postcss-nesting'; import postcssNesting from 'postcss-nesting';
const {EsbuildPlugin} = EsBuildLoader;
const {SourceMapDevToolPlugin, DefinePlugin, EnvironmentPlugin} = webpack;
const formatLicenseText = (licenseText: string) => wrapAnsi(licenseText || '', 80).trim(); const formatLicenseText = (licenseText: string) => wrapAnsi(licenseText || '', 80).trim();
const themes: EntryObject = {}; const themes: EntryObject = {};
@@ -33,7 +30,7 @@ const isProduction = env.NODE_ENV !== 'development';
// true - all enabled, the default in development // true - all enabled, the default in development
// reduced - minimal sourcemaps, the default in production // reduced - minimal sourcemaps, the default in production
// false - all disabled // false - all disabled
let sourceMaps: string; let sourceMaps;
if ('ENABLE_SOURCEMAP' in env) { if ('ENABLE_SOURCEMAP' in env) {
sourceMaps = ['true', 'false'].includes(env.ENABLE_SOURCEMAP) ? env.ENABLE_SOURCEMAP : 'reduced'; sourceMaps = ['true', 'false'].includes(env.ENABLE_SOURCEMAP) ? env.ENABLE_SOURCEMAP : 'reduced';
} else { } else {
@@ -96,12 +93,20 @@ export default {
path: fileURLToPath(new URL('public/assets', import.meta.url)), path: fileURLToPath(new URL('public/assets', import.meta.url)),
filename: () => 'js/[name].js', filename: () => 'js/[name].js',
chunkFilename: ({chunk}) => { chunkFilename: ({chunk}) => {
const language = (/monaco.*languages?_.+?_(.+?)_/.exec(chunk.id) || [])[1]; const language = (/monaco.*languages?_.+?_(.+?)_/.exec(String(chunk.id)) || [])[1];
return `js/${language ? `monaco-language-${language.toLowerCase()}` : `[name]`}.[contenthash:8].js`; return `js/${language ? `monaco-language-${language.toLowerCase()}` : `[name]`}.[contenthash:8].js`;
}, },
}, },
optimization: { optimization: {
minimize: isProduction, minimize: isProduction,
minimizer: [
new EsbuildPlugin({
target: 'es2020',
minify: true,
css: true,
legalComments: 'none',
}),
],
splitChunks: { splitChunks: {
chunks: 'async', chunks: 'async',
name: (_, chunks) => chunks.map((item) => item.name).join('-'), name: (_, chunks) => chunks.map((item) => item.name).join('-'),
@@ -113,34 +118,45 @@ export default {
rules: [ rules: [
{ {
test: /\.vue$/i, test: /\.vue$/i,
exclude: /[\\/]node_modules[\\/]/, exclude: /node_modules/,
loader: 'vue-loader', loader: 'vue-loader',
options: { options: {
compilerOptions: { compilerOptions: {
isCustomElement: (tag: string) => webComponents.has(tag), isCustomElement: (tag: string) => webComponents.has(tag),
}, },
experimentalInlineMatchResource: true,
}, },
}, },
{ {
test: /\.(j|t)s$/i, test: /\.js$/i,
exclude: /[\\/]node_modules[\\/]/, exclude: /node_modules/,
loader: 'builtin:swc-loader', use: [
{
loader: 'esbuild-loader',
options: { options: {
jsc: { loader: 'js',
parser: {
syntax: 'typescript',
},
externalHelpers: false,
target: 'es2020', target: 'es2020',
}, },
}, },
],
},
{
test: /\.ts$/i,
exclude: /node_modules/,
use: [
{
loader: 'esbuild-loader',
options: {
loader: 'ts',
target: 'es2020',
},
},
],
}, },
{ {
test: /\.css$/i, test: /\.css$/i,
use: [ use: [
{ {
loader: CssExtractRspackPlugin.loader, loader: MiniCssExtractPlugin.loader,
}, },
{ {
loader: 'css-loader', loader: 'css-loader',
@@ -189,7 +205,7 @@ export default {
TEST: 'false', TEST: 'false',
}), }),
new VueLoaderPlugin(), new VueLoaderPlugin(),
new CssExtractRspackPlugin({ new MiniCssExtractPlugin({
filename: 'css/[name].css', filename: 'css/[name].css',
chunkFilename: 'css/[name].[contenthash:8].css', chunkFilename: 'css/[name].[contenthash:8].css',
}), }),
@@ -241,7 +257,7 @@ export default {
}, },
stats: { stats: {
assetsSort: 'name', assetsSort: 'name',
assetsSpace: Number.MAX_SAFE_INTEGER, assetsSpace: Infinity,
cached: false, cached: false,
cachedModules: false, cachedModules: false,
children: false, children: false,