chore: bump rspack (#14957)

#### PR Dependency Tree


* **PR #14957** 👈

This tree was auto-generated by
[Charcoal](https://github.com/danerwilliams/charcoal)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Chores**
  * Updated minimum Node version requirement to 22.12.0 or later.
* Updated build tool dependencies including rspack and related packages.
  * Removed CI-specific logging behavior from development server.
* Migrated to native HTML plugin integration for improved build
efficiency.
* Simplified build configuration by removing unused experimental
options.

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/toeverything/AFFiNE/pull/14957)

<!-- review_stack_entry_end -->

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
DarkSky
2026-05-14 04:18:49 +08:00
committed by GitHub
parent 4b4def3a11
commit 1201f7c350
6 changed files with 233 additions and 1179 deletions

View File

@@ -15,7 +15,7 @@
"tests/*" "tests/*"
], ],
"engines": { "engines": {
"node": "<23.0.0" "node": ">=22.12.0 <23.0.0"
}, },
"scripts": { "scripts": {
"affine": "r affine.ts", "affine": "r affine.ts",

View File

@@ -18,23 +18,22 @@
"@affine-tools/utils": "workspace:*", "@affine-tools/utils": "workspace:*",
"@affine/s3-compat": "workspace:*", "@affine/s3-compat": "workspace:*",
"@napi-rs/simple-git": "^0.1.22", "@napi-rs/simple-git": "^0.1.22",
"@rspack/core": "^1.7.6", "@rspack/core": "^2.0.3",
"@rspack/dev-server": "^1.1.3", "@rspack/dev-server": "^2.0.1",
"@sentry/webpack-plugin": "^5.1.1", "@sentry/webpack-plugin": "^5.1.1",
"@swc/core": "^1.10.1", "@swc/core": "^1.10.1",
"@tailwindcss/postcss": "^4.0.0", "@tailwindcss/postcss": "^4.0.0",
"@vanilla-extract/webpack-plugin": "^2.3.15", "@vanilla-extract/webpack-plugin": "^2.3.15",
"autoprefixer": "^10.4.20", "autoprefixer": "^10.4.20",
"clipanion": "^3.2.1", "clipanion": "^3.2.1",
"css-loader": "^7.1.2", "css-loader": "^7.1.4",
"cssnano": "^7.0.6", "cssnano": "^7.0.6",
"html-webpack-plugin": "^5.6.6",
"inquirer": "^12.3.0", "inquirer": "^12.3.0",
"jsonc-parser": "^3.3.1", "jsonc-parser": "^3.3.1",
"lodash-es": "^4.17.23", "lodash-es": "^4.17.23",
"mime-types": "^3.0.0", "mime-types": "^3.0.0",
"postcss": "^8.4.49", "postcss": "^8.4.49",
"postcss-loader": "^8.1.1", "postcss-loader": "^8.2.1",
"postcss-selector-parser": "^7.1.0", "postcss-selector-parser": "^7.1.0",
"prettier": "^3.7.4", "prettier": "^3.7.4",
"source-map-loader": "^5.0.0", "source-map-loader": "^5.0.0",

View File

@@ -27,9 +27,6 @@ export function assertRspackSupportedPackageName(name: string) {
); );
} }
const IN_CI = !!process.env.CI;
const httpProxyMiddlewareLogLevel = IN_CI ? 'silent' : 'error';
export const DEFAULT_DEV_SERVER_CONFIG: RspackDevServerConfiguration = { export const DEFAULT_DEV_SERVER_CONFIG: RspackDevServerConfiguration = {
host: '0.0.0.0', host: '0.0.0.0',
allowedHosts: 'all', allowedHosts: 'all',
@@ -61,18 +58,15 @@ export const DEFAULT_DEV_SERVER_CONFIG: RspackDevServerConfiguration = {
{ {
context: '/api', context: '/api',
target: 'http://localhost:3010', target: 'http://localhost:3010',
logLevel: httpProxyMiddlewareLogLevel,
}, },
{ {
context: '/socket.io', context: '/socket.io',
target: 'http://localhost:3010', target: 'http://localhost:3010',
ws: true, ws: true,
logLevel: httpProxyMiddlewareLogLevel,
}, },
{ {
context: '/graphql', context: '/graphql',
target: 'http://localhost:3010', target: 'http://localhost:3010',
logLevel: httpProxyMiddlewareLogLevel,
}, },
], ],
}; };

View File

@@ -3,9 +3,11 @@ import { readFileSync } from 'node:fs';
import { Path, ProjectRoot } from '@affine-tools/utils/path'; import { Path, ProjectRoot } from '@affine-tools/utils/path';
import { Repository } from '@napi-rs/simple-git'; import { Repository } from '@napi-rs/simple-git';
import HTMLPlugin from 'html-webpack-plugin'; import { HtmlRspackPlugin, type HtmlRspackPluginOptions } from '@rspack/core';
import { once } from 'lodash-es'; import { once } from 'lodash-es';
type HtmlRspackPluginInstance = InstanceType<typeof HtmlRspackPlugin>;
type PluginLike = { type PluginLike = {
apply: (compiler: CompilerLike) => void; apply: (compiler: CompilerLike) => void;
}; };
@@ -109,15 +111,15 @@ function getHTMLPluginOptions(BUILD_CONFIG: BUILD_CONFIG_TYPE) {
templateParameters: templateParams, templateParameters: templateParams,
chunks: ['app'], chunks: ['app'],
scriptLoading: 'blocking', scriptLoading: 'blocking',
} satisfies HTMLPlugin.Options; } satisfies HtmlRspackPluginOptions;
} }
const AssetsManifestPlugin = { const AssetsManifestPlugin = {
apply(compiler: CompilerLike) { apply(compiler: CompilerLike) {
compiler.hooks.compilation.tap('assets-manifest-plugin', compilation => { compiler.hooks.compilation.tap('assets-manifest-plugin', compilation => {
HTMLPlugin.getHooks(compilation).beforeAssetTagGeneration.tap( HtmlRspackPlugin.getCompilationHooks(
'assets-manifest-plugin', compilation
arg => { ).beforeAssetTagGeneration.tap('assets-manifest-plugin', arg => {
if (!compilation.getAsset('assets-manifest.json')) { if (!compilation.getAsset('assets-manifest.json')) {
compilation.emitAsset( compilation.emitAsset(
`assets-manifest.json`, `assets-manifest.json`,
@@ -146,8 +148,7 @@ const AssetsManifestPlugin = {
} }
return arg; return arg;
} });
);
}); });
}, },
}; };
@@ -162,9 +163,9 @@ const GlobalErrorHandlerPlugin = {
compiler.hooks.compilation.tap( compiler.hooks.compilation.tap(
'global-error-handler-plugin', 'global-error-handler-plugin',
compilation => { compilation => {
HTMLPlugin.getHooks(compilation).beforeAssetTagGeneration.tap( HtmlRspackPlugin.getCompilationHooks(
'global-error-handler-plugin', compilation
arg => { ).beforeAssetTagGeneration.tap('global-error-handler-plugin', arg => {
if (!compilation.getAsset(globalErrorHandler[0])) { if (!compilation.getAsset(globalErrorHandler[0])) {
compilation.emitAsset( compilation.emitAsset(
globalErrorHandler[0], globalErrorHandler[0],
@@ -176,8 +177,7 @@ const GlobalErrorHandlerPlugin = {
} }
return arg; return arg;
} });
);
} }
); );
}, },
@@ -186,7 +186,7 @@ const GlobalErrorHandlerPlugin = {
const CorsPlugin = { const CorsPlugin = {
apply(compiler: CompilerLike) { apply(compiler: CompilerLike) {
compiler.hooks.compilation.tap('html-js-cors-plugin', compilation => { compiler.hooks.compilation.tap('html-js-cors-plugin', compilation => {
HTMLPlugin.getHooks(compilation).alterAssetTags.tap( HtmlRspackPlugin.getCompilationHooks(compilation).alterAssetTags.tap(
'html-js-cors-plugin', 'html-js-cors-plugin',
options => { options => {
if (options.publicPath !== '/') { if (options.publicPath !== '/') {
@@ -207,14 +207,14 @@ const CorsPlugin = {
export function createHTMLPlugins( export function createHTMLPlugins(
BUILD_CONFIG: BUILD_CONFIG_TYPE, BUILD_CONFIG: BUILD_CONFIG_TYPE,
config: CreateHTMLPluginConfig config: CreateHTMLPluginConfig
): (HTMLPlugin | PluginLike)[] { ): (HtmlRspackPluginInstance | PluginLike)[] {
const publicPath = getPublicPath(BUILD_CONFIG); const publicPath = getPublicPath(BUILD_CONFIG);
const htmlPluginOptions = getHTMLPluginOptions(BUILD_CONFIG); const htmlPluginOptions = getHTMLPluginOptions(BUILD_CONFIG);
const selfhostPublicPath = config.selfhostPublicPath ?? '/'; const selfhostPublicPath = config.selfhostPublicPath ?? '/';
const plugins: (HTMLPlugin | PluginLike)[] = []; const plugins: (HtmlRspackPluginInstance | PluginLike)[] = [];
plugins.push( plugins.push(
new HTMLPlugin({ new HtmlRspackPlugin({
...htmlPluginOptions, ...htmlPluginOptions,
chunks: ['index'], chunks: ['index'],
filename: config.filename, filename: config.filename,
@@ -227,7 +227,7 @@ export function createHTMLPlugins(
if (BUILD_CONFIG.isElectron) { if (BUILD_CONFIG.isElectron) {
plugins.push( plugins.push(
new HTMLPlugin({ new HtmlRspackPlugin({
...htmlPluginOptions, ...htmlPluginOptions,
chunks: ['shell'], chunks: ['shell'],
filename: 'shell.html', filename: 'shell.html',
@@ -236,7 +236,7 @@ export function createHTMLPlugins(
'env:publicPath': publicPath, 'env:publicPath': publicPath,
}, },
}), }),
new HTMLPlugin({ new HtmlRspackPlugin({
...htmlPluginOptions, ...htmlPluginOptions,
filename: 'popup.html', filename: 'popup.html',
chunks: ['popup'], chunks: ['popup'],
@@ -245,7 +245,7 @@ export function createHTMLPlugins(
'env:publicPath': publicPath, 'env:publicPath': publicPath,
}, },
}), }),
new HTMLPlugin({ new HtmlRspackPlugin({
...htmlPluginOptions, ...htmlPluginOptions,
filename: 'background-worker.html', filename: 'background-worker.html',
chunks: ['backgroundWorker'], chunks: ['backgroundWorker'],
@@ -271,7 +271,7 @@ export function createHTMLPlugins(
if (config.additionalEntryForSelfhost) { if (config.additionalEntryForSelfhost) {
plugins.push( plugins.push(
new HTMLPlugin({ new HtmlRspackPlugin({
...htmlPluginOptions, ...htmlPluginOptions,
chunks: ['index'], chunks: ['index'],
publicPath: selfhostPublicPath, publicPath: selfhostPublicPath,

View File

@@ -124,8 +124,6 @@ export function createHTMLTargetConfig(
dependencies: deps, dependencies: deps,
context: ProjectRoot.value, context: ProjectRoot.value,
experiments: { experiments: {
topLevelAwait: true,
outputModule: false,
asyncWebAssembly: true, asyncWebAssembly: true,
}, },
entry, entry,
@@ -364,7 +362,6 @@ export function createHTMLTargetConfig(
providedExports: true, providedExports: true,
usedExports: true, usedExports: true,
sideEffects: true, sideEffects: true,
removeAvailableModules: true,
runtimeChunk: { name: 'runtime' }, runtimeChunk: { name: 'runtime' },
splitChunks: { splitChunks: {
chunks: 'all', chunks: 'all',
@@ -426,8 +423,6 @@ export function createWorkerTargetConfig(
name: entry, name: entry,
context: ProjectRoot.value, context: ProjectRoot.value,
experiments: { experiments: {
topLevelAwait: true,
outputModule: false,
asyncWebAssembly: true, asyncWebAssembly: true,
}, },
entry: { [workerName]: entry }, entry: { [workerName]: entry },
@@ -530,7 +525,6 @@ export function createWorkerTargetConfig(
providedExports: true, providedExports: true,
usedExports: true, usedExports: true,
sideEffects: true, sideEffects: true,
removeAvailableModules: true,
runtimeChunk: false, runtimeChunk: false,
splitChunks: false, splitChunks: false,
}, },
@@ -556,8 +550,6 @@ export function createNodeTargetConfig(
name: entry, name: entry,
context: ProjectRoot.value, context: ProjectRoot.value,
experiments: { experiments: {
topLevelAwait: true,
outputModule: pkg.packageJson.type === 'module',
asyncWebAssembly: true, asyncWebAssembly: true,
}, },
entry: { index: entry }, entry: { index: entry },
@@ -566,6 +558,7 @@ export function createNodeTargetConfig(
path: pkg.distPath.value, path: pkg.distPath.value,
clean: true, clean: true,
globalObject: 'globalThis', globalObject: 'globalThis',
module: pkg.packageJson.type === 'module',
...(options.libraryType ...(options.libraryType
? { library: { type: options.libraryType } } ? { library: { type: options.libraryType } }
: {}), : {}),

1272
yarn.lock

File diff suppressed because it is too large Load Diff