diff --git a/package.json b/package.json
index 30129e31f2af..6a3a9660c483 100644
--- a/package.json
+++ b/package.json
@@ -92,13 +92,7 @@
"pnpm": {
"overrides": {
"@types/react": "^18",
- "@types/react-dom": "^18",
- "@modern-js/builder-rspack-provider>@rspack/core": "0.4.5",
- "@modern-js/builder-rspack-provider>@rspack/plugin-react-refresh": "0.4.5",
- "@modern-js/builder-rspack-provider>@rspack/plugin-html": "0.4.5",
- "@modern-js/storybook-builder>@rspack/plugin-react-refresh": "0.4.5",
- "@rspack/core@0.4.5>@rspack/binding": "0.4.5",
- "@rspack/binding@0.4.5>@rspack/binding-linux-x64-gnu": "0.4.5"
+ "@types/react-dom": "^18"
},
"peerDependencyRules": {
"allowedVersions": {
diff --git a/packages/builder/builder-rspack-provider/.eslintrc.js b/packages/builder/builder-rspack-provider/.eslintrc.js
deleted file mode 100644
index 2a850eabf8a8..000000000000
--- a/packages/builder/builder-rspack-provider/.eslintrc.js
+++ /dev/null
@@ -1,69 +0,0 @@
-const devDependencyPaths = Object.keys(
- require('./package.json').devDependencies,
-);
-
-const withAllowTypeImports = key => pkg => ({
- [key]: pkg,
- allowTypeImports: true,
-});
-
-/**
- * @refer https://eslint.org/docs/latest/rules/no-restricted-imports
- * @refer https://typescript-eslint.io/rules/no-restricted-imports
- */
-const restrictedImportInSource = {
- paths: [
- 'lodash',
- 'ts-loader',
- 'typescript',
- '@modern-js/utils',
- ...devDependencyPaths,
- ].map(withAllowTypeImports('name')),
- patterns: [
- 'src/**/*',
- '**/plugins/*',
- [
- '@modern-js/utils/*',
- '!@modern-js/utils/chalk',
- '!@modern-js/utils/lodash',
- '!@modern-js/utils/chain-id',
- ],
- ].map(withAllowTypeImports('group')),
-};
-
-const restrictedImportInTypes = {
- patterns: [{ group: '**', allowTypeImports: true }],
-};
-
-/** @type {import('eslint').Linter.Config} */
-module.exports = {
- extends: ['@modern-js'],
- ignorePatterns: ['compiled/', 'vitest.config.ts'],
- parserOptions: {
- project: require.resolve('./tsconfig.json'),
- },
- rules: {
- 'import/order': 0,
- },
- overrides: [
- {
- files: ['./src/types/**/*.ts'],
- rules: {
- '@typescript-eslint/no-restricted-imports': [
- 'error',
- restrictedImportInTypes,
- ],
- },
- },
- {
- files: ['./src/**/*.{ts,js}'],
- excludedFiles: ['**/*.test.*', './src/types/**/*'],
- rules: {
- '@typescript-eslint/no-restricted-imports': [
- 'error',
- restrictedImportInSource,
- ],
- },
- },
- ],
-};
diff --git a/packages/builder/builder-rspack-provider/.npmignore b/packages/builder/builder-rspack-provider/.npmignore
deleted file mode 100644
index f059fcfe5bc3..000000000000
--- a/packages/builder/builder-rspack-provider/.npmignore
+++ /dev/null
@@ -1,30 +0,0 @@
-.DS_Store
-
-.pnp
-.pnp.js
-.env.local
-.env.*.local
-*.log*
-
-node_modules/
-*.tsbuildinfo
-.eslintcache
-
-coverage/
-tests/
-
-.vscode/**/*
-!.vscode/settings.json
-!.vscode/extensions.json
-.idea/
-
-src/
-
-modern.config.*
-jest.config.js
-.eslintrc.js
-.eslintrc
-tsconfig.json
-CHANGELOG.md
-
-scripts/
diff --git a/packages/builder/builder-rspack-provider/CHANGELOG.md b/packages/builder/builder-rspack-provider/CHANGELOG.md
deleted file mode 100644
index c5dd5bdc060e..000000000000
--- a/packages/builder/builder-rspack-provider/CHANGELOG.md
+++ /dev/null
@@ -1,1645 +0,0 @@
-# @modern-js/builder-rspack-provider
-
-## 2.46.1
-
-### Patch Changes
-
-- @modern-js/builder-shared@2.46.1
-- @modern-js/server@2.46.1
-- @modern-js/types@2.46.1
-- @modern-js/utils@2.46.1
-
-## 2.46.0
-
-### Patch Changes
-
-- Updated dependencies [494b290]
- - @modern-js/types@2.46.0
- - @modern-js/builder-shared@2.46.0
- - @modern-js/server@2.46.0
- - @modern-js/utils@2.46.0
-
-## 2.45.0
-
-### Patch Changes
-
-- Updated dependencies [19c8687]
- - @modern-js/types@2.45.0
- - @modern-js/builder-shared@2.45.0
- - @modern-js/server@2.45.0
- - @modern-js/utils@2.45.0
-
-## 2.44.0
-
-### Patch Changes
-
-- b32f60a: chore(deps): bump rspack to 0.4.5 and bump rsbuild to 0.2.11
-
- chore(deps): 升级 rspack 到 0.4.5 & 升级 rsbuild 到 0.2.11
-
-- Updated dependencies [0ed968c]
-- Updated dependencies [2b41e70]
-- Updated dependencies [56d7f9a]
-- Updated dependencies [35a9961]
- - @modern-js/types@2.44.0
- - @modern-js/server@2.44.0
- - @modern-js/builder-shared@2.44.0
- - @modern-js/utils@2.44.0
-
-## 2.43.0
-
-### Patch Changes
-
-- 40678b1: fix: rspack 0.4.4 plugin & rule type error
-
- fix: 修复 rspack 0.4.4 plugin 和 rule 的类型问题
-
-- 2d2cf71: chore: bump rspack to 0.4.4
-
- chore: 升级 rspack 到 0.4.4
-
-- Updated dependencies [9e749d8]
-- Updated dependencies [d959200]
-- Updated dependencies [acd3861]
-- Updated dependencies [5782aa3]
- - @modern-js/server@2.43.0
- - @modern-js/types@2.43.0
- - @modern-js/builder-shared@2.43.0
- - @modern-js/utils@2.43.0
-
-## 2.42.2
-
-### Patch Changes
-
-- bb48362: chore: bump rspack to 0.4.3
-
- chore: rspack 版本升级到 0.4.3
-
-- Updated dependencies [2dfc891]
- - @modern-js/types@2.42.2
- - @modern-js/builder-shared@2.42.2
- - @modern-js/server@2.42.2
- - @modern-js/utils@2.42.2
-
-## 2.42.1
-
-### Patch Changes
-
-- @modern-js/builder-shared@2.42.1
-- @modern-js/server@2.42.1
-- @modern-js/types@2.42.1
-- @modern-js/utils@2.42.1
-
-## 2.42.0
-
-### Patch Changes
-
-- d433c97: fix(rspack-provider): react refresh not work in Micro front-end projects
-
- fix(rspack-provider): 修复 react refresh 在微前端场景下不生效的问题
-
-- fc1f36f: fix(builder): should generate manifest correctly when enable SSR
-- ef60f58: fix(builder): export type of rspack config and add globalObject type for rspack output
- fix(builder): 导出一些 rspack config 类型同时给 rspack output 添加 globalObject 类型
-- ba443b8: chore: bump rspack version to 0.4.2
- chore: 升级 rspack 版本到 0.4.2
-- 898f325: chore: replace @rspack/dev-client with @rspack/plugin-react-refresh
-
- chore: 将 @rspack/dev-client 替换为 @rspack/plugin-react-refresh
-
-- f4eadb5: chore: bump rspack and update snapshot
-- Updated dependencies [d433c97]
-- Updated dependencies [04d9522]
-- Updated dependencies [ef60f58]
- - @modern-js/builder-shared@2.42.0
- - @modern-js/server@2.42.0
- - @modern-js/types@2.42.0
- - @modern-js/utils@2.42.0
-
-## 2.41.0
-
-### Patch Changes
-
-- dc80bbc: hotfix(rspack-provider): can't get rspack util in tools.rspack
-- 4dffb01: chore(rspack-provider): set disableTransformByDefault false to compat rspack next version(0.4.0)
-
- chore(rspack-provider): 设置 disableTransformByDefault 为 false 以兼容 Rspack next(0.4.0) 版本
-
-- 88d5c57: chore(rspack-provider): return compiler instead of multiCompiler when targets length is 1
-
- chore(rspack-provider): 返回 compiler 而非 multiCompiler 当 targets 长度为 1 时
-
-- c4d396a: chore(swc): bump swc and helpers
- chore(swc): 升级 swc 以及 helpers
-- 7459705: chore(rspack-provider): update rspack to 0.4.0
-
- chore(rspack-provider): 升级 rspack 到 0.4.0
-
-- Updated dependencies [969def1]
-- Updated dependencies [c4d396a]
- - @modern-js/builder-shared@2.41.0
- - @modern-js/server@2.41.0
- - @modern-js/utils@2.41.0
- - @modern-js/types@2.41.0
-
-## 2.40.0
-
-### Patch Changes
-
-- f5f7526: chore(builder): update rspack to 0.3.11 and fix deprecate warning
-
- chore(builder): 升级 rspack 到 0.3.11 并修复 deprecate warning
-
-- Updated dependencies [95f15d2]
- - @modern-js/utils@2.40.0
- - @modern-js/builder-shared@2.40.0
- - @modern-js/server@2.40.0
- - @modern-js/types@2.40.0
-
-## 2.39.2
-
-### Patch Changes
-
-- @modern-js/builder-shared@2.39.2
-- @modern-js/server@2.39.2
-- @modern-js/types@2.39.2
-- @modern-js/utils@2.39.2
-
-## 2.39.1
-
-### Patch Changes
-
-- @modern-js/server@2.39.1
-- @modern-js/builder-shared@2.39.1
-- @modern-js/types@2.39.1
-- @modern-js/utils@2.39.1
-
-## 2.39.0
-
-### Patch Changes
-
-- @modern-js/builder-shared@2.39.0
-- @modern-js/server@2.39.0
-- @modern-js/types@2.39.0
-- @modern-js/utils@2.39.0
-
-## 2.38.0
-
-### Patch Changes
-
-- 3304d33: chore(deps): bump @babel/core to v7.23.2
-
- chore(deps): 升级 @babel/core 至 v7.23.2
-
-- 64da831: fix(builder): should not print stats object
-
- fix(builder): 修复报错时输出完整 stats 对象的问题
-
-- 09fc285: chore(builder): update rspack to 0.3.8
-
- chore(builder): 升级 rspack 到 0.3.8
-
-- Updated dependencies [3304d33]
- - @modern-js/builder-shared@2.38.0
- - @modern-js/server@2.38.0
- - @modern-js/types@2.38.0
- - @modern-js/utils@2.38.0
-
-## 2.37.2
-
-### Patch Changes
-
-- @modern-js/builder-shared@2.37.2
-- @modern-js/server@2.37.2
-- @modern-js/types@2.37.2
-- @modern-js/utils@2.37.2
-
-## 2.37.1
-
-### Patch Changes
-
-- @modern-js/builder-shared@2.37.1
-- @modern-js/server@2.37.1
-- @modern-js/types@2.37.1
-- @modern-js/utils@2.37.1
-
-## 2.37.0
-
-### Patch Changes
-
-- 383b636: chore: replace babel-preset-base with rsbuild babel-preset
-
- chore: 替换 babel-preset-base 为 rsbuild babel-preset
-
-- Updated dependencies [383b636]
-- Updated dependencies [ce0a14e]
-- Updated dependencies [708f248]
- - @modern-js/server@2.37.0
- - @modern-js/utils@2.37.0
- - @modern-js/builder-shared@2.37.0
- - @modern-js/types@2.37.0
-
-## 2.36.0
-
-### Patch Changes
-
-- 3921cd4: chore(builder): update rspack to 0.3.5
-
- chore(builder): 升级 rspack 到 0.3.5
-
-- bc25bcb: chore(builder): use rspack.xxxPlugin instead of builtins configuration
-
- chore(builder): 使用 rspack.xxxPlugin 代替 builtins configuration
-
-- 73dcace: chore(builder): support the use of the RSPACK_PROFILE environment variable for Rspack build performance profile
-
- chore(builder):支持使用 RSPACK_PROFILE 环境变量来进行 Rspack 构建性能分析
-
-- 2675812: feat(builder): improve time logs format
-
- feat(builder): 优化时间日志的格式
-
-- 9d37401: fix(builder): mismatched directory name containing node_modules
-
- fix(builder): 错误匹配了包含 node_modules 的目录
-
-- 4289ffd: chore(builder): update rspack to 0.3.6
-
- chore(builder): 升级 rspack 到 0.3.6
-
-- eb602d2: chore(builder): bump webpack-dev-middleware v6.1.1 and move to builder-shared
-
- chore(builder): 升级 webpack-dev-middleware v6.1.1 并移动到 builder-shared
-
-- 5b4bf21: feat(builder): include tslib in lib-polyfill.js
-
- feat(builder): 拆分 tslib 到 lib-polyfill.js 中
-
-- Updated dependencies [3473bee]
-- Updated dependencies [b98f8aa]
-- Updated dependencies [3dcad90]
-- Updated dependencies [bc25bcb]
-- Updated dependencies [c1b0d18]
-- Updated dependencies [2675812]
-- Updated dependencies [9d37401]
-- Updated dependencies [eb602d2]
- - @modern-js/utils@2.36.0
- - @modern-js/server@2.36.0
- - @modern-js/builder-shared@2.36.0
- - @modern-js/types@2.36.0
-
-## 2.35.1
-
-### Patch Changes
-
-- ea3fe18: feat(app-tools): make logs easier to read
-
- feat(app-tools): 让日志更容易阅读
-
-- bc1413d: fix(builder): resolve-url-loader performance regression issue
-
- fix(builder): 修复 resolve-url-loader 导致的性能下降问题
-
-- 0988b12: chore(builder): move duplicated prebundle packages to shared
-
- chore(builder): 合并重复的预打包 packages 到 shared
-
-- dc93952: fix(builder): should not apply babel in rspack mode when tools.babel not modify config
-
- fix(builder): 在使用 rspack 构建时,如果 tools.babel 未实际修改配置时,则不使用 babel
-
-- 6b03be8: chore(builder): apply chunkIds deterministic in Rspack mode production
-
- chore(builder): 在 Rspack 模式下,生产环境开启 chunkIds 'deterministic'
-
-- 578f94f: chore(rspack): use DataURI module instead of rspack-plugin-virtual-module
-
- chore(rspack): 使用 DataURI module 替代 rspack-plugin-virtual-module
-
-- fe8caeb: feat(builder): unify progress bar style in webpack / Rspack mode
-
- feat(builder): 对齐 webpack / Rspack 模式下的进度条样式
-
-- Updated dependencies [ce24aad]
-- Updated dependencies [ea3fe18]
-- Updated dependencies [de9cdee]
-- Updated dependencies [9dd3151]
-- Updated dependencies [0988b12]
-- Updated dependencies [4980480]
-- Updated dependencies [6a1d46e]
-- Updated dependencies [fe8caeb]
- - @modern-js/builder-shared@2.35.1
- - @modern-js/utils@2.35.1
- - @modern-js/server@2.35.1
- - @modern-js/types@2.35.1
-
-## 2.35.0
-
-### Patch Changes
-
-- 3b25410: fix(builder): support enableLatestDecorators in rspack mode
-
- fix(builder): 修复在使用 rspack 构建时 enableLatestDecorators 报错问题
-
-- e2def6e: feat(builder): update rspack to 0.3.4 and support output.charset ascii
-
- feat(builder): 更新 rspack 到 0.3.4,并支持 output.charset ascii 配置
-
-- 28128ca: refactor(builder): migrate to tsconfig-paths-webpack-plugin
-
- refactor(builder): 迁移至 tsconfig-paths-webpack-plugin
-
-- 4027a6a: feat(builder): apply css-minimizer-webpack-plugin when use rspack
-
- feat(builder): 在 Rspack 构建时,使用 css-minimizer-webpack-plugin 进行 css 压缩
-
-- Updated dependencies [225f065]
-- Updated dependencies [0300daf]
-- Updated dependencies [f509548]
-- Updated dependencies [15b834f]
-- Updated dependencies [28128ca]
-- Updated dependencies [4027a6a]
-- Updated dependencies [3d93e81]
- - @modern-js/builder-shared@2.35.0
- - @modern-js/utils@2.35.0
- - @modern-js/server@2.35.0
- - @modern-js/types@2.35.0
-
-## 2.34.0
-
-### Patch Changes
-
-- Updated dependencies [a77b82a]
-- Updated dependencies [09b176a]
-- Updated dependencies [c8b448b]
-- Updated dependencies [c9626e7]
-- Updated dependencies [e538169]
- - @modern-js/utils@2.34.0
- - @modern-js/builder-shared@2.34.0
- - @modern-js/server@2.34.0
- - @modern-js/types@2.34.0
-
-## 2.33.1
-
-### Patch Changes
-
-- @modern-js/builder-shared@2.33.1
-- @modern-js/server@2.33.1
-- @modern-js/types@2.33.1
-- @modern-js/utils@2.33.1
-
-## 2.33.0
-
-### Patch Changes
-
-- 1c812c2: chore(builder): update rspack to 0.3.1 & overrides rspress's modern.js deps in workspace
-
- chore(builder): 升级 rspack 到 0.3.1,并将 rspress 内 modern.js 的依赖指向当前 workspace
-
-- 64df945: feat(builder): support enableCssModuleTSDeclaration and cssModules.exportLocalsConvention when use rspack mode
-
- feat(builder): 在使用 Rspack 构建时,支持 enableCssModuleTSDeclaration 和 cssModules.exportLocalsConvention 配置项
-
-- Updated dependencies [c9ffc4d]
-- Updated dependencies [915636b]
-- Updated dependencies [fd82137]
-- Updated dependencies [d55caa9]
-- Updated dependencies [bc1f8da]
-- Updated dependencies [64df945]
- - @modern-js/builder-shared@2.33.0
- - @modern-js/utils@2.33.0
- - @modern-js/server@2.33.0
- - @modern-js/types@2.33.0
-
-## 2.32.1
-
-### Patch Changes
-
-- Updated dependencies [90e053a]
- - @modern-js/types@2.32.1
- - @modern-js/builder-shared@2.32.1
- - @modern-js/server@2.32.1
- - @modern-js/utils@2.32.1
-
-## 2.32.0
-
-### Patch Changes
-
-- 6076166: fix: packaging errors found by publint
-
- fix: 修复 publint 检测到的 packaging 问题
-
-- 83c1cf7: chore(builder): When building with Rspack, check whether the current Rspack version meets the minimum version requirements
-
- chore(builder): 使用 Rspack 构建时,检查当前 Rspack 版本是否满足最低版本要求
-
-- Updated dependencies [e5a3fb4]
-- Updated dependencies [6076166]
-- Updated dependencies [5f7c714]
-- Updated dependencies [6517032]
-- Updated dependencies [a030aff]
-- Updated dependencies [0cc3981]
-- Updated dependencies [ddcdef2]
-- Updated dependencies [4323e68]
-- Updated dependencies [3c91100]
-- Updated dependencies [2447d64]
-- Updated dependencies [5255eba]
- - @modern-js/utils@2.32.0
- - @modern-js/types@2.32.0
- - @modern-js/server@2.32.0
- - @modern-js/builder-shared@2.32.0
-
-## 2.31.2
-
-### Patch Changes
-
-- Updated dependencies [15d30abdc66]
- - @modern-js/utils@2.31.2
- - @modern-js/builder-shared@2.31.2
- - @modern-js/server@2.31.2
- - @modern-js/types@2.31.2
-
-## 2.31.1
-
-### Patch Changes
-
-- fe70fdf: hotfix(builder): temporarily disable asciiOnly in rspack
-
- hotfix(builder): rspack 场景下临时关闭 asciiOnly 能力
-
- - @modern-js/builder-shared@2.31.1
- - @modern-js/server@2.31.1
- - @modern-js/types@2.31.1
- - @modern-js/utils@2.31.1
-
-## 2.31.0
-
-### Patch Changes
-
-- 0f09d7c: chore(builder): update rspack to 0.2.12
-
- chore(builder): 升级 rspack 到 0.2.12
-
-- bfdf7b4: fix(builder): omit unused keys from builder config passed by user
-
- fix(builder): 移除用户传入的 builder config 中多余的 key
-
-- 8ab3e2a: hotfix(builder): fix sass resolve-url-loader can't deal with alias
-
- hotfix(builder): 修复 sass resolve-url-loader 错误处理 alias 的问题
-
-- 1eece3e: feat(builder): support performance.profile when use rspack-provider
-
- feat(builder): 在使用 rspack-provider 时支持 performance.profile 配置项
-
-- fa8e948: feat(builder): support disable rspack css sourcemap
-
- feat(builder): 支持禁用 rspack css sourcemap 输出
-
-- 83bf560: feat(builder): support output.legalComments.inline and output.charset 'ascii' in rspack-provider
-
- feat(builder): 在使用 rspack-provider 时支持 output.legalComments.inline 和 output.charset 'ascii' 配置项
-
-- 1882366: chore(deps): bump build dependencies
-
- chore(deps): 升级构建相关依赖
-
-- Updated dependencies [bfdf7b4]
-- Updated dependencies [8ab3e2a]
-- Updated dependencies [fa8e948]
-- Updated dependencies [1882366]
- - @modern-js/builder-shared@2.31.0
- - @modern-js/utils@2.31.0
- - @modern-js/server@2.31.0
- - @modern-js/types@2.31.0
-
-## 2.30.0
-
-### Patch Changes
-
-- 0ea763e: chore(builder): update rspack to 0.2.11
-
- chore(builder): 升级 rspack 到 0.2.11
-
-- e6ae836: feat(builder): support performance preload & prefetch configurations
-
- feat(builder): 支持 performance preload 和 prefetch 配置项
-
-- Updated dependencies [a5ee81a]
-- Updated dependencies [883692c]
-- Updated dependencies [cc5f49e]
-- Updated dependencies [f74064c]
-- Updated dependencies [b6ab299]
-- Updated dependencies [e6ae836]
-- Updated dependencies [7cb7b24]
-- Updated dependencies [e94ad94]
- - @modern-js/types@2.30.0
- - @modern-js/server@2.30.0
- - @modern-js/builder-shared@2.30.0
- - @modern-js/utils@2.30.0
-
-## 2.29.0
-
-### Patch Changes
-
-- 1d420ae: feat(builder): support resolve relative asset in SASS files
-
- feat(builder): 支持处理 SASS 文件的相对资源
-
-- 3e0e1b2: chore(builder): update rspack to 0.2.10
-
- chore(builder): 升级 rspack 到 0.2.10
-
-- 99052ea: feat(builder): improve error stacks if dev compilation failed
-
- feat(builder): 优化 dev 编译失败时的错误堆栈格式
-
-- 2ad31da: feat(builder): support performance preconnect/dnsPrefetch configurations
-
- feat(builder): 支持 performance preconnect/dnsPrefetch 配置项
-
-- Updated dependencies [e6b5355]
-- Updated dependencies [93db783]
-- Updated dependencies [bd4c354]
-- Updated dependencies [cba7675]
-- Updated dependencies [99052ea]
-- Updated dependencies [d198779]
-- Updated dependencies [1d71d2e]
- - @modern-js/utils@2.29.0
- - @modern-js/builder-shared@2.29.0
- - @modern-js/server@2.29.0
- - @modern-js/types@2.29.0
-
-## 2.28.0
-
-### Patch Changes
-
-- 213089e: chore(builder): update rspack to 0.2.9
-
- chore(builder): 升级 rspack 到 0.2.9
-
-- 362416f: feat(builder): support import Node.js addons when target is node
-
- feat(builder): 支持在 target 为 node 时引用 Node.js addons
-
-- 9301e46: chore(builder): optimize some error format of zod validation and add joint verification of rspack css related configuration
-
- chore(builder): 优化 builder schema 校验的部分错误输出格式,并为 rspack 添加 css 相关配置的联合校验
-
-- Updated dependencies [4e3ce96]
-- Updated dependencies [6400d98]
-- Updated dependencies [6eae1e7]
-- Updated dependencies [362416f]
-- Updated dependencies [aa0c0c3]
-- Updated dependencies [9301e46]
-- Updated dependencies [00b58a7]
-- Updated dependencies [820bfe9]
- - @modern-js/types@2.28.0
- - @modern-js/builder-shared@2.28.0
- - @modern-js/server@2.28.0
- - @modern-js/utils@2.28.0
-
-## 2.27.0
-
-### Minor Changes
-
-- 3f79dd7: feat(builder): add `source.aliasStrategy` option
-
- feat(builder): 新增 `source.aliasStrategy` 选项
-
-### Patch Changes
-
-- 645e111: fix(builder): CSS Modules name has a probability of conflict in prod
-
- fix(builder): 修复 CSS Modules name 在生产环境有极小概率冲突的问题
-
-- 8322a51: chore: migrate packages from tsc to module-lib build
-
- chore: 将使用 tsc 的包迁移到 module-lib 构建
-
-- 5376a22: chore(builder): update rspack to 0.2.8 and compatible [dev-client change](https://github.com/web-infra-dev/rspack/pull/3731/files)
-
- chore(builder): 升级 rspack 到 0.2.8 并兼容 [dev-client 变更](https://github.com/web-infra-dev/rspack/pull/3731/files)
-
-- 67d0b0c: fix(builder): failed to disable html via htmlPlugin: false
-
- fix(builder): 修复通过 htmlPlugin: false 无法禁用 html 的问题
-
-- Updated dependencies [645e111]
-- Updated dependencies [91d14b8]
-- Updated dependencies [8322a51]
-- Updated dependencies [d9080ed]
-- Updated dependencies [67d0b0c]
-- Updated dependencies [3f79dd7]
-- Updated dependencies [6d7104d]
- - @modern-js/builder-shared@2.27.0
- - @modern-js/utils@2.27.0
- - @modern-js/server@2.27.0
- - @modern-js/types@2.27.0
-
-## 2.26.0
-
-### Patch Changes
-
-- 150ddb1: fix(builder-shared): set formatStats fn as sync-fn so that info can print quikly
- fix(builder-shared): 将 formatStats 设置成同步函数使构建信息能够尽快的打印出来
-- fac4ee0: fix(builder): enable preferRelative for CSS files by default
-
- fix(builder): 默认开启 CSS files 的 preferRelative 配置
-
-- cdf5b6b: chore(builder): override rspack.devServer type declare and update doc
-
- chore(builder): 覆盖 rspack.devServer 类型定义并更新文档
-
-- Updated dependencies [150ddb1]
-- Updated dependencies [15ad760]
-- Updated dependencies [786c195]
- - @modern-js/builder-shared@2.26.0
- - @modern-js/server@2.26.0
- - @modern-js/types@2.26.0
- - @modern-js/utils@2.26.0
-
-## 2.25.2
-
-### Patch Changes
-
-- f54bb68: chore(rspack-provider): update rspack to 0.2.5
-
- chore(rspack-provider): 升级 rspack 相关依赖到 0.2.5
-
-- 15a8276: fix(builder): failed to set publicPath function
-
- fix(builder): 修复设置 publicPath 函数时报错的问题
-
-- 272646c: feat(builder): bump webpack v5.88, support top level await
-
- feat(builder): 升级 webpack v5.88, 支持 top level await
-
-- Updated dependencies [63d8247]
-- Updated dependencies [6651684]
-- Updated dependencies [15a8276]
-- Updated dependencies [272646c]
-- Updated dependencies [358ed24]
- - @modern-js/utils@2.25.2
- - @modern-js/builder-shared@2.25.2
- - @modern-js/server@2.25.2
- - @modern-js/types@2.25.2
-
-## 2.25.1
-
-### Patch Changes
-
-- Updated dependencies [b10045f]
-- Updated dependencies [9f78d0c]
- - @modern-js/builder-shared@2.25.1
- - @modern-js/utils@2.25.1
- - @modern-js/server@2.25.1
- - @modern-js/types@2.25.1
-
-## 2.25.0
-
-### Patch Changes
-
-- bafd4aa: chore(rspack-provider): update rspack to 0.2.4
-
- chore(rspack-provider): 升级 rspack 相关依赖到 0.2.4
-
-- Updated dependencies [2491875]
-- Updated dependencies [5732c6a]
- - @modern-js/types@2.25.0
- - @modern-js/utils@2.25.0
- - @modern-js/builder-shared@2.25.0
- - @modern-js/server@2.25.0
-
-## 2.24.0
-
-### Patch Changes
-
-- ef041c0: chore(builder): reuse externals plugin
-
- chore(builder): 复用 externals 插件
-
-- 4fdd868: feat(rspack-provider): update rspack to v0.2.3
-
- feat(rspack-provider): 升级 rspack 到 v0.2.3
-
-- Updated dependencies [c882fbd]
-- Updated dependencies [8c9923f]
-- Updated dependencies [ef041c0]
-- Updated dependencies [0424a2d]
-- Updated dependencies [4a82c3b]
- - @modern-js/types@2.24.0
- - @modern-js/utils@2.24.0
- - @modern-js/server@2.24.0
- - @modern-js/builder-shared@2.24.0
-
-## 2.23.1
-
-### Patch Changes
-
-- 20c85bb: feat(rspack-provider): support performance.removeMomentLocale in rspack
-
- feat(rspack-provider): 在使用 rspack 构建时支持 performance.removeMomentLocale 配置项
-
-- 5772927: feat(rspack-provider): support import .wasm assets
-
- feat(rspack-provider): 支持引用 .wasm 资源
-
-- 4af25d9: fix(builder): remove @modern-js/e2e from peerDependencies
-
- fix(builder): 移除 @modern-js/e2e peerDependencies
-
-- 4d4dca0: feat(builder): add new plugin.remove option
-
- feat(builder): 新增 plugin.remove 选项
-
-- Updated dependencies [f08bbfc]
-- Updated dependencies [a6b313a]
-- Updated dependencies [5772927]
-- Updated dependencies [811ccd4]
-- Updated dependencies [5a3eeff]
-- Updated dependencies [4d4dca0]
-- Updated dependencies [8f2cab0]
- - @modern-js/utils@2.23.1
- - @modern-js/builder-shared@2.23.1
- - @modern-js/server@2.23.1
- - @modern-js/types@2.23.1
-
-## 2.23.0
-
-### Patch Changes
-
-- 15eac36: chore(builder): move more default config to shared package
-
- chore(builder): 移动更多默认 config 到 shared 包
-
-- a912b66: fix(builder): support devMiddleware.writeToDisk in rspack and use webpack-dev-middleware instead of @rspack/dev-middleware
-
- fix(builder): 在 rspack 中支持 devMiddleware.writeToDisk 配置项,并使用 webpack-dev-middleware 代替 @rspack/dev-middleware
-
-- d4e85c1: fix(rspack-provider): should inject polyfill for web-worker target
-
- fix(rspack-provider): 修复 web-worker target 未注入 polyfill 的问题
-
-- 7e6fb5f: chore: publishConfig add provenance config
-
- chore: publishConfig 增加 provenance 配置
-
-- f212633: feat(rspack-provider): update rspack to [0.2.2](https://github.com/web-infra-dev/rspack/releases/tag/0.2.2)
-
- feat(rspack-provider): 升级 rspack 到 [0.2.2](https://github.com/web-infra-dev/rspack/releases/tag/0.2.2) 版本
-
-- 5684381: fix(builder): incorrect importLoaders option for sass/less files
-
- fix(builder): 修正 importLoaders 对于 sass/less 文件的值
-
-- f14f920: feat(rspack-provider): support disableCssExtract in rspack
-
- feat(rspack-provider): 在 Rspack 构建时支持 disableCssExtract 能力
-
-- 38eccef: chore(builder): move getPostcssConfig and postcss related pkg to builder-shared
-
- chore(builder): 将 getPostcssConfig 和 postcss 相关的 pkg 移动到 builder-shared 中
-
-- f91c557: fix(builder): failed to minify css when use style-loader in Rspack
-
- fix(builder): 修复使用 Rspack + style-loader 时未压缩 CSS 的问题
-
-- Updated dependencies [964c41b]
-- Updated dependencies [15eac36]
-- Updated dependencies [d4e85c1]
-- Updated dependencies [7e6fb5f]
-- Updated dependencies [a7a7ad7]
-- Updated dependencies [6dec7c2]
-- Updated dependencies [c3216b5]
-- Updated dependencies [f14f920]
-- Updated dependencies [692cc0e]
-- Updated dependencies [38eccef]
-- Updated dependencies [f91c557]
-- Updated dependencies [a82d6f7]
- - @modern-js/e2e@2.23.0
- - @modern-js/builder-shared@2.23.0
- - @modern-js/server@2.23.0
- - @modern-js/types@2.23.0
- - @modern-js/utils@2.23.0
-
-## 2.22.1
-
-### Patch Changes
-
-- a470c04: chore(builder): reuse rem plugin between rspack and webpack provider
-
- chore(builder): 在 rspack 和 webpack provider 间复用 rem 插件
-
-- bd4b150: feat(builder): add builder.serve method
-
- feat(builder): 新增 builder.serve 方法
-
-- c739207: feat(builder): support enable CSS Modules for the specified style file by output.cssModules configuration
-
- feat(builder): 支持通过 output.cssModules 配置项为指定的样式文件启用 CSS Modules
-
-- c465db6: fix(builder): update rspack to 0.2.1 and remove useless config format logic
-
- fix(builder): 将 Rspack 升级到 0.2.1 并移除无用的配置转换逻辑
-
-- 8bd9981: fix(builder): use postcss-loader instead of @rspack/postcss-loader to fix tailwindcss hmr bug
-
- fix(builder): 使用 postcss-loader 代替 @rspack/postcss-loader, 来修复 tailwindcss hmr 问题
-
-- Updated dependencies [25b490a]
-- Updated dependencies [e2848a2]
-- Updated dependencies [a470c04]
-- Updated dependencies [95ffa6b]
-- Updated dependencies [12d54ae]
-- Updated dependencies [bd4b150]
-- Updated dependencies [dd36311]
-- Updated dependencies [d4045ed]
-- Updated dependencies [8bd9981]
-- Updated dependencies [1f02cd2]
-- Updated dependencies [cfcf003]
-- Updated dependencies [15181be]
- - @modern-js/types@2.22.1
- - @modern-js/utils@2.22.1
- - @modern-js/builder-shared@2.22.1
- - @modern-js/server@2.22.1
- - @modern-js/e2e@2.22.1
-
-## 2.22.0
-
-### Patch Changes
-
-- 3d48836: chore(deps): fix all missing peer dependencies
-
- chore(deps): 修复缺少的 peer dependencies
-
-- 4161b09: fix(builder): rule.loader support undefined in rspack
-
- fix(builder): 使用 rspack 构建时, rule.loader 允许为空
-
-- becfd36: fix(builder): support array in output.externals when use Rspack
-
- fix(builder): 在使用 Rspack 构建时,output.externals 支持数组
-
-- 02238e6: feat(builder): 使用 Rspack 0601 nightly 版本 (与 0.2.0 版本功能相同)
-
- feat(builder): adapt and use Rspack 0601 nightly version (Same features as version 0.2.0.)
-
-- Updated dependencies [3d48836]
-- Updated dependencies [5050e8e]
-- Updated dependencies [850cde6]
- - @modern-js/builder-shared@2.22.0
- - @modern-js/utils@2.22.0
- - @modern-js/server@2.22.0
- - @modern-js/e2e@2.22.0
- - @modern-js/types@2.22.0
-
-## 2.21.1
-
-### Patch Changes
-
-- Updated dependencies [19b3b64]
- - @modern-js/builder-shared@2.21.1
- - @modern-js/server@2.21.1
- - @modern-js/e2e@2.21.1
- - @modern-js/types@2.21.1
- - @modern-js/utils@2.21.1
-
-## 2.21.0
-
-### Patch Changes
-
-- 7d2972e: fix(builder): output.copy not work in Rspack
-
- fix(builder): output.copy 在 Rspack 构建时不生效
-
-- 7d2972e: feat(builder): update rspack to 0.1.12
-
- feat(builder): 升级 rspack 到 0.1.12 版本
-
-- 863f8df: feat(rspack-provider): support security.checkSyntax in Rspack
-
- feat(rspack-provider): 在使用 Rspack 构建时支持 security.checkSyntax 配置项
-
-- 26dcf3a: chore: bump typescript to v5 in devDependencies
-
- chore: 升级 devDependencies 中的 typescript 版本到 v5
-
-- 8a7d4d2: hotfix(rspack-provider): update Rspack and fix upgrade error
-
- hotfix(rspack-provider): 升级 Rspack 并处理升级问题
-
-- 441a579: feat(builder): support output.disableTsChecker in Rspack
-
- feat(builder): 在使用 Rspack 构建时支持 output.disableTsChecker 配置项
-
-- 056627f: fix(plugin-sass): pollute the `global.location` object
- fix(plugin-sass): 污染全局对象 `global.location`
-- 4274510: fix(builder): failed to disable html via htmlPlugin: false
-
- fix(builder): 修复通过 htmlPlugin: false 无法禁用 html 的问题
-
-- c90ea5a: feat(builder): support output.enableAssetManifest in Rspack
-
- feat(builder): 在使用 Rspack 构建时支持 output.enableAssetManifest 配置项
-
-- 43b4e83: feat: support security.nonce for add nonce attribute on script tag
- feat: 支持 security.nonce 配置,为 script 标签添加 nonce 属性
-- ad78387: chore(deps): bump babel-related dependencies to latest version
-
- chore(deps): 升级 babel 相关依赖到最新版本
-
-- Updated dependencies [7d2972e]
-- Updated dependencies [863f8df]
-- Updated dependencies [e81eeaf]
-- Updated dependencies [26dcf3a]
-- Updated dependencies [1ef03dc]
-- Updated dependencies [056627f]
-- Updated dependencies [8fa8566]
-- Updated dependencies [4274510]
-- Updated dependencies [0fc15ca]
-- Updated dependencies [43b4e83]
-- Updated dependencies [ad78387]
- - @modern-js/builder-shared@2.21.0
- - @modern-js/utils@2.21.0
- - @modern-js/server@2.21.0
- - @modern-js/e2e@2.21.0
- - @modern-js/types@2.21.0
-
-## 2.20.0
-
-### Patch Changes
-
-- f0ef868: feat(rspack-provider): update rspack to 0.1.11
-
- feat(rspack-provider): 升级 rspack 相关依赖到 0.1.11
-
-- Updated dependencies [3c4e0a5]
-- Updated dependencies [6b9d90a]
-- Updated dependencies [5f055ab]
- - @modern-js/builder-shared@2.20.0
- - @modern-js/utils@2.20.0
- - @modern-js/server@2.20.0
- - @modern-js/types@2.20.0
- - @modern-js/e2e@2.20.0
-
-## 2.19.1
-
-### Patch Changes
-
-- Updated dependencies [afb735f]
- - @modern-js/builder-shared@2.19.1
- - @modern-js/server@2.19.1
- - @modern-js/e2e@2.19.1
- - @modern-js/types@2.19.1
- - @modern-js/utils@2.19.1
-
-## 2.19.0
-
-### Patch Changes
-
-- Updated dependencies [1134fe2]
- - @modern-js/builder-shared@2.19.0
- - @modern-js/server@2.19.0
- - @modern-js/utils@2.19.0
- - @modern-js/e2e@2.19.0
- - @modern-js/types@2.19.0
-
-## 2.18.1
-
-### Patch Changes
-
-- 9b0b7ef: feat(rspack-provider): support tools.pug configuration when Rspack build
-
- feat(rspack-provider): 在使用 Rspack 构建时支持 tools.pug 配置项
-
-- abf8c6d: perf(builder): optimize stats.toJson performance
-
- perf(builder): 优化 stats.toJson 性能
-
-- a6ac01a: feat(rspack-provider): support legalComments `linked` and `none` configuration items when building with Rspack
-
- feat(rspack-provider): 在使用 Rspack 构建时,支持 legalComments `linked` 和 `none` 配置项
-
-- 160a0b3: feat(rspack-provider): update Rspack to 0.1.10
-
- feat(rspack-provider): 升级 Rspack 相关依赖到 0.1.10
-
-- Updated dependencies [9b0b7ef]
- - @modern-js/builder-shared@2.18.1
- - @modern-js/server@2.18.1
- - @modern-js/e2e@2.18.1
- - @modern-js/types@2.18.1
- - @modern-js/utils@2.18.1
-
-## 2.18.0
-
-### Minor Changes
-
-- 7de6599: feat: rspack-provider support modern.js ssr mode
- feat: rspack-provider 支持 modern.js ssr 模式
-
-### Patch Changes
-
-- ea60b58: refactor(node-polyfill): using Rspack builtins to provide global variables
-
- refactor(node-polyfill): 通过 Rspack 内置的 provide 注入全局变量
-
- - @modern-js/builder-shared@2.18.0
- - @modern-js/server@2.18.0
- - @modern-js/e2e@2.18.0
- - @modern-js/types@2.18.0
- - @modern-js/utils@2.18.0
-
-## 2.17.1
-
-### Patch Changes
-
-- @modern-js/builder-shared@2.17.1
-- @modern-js/server@2.17.1
-- @modern-js/e2e@2.17.1
-- @modern-js/types@2.17.1
-- @modern-js/utils@2.17.1
-
-## 2.17.0
-
-### Patch Changes
-
-- @modern-js/builder-shared@2.17.0
-- @modern-js/server@2.17.0
-- @modern-js/e2e@2.17.0
-- @modern-js/types@2.17.0
-- @modern-js/utils@2.17.0
-
-## 2.16.0
-
-### Minor Changes
-
-- 7596520: feat(builder): builder plugin supports specifying relative order via the `pre` / `post` configuration items
-
- feat(builder): builder 插件支持通过 `pre` / `post` 配置项指定相对顺序
-
-### Patch Changes
-
-- 50bc0db: feat(builder): update swc-plugins, core-js, swc-helpers
- feat(builder): 更新 swc-plugins, core-js, swc-helpers
-- fd4a8a6: chore(deps): bump postcss-custom-properties to v13.1.5
-
- chore(deps): 升级 postcss-custom-properties 到 v13.1.5
-
-- 4e876ab: chore: package.json include the monorepo-relative directory
-
- chore: 在 package.json 中声明 monorepo 的子路径
-
-- Updated dependencies [fe92de6]
-- Updated dependencies [091986a]
-- Updated dependencies [5954330]
-- Updated dependencies [7596520]
-- Updated dependencies [4e876ab]
-- Updated dependencies [e4e0e01]
- - @modern-js/builder-shared@2.16.0
- - @modern-js/utils@2.16.0
- - @modern-js/server@2.16.0
- - @modern-js/types@2.16.0
- - @modern-js/e2e@2.16.0
-
-## 2.15.0
-
-### Minor Changes
-
-- 3e5e790: feat(transformImport): support disable default transform import, add more test of transformImport
-
- feat(transformImport): 支持关闭默认的 transform import,增加更多 transformImport 测试
-
-### Patch Changes
-
-- 7d23d39: fix: rspack back to v0.1.7
-
- fix: rspack 回退到 v0.1.7
-
-- Updated dependencies [3e5e790]
- - @modern-js/builder-shared@2.15.0
- - @modern-js/server@2.15.0
- - @modern-js/e2e@2.15.0
- - @modern-js/types@2.15.0
- - @modern-js/utils@2.15.0
-
-## 2.14.0
-
-### Patch Changes
-
-- fefd1c5: feat(builder): add convertToRem.inlineRuntime config
-
- feat(builder): 新增 convertToRem.inlineRuntime 配置项
-
-- 4baf588: fix(monorepo): ignore unnessary peer deps warning from antd
-
- fix(monorepo): 忽略由 antd 造成的不必要的 peer deps 警告
-
-- d0efae3: chore(rspack-provider): update rspack to 0.1.8
-
- chore(rspack-provider): 升级 rspack 相关依赖到 0.1.8 版本
-
-- 864d55e: feat(builder): source.globalVars support function usage
-
- feat(builder): source.globalVars 支持函数写法
-
-- b965df2: fix(builder): update source.alias type when using Rspack
-
- fix(builder): 更新使用 Rspack 时的 source.alias 类型
-
-- Updated dependencies [b46fbcb]
-- Updated dependencies [4779152]
-- Updated dependencies [fefd1c5]
-- Updated dependencies [8a3c693]
-- Updated dependencies [9321bef]
-- Updated dependencies [9b45c58]
-- Updated dependencies [1f34dba]
-- Updated dependencies [52d0cb1]
-- Updated dependencies [60a81d0]
-- Updated dependencies [864d55e]
-- Updated dependencies [b965df2]
-- Updated dependencies [dacef96]
-- Updated dependencies [16399fd]
- - @modern-js/builder-shared@2.14.0
- - @modern-js/server@2.14.0
- - @modern-js/utils@2.14.0
- - @modern-js/types@2.14.0
- - @modern-js/e2e@2.14.0
-
-## 2.13.4
-
-### Patch Changes
-
-- @modern-js/builder-shared@2.13.4
-- @modern-js/server@2.13.4
-- @modern-js/e2e@2.13.4
-- @modern-js/types@2.13.4
-- @modern-js/utils@2.13.4
-
-## 2.13.3
-
-### Patch Changes
-
-- Updated dependencies [18cd03f]
-- Updated dependencies [28583e8]
- - @modern-js/builder-shared@2.13.3
- - @modern-js/server@2.13.3
- - @modern-js/e2e@2.13.3
- - @modern-js/types@2.13.3
- - @modern-js/utils@2.13.3
-
-## 2.13.2
-
-### Patch Changes
-
-- @modern-js/builder-shared@2.13.2
-- @modern-js/server@2.13.2
-- @modern-js/e2e@2.13.2
-- @modern-js/types@2.13.2
-- @modern-js/utils@2.13.2
-
-## 2.13.1
-
-### Patch Changes
-
-- @modern-js/builder-shared@2.13.1
-- @modern-js/server@2.13.1
-- @modern-js/e2e@2.13.1
-- @modern-js/types@2.13.1
-- @modern-js/utils@2.13.1
-
-## 2.13.0
-
-### Patch Changes
-
-- c89de05: chore(rspack-provider): apply fullySpecified mjs default value in Rspack
-
- chore(rspack-provider): 在 Rspack 中设置 fullySpecified 在 mjs 下的默认值
-
-- d69c0b9: fix: pin core-js version to 3.27 in SWC
-
- fix: SWC 相关的 core-js 版本固定到 3.27
-
-- 5deb1fb: chore: bump core-js and swc
-
- chore: 升级 core-js 和 swc
-
-- 9c0572e: chore(builder): support get builder/shared compiled path in provider getCompiledPath api
-
- chore(builder): 支持通过 provider getCompiledPath api 获取 builder/shared 中预打包依赖路径
-
-- 538d1a8: feat(rspack-provider): update Rspack to 0.1.7
-
- feat(rspack-provider): 升级 Rspack 相关依赖至 0.1.7
-
-- Updated dependencies [1feacdc]
-- Updated dependencies [384406c]
-- Updated dependencies [c89de05]
-- Updated dependencies [348306d]
-- Updated dependencies [384e393]
-- Updated dependencies [9c0572e]
- - @modern-js/builder-shared@2.13.0
- - @modern-js/server@2.13.0
- - @modern-js/e2e@2.13.0
- - @modern-js/types@2.13.0
- - @modern-js/utils@2.13.0
-
-## 2.12.0
-
-### Patch Changes
-
-- cd1d966: chore(rspack-provider): use rspack stats.time instead of manual timing
-
- chore(rspack-provider): 使用 rspack stats.time 代替手动计时
-
-- fef3394: fix(builder): should add id prefix after minify SVG
-
- fix(builder): 压缩 SVG 后需要添加 id 前缀
-
-- 6b30837: chore(rspack-provider): update rspack to 0.1.6
-
- chore(rspack-provider): 升级 rspack 相关依赖到 0.1.6
-
-- Updated dependencies [c2ca6c8]
-- Updated dependencies [6d86e34]
-- Updated dependencies [fef3394]
- - @modern-js/utils@2.12.0
- - @modern-js/builder-shared@2.12.0
- - @modern-js/server@2.12.0
- - @modern-js/e2e@2.12.0
- - @modern-js/types@2.12.0
-
-## 2.11.0
-
-### Minor Changes
-
-- a8c08c3: feat: 添加 `source.transformImoprt`
-
- feat: add `source.transformImoprt`
-
-### Patch Changes
-
-- a9c6083: fix(builder): incorrect asset URL in windows
-
- fix(builder): 修复 windows 上生成静态资源 URL 错误的问题
-
-- 55b07fd: feat(builder): support output.assetsRetry in rspack-provider
-
- feat(builder): 在 rspack-provider 中支持 output.assetsRetry 配置能力
-
-- c0ba89b: feat: 控制台输出 rspack 版本
- feat: Print the version of rspack in the console.
-- cd1040f: feat: use generated default config objects instead of global objects
- feat: 默认配置项使用动态生成替代全局对象
-- e262a99: fix(builder): failed to set empty distPath.js/css
-
- fix(builder): 修复设置 distPath.js/css 为空时报错的问题
-
-- 1140a69: chore(rspack-builder): update Rspack to 0.1.4
-
- chore(rspack-builder): 升级 Rspack 相关依赖至 0.1.4 版本
-
-- b71cef1: feat(builder): support setting forceSplitting to be an object
-
- feat(builder): 支持将 forceSplitting 设置为一个对象
-
-- 274b2e5: fix: For rspack-provider can use `tools.babel` configuration, inline the `@babel/preset-typescript` to handle ts syntax in rspack-provider.
- fix: 为了 rspack-provider 能给使用 `tools.babel` 配置项,将 `@babel/preset-typescript` 内置进 rspack-provider 去处理 ts 语法。
-- Updated dependencies [adcedad]
-- Updated dependencies [cfb058f]
-- Updated dependencies [a9c6083]
-- Updated dependencies [55b07fd]
-- Updated dependencies [0bd018b]
-- Updated dependencies [8b90c79]
-- Updated dependencies [a8c08c3]
-- Updated dependencies [3aa318d]
-- Updated dependencies [5d624fd]
-- Updated dependencies [e2466a1]
-- Updated dependencies [53b0a63]
-- Updated dependencies [02bb383]
-- Updated dependencies [381a3b9]
-- Updated dependencies [7a60f10]
-- Updated dependencies [cd1040f]
-- Updated dependencies [e262a99]
-- Updated dependencies [b71cef1]
-- Updated dependencies [274b2e5]
-- Updated dependencies [b9e1c54]
- - @modern-js/builder-shared@2.11.0
- - @modern-js/utils@2.11.0
- - @modern-js/server@2.11.0
- - @modern-js/e2e@2.11.0
- - @modern-js/types@2.11.0
-
-## 2.10.0
-
-### Minor Changes
-
-- a8db932: feat: rspack-provider support tools.babel
- feat: rspack-provider 支持 tools.babel
-
-### Patch Changes
-
-- 4d54233: chore(builder): update rspack & show rspack format error
-
- chore(builder): 更新 rspack 版本 & 优化 rspack 错误日志输出
-
-- cfdbf80: fix(builder): update source.define type and schema check in rspack-provider
-
- fix(builder): 更新 rspack-provider 中 source.define 的类型定义与校验
-
-- ed55acb: fix: Temporary forbidden the `tools.babel` in rspack ,because the `tools.babel` in rspack would cause a syntax error
- fix: 由于使用 tools.babel 会引起语法错误,暂时在 rspack 中禁用 tools.babel 配置能力
-- Updated dependencies [a8db932]
-- Updated dependencies [3e0bd50]
-- Updated dependencies [92d247f]
-- Updated dependencies [0da32d0]
-- Updated dependencies [0d9962b]
-- Updated dependencies [fbefa7e]
-- Updated dependencies [4d54233]
-- Updated dependencies [6db4864]
- - @modern-js/builder-shared@2.10.0
- - @modern-js/server@2.10.0
- - @modern-js/types@2.10.0
- - @modern-js/utils@2.10.0
- - @modern-js/e2e@2.10.0
-
-## 2.9.0
-
-### Patch Changes
-
-- 76b26883bb: fix: rspack-provider swc plugin should not inject core-js in ssr.
- fix: rspack-provider swc 插件不应该在 SSR 下注入 core-js
-- 07569e577e: fix(builder): add additional note about hashDigest in cssModuleLocalIdentName
-
- fix(builder): 添加 cssModuleLocalIdentName 中关于 hashDigest 的补充说明
-
-- Updated dependencies [49bb8cd0ef]
- - @modern-js/server@2.9.0
- - @modern-js/builder-shared@2.9.0
- - @modern-js/e2e@2.9.0
- - @modern-js/types@2.9.0
- - @modern-js/utils@2.9.0
-
-## 2.8.0
-
-### Minor Changes
-
-- 40f5039b17: feat(builder): update rspack to 0.1.0
-
- feat(builder): 升级 rspack 至 0.1.0
-
-### Patch Changes
-
-- bc943c9b04: fix: specify the resolve.conditionNames when target = node.
- fix: 当 target = node,指定 resolve.conditionNames
-- 1242f5d8d6: fix(builder-rspack-provider): support entry mode polyfill
-
- fix(builder-rspack-provider): 支持 entry 模式的 polyfill 注入
-
-- 457ee832b9: hotfix(builder): use community loader instead of Rspack unstable sass & less loader
-
- hotfix(builder): 使用社区 sass-loader 和 less-loader 替代 Rspack 非稳定的 sass 和 less loader
-
-- Updated dependencies [ea7bb41e30]
-- Updated dependencies [bd369a89a4]
-- Updated dependencies [1104a9f18b]
-- Updated dependencies [70d82e1408]
-- Updated dependencies [2c1151271d]
-- Updated dependencies [481461a61d]
-- Updated dependencies [1f6ca2c7fb]
- - @modern-js/server@2.8.0
- - @modern-js/builder-shared@2.8.0
- - @modern-js/utils@2.8.0
- - @modern-js/types@2.8.0
- - @modern-js/e2e@2.8.0
-
-## 2.7.0
-
-### Patch Changes
-
-- 206c806efa: fix(rspack-provider): missing tools.autoprefixer type
-
- fix(rspack-provider): 修复缺少 tools.autoprefixer 类型定义的问题
-
-- 3a942a2472: feat: add Rspack provider swc options, add builder-plugin-swc overrideBrowserslist configuration, report warning when enable latestDecorator in builder-plugin-swc
-
- feat: 给 Rspack provider 增加 swc 相关配置项,增加 builder-plugin-swc overrideBrowserslist 配置,在 builder-plugin-swc 启用 latestDecorator 后增加 warning 报错
-
-- 5f899af53a: feat(builder): support output.enableAssetFallback in rspack-provider
-
- feat(builder): 在 rspack-provider 中支持 output.enableAssetFallback 配置项
-
-- 1b913372b4: feat: 增加 copy 配置以及对 core-js path 的 alias
-
- feat: support copy config and add alias of core-js
-
-- Updated dependencies [206c806efa]
-- Updated dependencies [6378e26bf9]
-- Updated dependencies [0f15fc597c]
-- Updated dependencies [5f899af53a]
-- Updated dependencies [dcad887024]
-- Updated dependencies [a4672f7c16]
-- Updated dependencies [ebe0d2dd6e]
-- Updated dependencies [7fff9020e1]
-- Updated dependencies [1eea234fdd]
-- Updated dependencies [84bfb439b8]
- - @modern-js/builder-shared@2.7.0
- - @modern-js/server@2.7.0
- - @modern-js/utils@2.7.0
- - @modern-js/types@2.7.0
- - @modern-js/e2e@2.7.0
-
-## 2.6.0
-
-### Patch Changes
-
-- 0fe658a: feat(builder): support passing URL to html.favicon
-
- feat(builder): 支持在 html.favicon 中直接传入 URL
-
-- Updated dependencies [b92d6db]
-- Updated dependencies [ba6db6e]
-- Updated dependencies [ba6db6e]
-- Updated dependencies [e1f799e]
-- Updated dependencies [107f674]
-- Updated dependencies [7915ab3]
-- Updated dependencies [03d7f7d]
-- Updated dependencies [fae9d1b]
-- Updated dependencies [49fa0b1]
-- Updated dependencies [0fe658a]
-- Updated dependencies [62930b9]
- - @modern-js/builder-shared@2.6.0
- - @modern-js/server@2.6.0
- - @modern-js/utils@2.6.0
- - @modern-js/types@2.6.0
- - @modern-js/e2e@2.6.0
-
-## 2.5.0
-
-### Minor Changes
-
-- 28e7dc6: feat: more use bunlder chain to modify bundler config
- feat: 更多的使用 `bunlder chain` 去修改 bunlder 配置
-
-### Patch Changes
-
-- 30614fa: chore: modify package.json entry fields and build config
- chore: 更改 package.json entry 字段以及构建配置
-- c4c10e7: refactor: refactor rules for static assets processing with rule.oneOf, reuse svg/font/image/media plugin
-
- refactor: 使用 oneOf 重构静态资源处理规则 & 复用 svg / font / media / img 插件
-
-- 84c21f9: fix(builder-webpack-provider): correct mistaken compilerOptions usage in ts-loader options
-
- fix(builder-webpack-provider): 改正 ts-loader options 中错误的 compilerOptions
-
-- 1b0ce87: chore: bump caniuse-lite to latest version
-
- chore: 升级 caniuse-lite 到最新版
-
-- c5ea222: feat(builder): support mergeConfig util in tools.webpack
-
- feat(builder): 支持在 tools.webpack 中使用 mergeConfig 工具函数
-
-- 40230b3: feat(builder): enable postcss plugins based on browserslist
-
- feat(builder): 基于 browserslist 来启用需要的 postcss 插件
-
-- Updated dependencies [58a9918]
-- Updated dependencies [89ca6cc]
-- Updated dependencies [7cb8bb4]
-- Updated dependencies [bb4e712]
-- Updated dependencies [6fca567]
-- Updated dependencies [30614fa]
-- Updated dependencies [c4c10e7]
-- Updated dependencies [1b0ce87]
-- Updated dependencies [11c053b]
-- Updated dependencies [f0b3d8c]
-- Updated dependencies [28e7dc6]
-- Updated dependencies [40230b3]
- - @modern-js/builder-shared@2.5.0
- - @modern-js/server@2.5.0
- - @modern-js/types@2.5.0
- - @modern-js/utils@2.5.0
- - @modern-js/e2e@2.5.0
-
-## 2.4.0
-
-### Minor Changes
-
-- a5572b8: feat: more plugin rebase in `builder-shared`
- feat: 更多 plugin 下沉到 `builder-shared`
-- a914be8: feat: modern-js support Rspack bundler
- feat: modern-js 支持 Rspack 构建工具
-
-### Patch Changes
-
-- 6f83037: fix: change the builder resolve plugin
- fix: 修复 builder resolve 插件
-- 014d06b: feat: reuse bundleAnalyzer plugin, support performance.bundleAnalyze config in rspack-provider
-
- feat: 复用 bundleAnalyzer 插件,在 rspack-provider 中支持 performance.bundleAnalyze 配置项
-
-- 48b036e: fix(builder): should not generate cache when build failed
-
- fix(builder): 修复构建失败时会生成无效编译缓存的问题
-
-- 8c2db5f: feat(core): improve support for exporting a function in config file
-
- feat(core): 完善对配置文件中导出函数的支持
-
-- Updated dependencies [d19484c]
-- Updated dependencies [6f83037]
-- Updated dependencies [014d06b]
-- Updated dependencies [98a2733]
-- Updated dependencies [a5572b8]
-- Updated dependencies [a914be8]
-- Updated dependencies [8c2db5f]
- - @modern-js/server@2.4.0
- - @modern-js/builder-shared@2.4.0
- - @modern-js/utils@2.4.0
- - @modern-js/e2e@2.4.0
- - @modern-js/types@2.4.0
-
-## 2.3.0
-
-### Patch Changes
-
-- 7cd8185: chore: reuse splitChunks plugin between rspack-provider and webpack-provider
-
- chore: 在 rspack-provider 和 webpack-provider 间复用 splitChunks plugin
-
-- 4dfe1bf: feat(rspack-builder): add Rspack minimize plugin
-
- feat(rspack-builder): 添加 Rspack minimize 插件
-
-- Updated dependencies [fd5a3ed]
-- Updated dependencies [67ba34a]
-- Updated dependencies [2ad9fdf]
-- Updated dependencies [f9a26fe]
-- Updated dependencies [6ca1c0b]
-- Updated dependencies [89b6739]
-- Updated dependencies [ff48fc2]
- - @modern-js/utils@2.3.0
- - @modern-js/builder-shared@2.3.0
- - @modern-js/server@2.3.0
- - @modern-js/e2e@2.3.0
- - @modern-js/types@2.3.0
-
-## 2.2.0
-
-### Patch Changes
-
-- f2f8a83: chore: reuse rem AutoSetRootFontSizePlugin between rspack-provider and webpack-provider
-
- chore: 在 rspack-provider 和 webpack-provider 间复用 rem AutoSetRootFontSizePlugin
-
-- cb12ee7: chore: remove some unused deps, bump postcss version
-
- chore: 移除未使用的依赖, 升级 postcss 版本
-
-- 16bdc0a: chore: adjust builder plugin name
-
- chore: 调整 builder 插件命名格式
-
-- Updated dependencies [f2f8a83]
-- Updated dependencies [49eff0c]
-- Updated dependencies [9fc6de9]
-- Updated dependencies [19bb384]
- - @modern-js/builder-shared@2.2.0
- - @modern-js/utils@2.2.0
- - @modern-js/server@2.2.0
- - @modern-js/types@2.2.0
- - @modern-js/e2e@2.2.0
-
-## 2.1.0
-
-### Patch Changes
-
-- 3ad26c2: feat: add util `mergeBuilderConfig` for `modifyBuilderConfig` hook
-
- feat: `modifyBuilderConfig` 钩子回调提供工具函数 `mergeBuilderConfig`
-
-- 5b54418: fix(builder): no longer remove comments of HTML
-
- fix(builder): 不再默认移除 HTML 中的注释
-
-- Updated dependencies [837620c]
-- Updated dependencies [3d0fb38]
-- Updated dependencies [3ad26c2]
-- Updated dependencies [5b54418]
-- Updated dependencies [ccbac43]
-- Updated dependencies [8a9482c]
-- Updated dependencies [679296d]
- - @modern-js/utils@2.1.0
- - @modern-js/server@2.1.0
- - @modern-js/builder-shared@2.1.0
- - @modern-js/e2e@2.1.0
- - @modern-js/types@2.1.0
-
-## 2.0.0
-
-### Major Changes
-
-Initial Release
diff --git a/packages/builder/builder-rspack-provider/LICENSE b/packages/builder/builder-rspack-provider/LICENSE
deleted file mode 100644
index 39e3c5971226..000000000000
--- a/packages/builder/builder-rspack-provider/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) 2021-present Modern.js
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/packages/builder/builder-rspack-provider/README.md b/packages/builder/builder-rspack-provider/README.md
deleted file mode 100644
index 96471fcd089d..000000000000
--- a/packages/builder/builder-rspack-provider/README.md
+++ /dev/null
@@ -1,28 +0,0 @@
-> DEPRECATED: use [Rsbuild](https://github.com/web-infra-dev/rsbuild) instead.
-
-
-
-
-
- Modern.js Builder
-
-
- modernjs.dev/builder
-
-
-
- An Rspack-based build tool for web development.
-
-
-# @modern-js/builder-webpack-provider
-
-This package provides webpack build ability of Modern.js Builder.
-
-## Getting Started
-
-- [Introduction](https://modernjs.dev/builder/en/guide/introduction.html)
-- [API References](https://modernjs.dev/builder/en/api/)
-
-## Contributing
-
-- [Contributing Guide](https://github.com/web-infra-dev/modern.js/blob/main/CONTRIBUTING.md)
diff --git a/packages/builder/builder-rspack-provider/modern.config.js b/packages/builder/builder-rspack-provider/modern.config.js
deleted file mode 100644
index c2bf3e85b393..000000000000
--- a/packages/builder/builder-rspack-provider/modern.config.js
+++ /dev/null
@@ -1,5 +0,0 @@
-const { tscLikeBuildConfig } = require('@scripts/build');
-
-module.exports = {
- buildConfig: tscLikeBuildConfig,
-};
diff --git a/packages/builder/builder-rspack-provider/package.json b/packages/builder/builder-rspack-provider/package.json
deleted file mode 100644
index 00d8a6db356e..000000000000
--- a/packages/builder/builder-rspack-provider/package.json
+++ /dev/null
@@ -1,88 +0,0 @@
-{
- "name": "@modern-js/builder-rspack-provider",
- "description": "Builder provider for Rspack",
- "homepage": "https://modernjs.dev",
- "bugs": "https://github.com/web-infra-dev/modern.js/issues",
- "repository": {
- "type": "git",
- "url": "https://github.com/web-infra-dev/modern.js",
- "directory": "packages/builder/builder-rspack-provider"
- },
- "license": "MIT",
- "keywords": [
- "react",
- "framework",
- "modern",
- "modern.js"
- ],
- "engines": {
- "node": ">=14.0.0"
- },
- "version": "2.46.1",
- "jsnext:source": "./src/index.ts",
- "types": "./src/index.ts",
- "main": "./dist/index.js",
- "module": "./dist/index.js",
- "exports": {
- ".": {
- "jsnext:source": "./src/index.ts",
- "default": "./dist/index.js"
- },
- "./plugins/*": {
- "types": "./dist/plugins/*.d.ts",
- "jsnext:source": "./src/plugins/*.ts",
- "default": "./dist/plugins/*.js"
- }
- },
- "typesVersions": {
- "*": {
- "plugins/*": [
- "./dist/plugins/*.d.ts"
- ]
- }
- },
- "scripts": {
- "prepublishOnly": "only-allow-pnpm",
- "build": "modern-lib build",
- "dev": "modern-lib build --watch",
- "test": "vitest run",
- "test:watch": "vitest dev",
- "test:ui": "vitest --ui"
- },
- "dependencies": {
- "@babel/core": "^7.23.2",
- "@modern-js/builder-shared": "workspace:*",
- "@modern-js/server": "workspace:*",
- "@modern-js/types": "workspace:*",
- "@modern-js/utils": "workspace:*",
- "@babel/preset-typescript": "^7.22.15",
- "@rspack/core": "0.4.5",
- "@rspack/plugin-react-refresh": "0.4.5",
- "@rspack/plugin-html": "0.4.5",
- "@swc/helpers": "0.5.3",
- "rspack-manifest-plugin": "5.0.0-alpha0",
- "caniuse-lite": "^1.0.30001520",
- "core-js": "~3.32.1",
- "react-refresh": "^0.14.0",
- "style-loader": "3.3.3",
- "webpack": "^5.89.0",
- "postcss": "8.4.31"
- },
- "devDependencies": {
- "@arco-design/web-react": "^2.46.0",
- "@scripts/build": "workspace:*",
- "@scripts/vitest-config": "workspace:*",
- "@types/node": "^14",
- "antd": "4",
- "typescript": "^5",
- "react": "^18",
- "react-dom": "^18"
- },
- "sideEffects": false,
- "publishConfig": {
- "registry": "https://registry.npmjs.org/",
- "access": "public",
- "provenance": true,
- "types": "./dist/index.d.ts"
- }
-}
diff --git a/packages/builder/builder-rspack-provider/src/config/defaults.ts b/packages/builder/builder-rspack-provider/src/config/defaults.ts
deleted file mode 100644
index 1c40dad503ae..000000000000
--- a/packages/builder/builder-rspack-provider/src/config/defaults.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import {
- mergeBuilderConfig,
- getDefaultDevConfig,
- getDefaultHtmlConfig,
- getDefaultToolsConfig,
- getDefaultOutputConfig,
- getDefaultSourceConfig,
- getDefaultSecurityConfig,
- getDefaultPerformanceConfig,
-} from '@modern-js/builder-shared';
-import type { BuilderConfig } from '../types';
-
-export const createDefaultConfig = (): BuilderConfig => ({
- dev: getDefaultDevConfig(),
- html: getDefaultHtmlConfig(),
- source: {
- ...getDefaultSourceConfig(),
- define: {},
- },
- output: getDefaultOutputConfig(),
- tools: getDefaultToolsConfig(),
- security: getDefaultSecurityConfig(),
- performance: getDefaultPerformanceConfig(),
-});
-
-export const withDefaultConfig = (config: BuilderConfig) =>
- mergeBuilderConfig(createDefaultConfig(), config);
diff --git a/packages/builder/builder-rspack-provider/src/config/normalize.ts b/packages/builder/builder-rspack-provider/src/config/normalize.ts
deleted file mode 100644
index 01806b024971..000000000000
--- a/packages/builder/builder-rspack-provider/src/config/normalize.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import { mergeBuilderConfig } from '@modern-js/builder-shared';
-import { BuilderConfig, NormalizedConfig } from '../types';
-import { createDefaultConfig } from './defaults';
-
-/** #__PURE__
- * 1. May used by multiple plugins.
- * 2. Object value that should not be empty.
- * 3. Meaningful and can be filled by constant value.
- */
-export const normalizeConfig = (config: BuilderConfig): NormalizedConfig =>
- mergeBuilderConfig(
- createDefaultConfig() as NormalizedConfig,
- config as NormalizedConfig,
- );
diff --git a/packages/builder/builder-rspack-provider/src/config/validate/dev.ts b/packages/builder/builder-rspack-provider/src/config/validate/dev.ts
deleted file mode 100644
index 89abb7f60668..000000000000
--- a/packages/builder/builder-rspack-provider/src/config/validate/dev.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import { sharedDevConfigSchema, z } from '@modern-js/builder-shared';
-import type { DevConfig } from '../../types';
-
-export const devConfigSchema: z.ZodType = sharedDevConfigSchema;
diff --git a/packages/builder/builder-rspack-provider/src/config/validate/html.ts b/packages/builder/builder-rspack-provider/src/config/validate/html.ts
deleted file mode 100644
index 71dca7b164d6..000000000000
--- a/packages/builder/builder-rspack-provider/src/config/validate/html.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import { sharedHtmlConfigSchema, z } from '@modern-js/builder-shared';
-import type { HtmlConfig } from '../../types';
-
-export const htmlConfigSchema: z.ZodType = sharedHtmlConfigSchema;
diff --git a/packages/builder/builder-rspack-provider/src/config/validate/index.ts b/packages/builder/builder-rspack-provider/src/config/validate/index.ts
deleted file mode 100644
index 1c71a8bdd2ad..000000000000
--- a/packages/builder/builder-rspack-provider/src/config/validate/index.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import { z } from '@modern-js/builder-shared/zod';
-import { validateBuilderConfig as validateConfig } from '@modern-js/builder-shared';
-import { BuilderConfig } from '../../types';
-
-import { devConfigSchema } from './dev';
-import { htmlConfigSchema } from './html';
-import { outputConfigSchema } from './output';
-import { performanceConfigSchema } from './performance';
-import { sourceConfigSchema } from './source';
-import { toolsConfigSchema } from './tools';
-import { securityConfigSchema } from './security';
-
-export const configSchema: z.ZodType = z.partialObj({
- source: sourceConfigSchema,
- dev: devConfigSchema,
- html: htmlConfigSchema,
- output: outputConfigSchema,
- security: securityConfigSchema,
- performance: performanceConfigSchema,
- tools: toolsConfigSchema,
-});
-
-export const validateBuilderConfig = async (data: unknown) => {
- return validateConfig(configSchema, data);
-};
diff --git a/packages/builder/builder-rspack-provider/src/config/validate/output.ts b/packages/builder/builder-rspack-provider/src/config/validate/output.ts
deleted file mode 100644
index a4bf47e32f30..000000000000
--- a/packages/builder/builder-rspack-provider/src/config/validate/output.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { sharedOutputConfigSchema, z } from '@modern-js/builder-shared';
-import type { OutputConfig } from '../../types';
-
-export const outputConfigSchema: z.ZodType =
- sharedOutputConfigSchema
- .extend({
- polyfill: z.enum(['entry', 'ua', 'off']),
- })
- .partial();
diff --git a/packages/builder/builder-rspack-provider/src/config/validate/performance.ts b/packages/builder/builder-rspack-provider/src/config/validate/performance.ts
deleted file mode 100644
index 4cfeee52d505..000000000000
--- a/packages/builder/builder-rspack-provider/src/config/validate/performance.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-import {
- sharedPerformanceConfigSchema,
- z,
- BaseChunkSplit,
- BuilderChunkSplit,
- BaseSplitRulesSchema,
- SplitBySizeSchema,
- SplitCustomSchema,
- ForceSplittingSchema,
-} from '@modern-js/builder-shared';
-import type { PerformanceConfig } from '../../types';
-
-const BaseChunkSplitSchema: z.ZodType =
- BaseSplitRulesSchema.extend({
- strategy: z.enum([
- 'split-by-module',
- 'split-by-experience',
- 'all-in-one',
- 'single-vendor',
- ]),
- forceSplitting: ForceSplittingSchema,
- override: z.any().optional(),
- });
-
-const BuilderChunkSplitSchema: z.ZodType = z.union([
- BaseChunkSplitSchema,
- SplitBySizeSchema,
- SplitCustomSchema,
-]);
-
-export const performanceConfigSchema: z.ZodType =
- sharedPerformanceConfigSchema
- .extend({
- chunkSplit: BuilderChunkSplitSchema,
- })
- .partial();
diff --git a/packages/builder/builder-rspack-provider/src/config/validate/security.ts b/packages/builder/builder-rspack-provider/src/config/validate/security.ts
deleted file mode 100644
index b3c82ac67270..000000000000
--- a/packages/builder/builder-rspack-provider/src/config/validate/security.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import { sharedSecurityConfigSchema, z } from '@modern-js/builder-shared';
-import type { SecurityConfig } from '../../types';
-
-export const securityConfigSchema: z.ZodType =
- sharedSecurityConfigSchema;
diff --git a/packages/builder/builder-rspack-provider/src/config/validate/source.ts b/packages/builder/builder-rspack-provider/src/config/validate/source.ts
deleted file mode 100644
index fde71af3eab1..000000000000
--- a/packages/builder/builder-rspack-provider/src/config/validate/source.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { sharedSourceConfigSchema, z } from '@modern-js/builder-shared';
-import type { SourceConfig } from '../../types';
-
-export const sourceConfigSchema: z.ZodType =
- sharedSourceConfigSchema
- .extend({
- define: z.record(z.any()),
- })
- .partial();
diff --git a/packages/builder/builder-rspack-provider/src/config/validate/tools.ts b/packages/builder/builder-rspack-provider/src/config/validate/tools.ts
deleted file mode 100644
index 65b857c67c4b..000000000000
--- a/packages/builder/builder-rspack-provider/src/config/validate/tools.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import {
- z,
- FileFilterUtilSchema,
- sharedToolsConfigSchema,
-} from '@modern-js/builder-shared';
-import type { ToolsConfig } from '../../types';
-
-export const toolsConfigSchema: z.ZodType =
- sharedToolsConfigSchema.extend({
- sass: z.chained(z.any(), z.object({ addExcludes: FileFilterUtilSchema })),
- less: z.chained(z.any(), z.object({ addExcludes: FileFilterUtilSchema })),
- htmlPlugin: z.chained(
- z.any(),
- z.object({ entryName: z.string(), entryValue: z.any() }),
- ),
- postcss: z.chained(z.any(), z.object({ addPlugins: z.function() })),
- autoprefixer: z.chained(z.any()),
- rspack: z.chained(z.any(), z.any()),
- });
diff --git a/packages/builder/builder-rspack-provider/src/core/build.ts b/packages/builder/builder-rspack-provider/src/core/build.ts
deleted file mode 100644
index 642dd1bf28ff..000000000000
--- a/packages/builder/builder-rspack-provider/src/core/build.ts
+++ /dev/null
@@ -1,79 +0,0 @@
-import { createCompiler } from './createCompiler';
-import { initConfigs, InitConfigsOptions } from './initConfigs';
-import {
- logger,
- BuildOptions,
- Stats,
- MultiStats,
-} from '@modern-js/builder-shared';
-import type { Compiler, MultiCompiler, RspackConfig } from '../types';
-
-export type BuildExecuter = {
- (compiler: Compiler): Promise<{ stats?: Stats }>;
- (compiler: MultiCompiler): Promise<{ stats?: MultiStats }>;
- (compiler: Compiler | MultiCompiler): Promise<{ stats?: Stats | MultiStats }>;
-};
-
-export const rspackBuild: BuildExecuter = async compiler => {
- return new Promise((resolve, reject) => {
- compiler.run((err: any, stats?: Stats) => {
- if (err || stats?.hasErrors()) {
- const buildError = err || new Error('Rspack build failed!');
- reject(buildError);
- }
- // If there is a compilation error, the close method should not be called.
- // Otherwise the bundler may generate an invalid cache.
- else {
- // When using run or watch, call close and wait for it to finish before calling run or watch again.
- // Concurrent compilations will corrupt the output files.
- compiler.close(() => {
- // Assert type of stats must align to compiler.
- resolve({ stats: stats as any });
- });
- }
- });
- });
-};
-
-export const build = async (
- initOptions: InitConfigsOptions,
- { mode = 'production', watch, compiler: customCompiler }: BuildOptions = {},
- executer?: BuildExecuter,
-) => {
- if (!process.env.NODE_ENV) {
- process.env.NODE_ENV = mode;
- }
-
- const { context } = initOptions;
-
- let compiler: Compiler | MultiCompiler;
- let bundlerConfigs: RspackConfig[] | undefined;
-
- if (customCompiler) {
- compiler = customCompiler as any;
- } else {
- const { rspackConfigs } = await initConfigs(initOptions);
- compiler = await createCompiler({
- context,
- rspackConfigs,
- });
- bundlerConfigs = rspackConfigs;
- }
-
- await context.hooks.onBeforeBuildHook.call({
- bundlerConfigs,
- });
-
- if (watch) {
- compiler.watch({}, err => {
- if (err) {
- logger.error(err);
- }
- });
- } else {
- const executeResult = await executer?.(compiler);
- await context.hooks.onAfterBuildHook.call({
- stats: executeResult?.stats,
- });
- }
-};
diff --git a/packages/builder/builder-rspack-provider/src/core/createCompiler.ts b/packages/builder/builder-rspack-provider/src/core/createCompiler.ts
deleted file mode 100644
index d48a3678190b..000000000000
--- a/packages/builder/builder-rspack-provider/src/core/createCompiler.ts
+++ /dev/null
@@ -1,82 +0,0 @@
-import {
- debug,
- logger,
- prettyTime,
- formatStats,
- TARGET_ID_MAP,
-} from '@modern-js/builder-shared';
-import type { Context, RspackConfig } from '../types';
-import { Stats, MultiStats } from '@rspack/core';
-
-export async function createCompiler({
- context,
- rspackConfigs,
-}: {
- context: Context;
- rspackConfigs: RspackConfig[];
-}) {
- debug('create compiler');
- await context.hooks.onBeforeCreateCompilerHook.call({
- bundlerConfigs: rspackConfigs,
- });
-
- const { rspack } = await import('@rspack/core');
- const { isDev } = await import('@modern-js/utils');
-
- const compiler =
- rspackConfigs.length === 1
- ? rspack(rspackConfigs[0])
- : rspack(rspackConfigs);
-
- let isFirstCompile = true;
-
- compiler.hooks.done.tap('done', async (stats: Stats | MultiStats) => {
- const obj = stats.toJson({
- all: false,
- timings: true,
- });
-
- const printTime = (c: typeof obj, index: number) => {
- if (c.time) {
- const time = prettyTime([0, c.time * 10 ** 6]);
- const target = Array.isArray(context.target)
- ? context.target[index]
- : context.target;
- const name = TARGET_ID_MAP[target || 'web'];
- logger.ready(`${name} compiled in ${time}`);
- }
- };
-
- if (!stats.hasErrors()) {
- if (obj.children) {
- obj.children.forEach((c, index) => {
- printTime(c, index);
- });
- } else {
- printTime(obj, 0);
- }
- }
-
- const { message, level } = formatStats(stats);
-
- if (level === 'error') {
- logger.error(message);
- }
- if (level === 'warning') {
- logger.warn(message);
- }
-
- if (isDev()) {
- await context.hooks.onDevCompileDoneHook.call({
- isFirstCompile,
- });
- }
-
- isFirstCompile = false;
- });
-
- await context.hooks.onAfterCreateCompilerHook.call({ compiler });
- debug('create compiler done');
-
- return compiler;
-}
diff --git a/packages/builder/builder-rspack-provider/src/core/createContext.ts b/packages/builder/builder-rspack-provider/src/core/createContext.ts
deleted file mode 100644
index 1c8452f782fe..000000000000
--- a/packages/builder/builder-rspack-provider/src/core/createContext.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-import { join } from 'path';
-import {
- isFileExists,
- TS_CONFIG_FILE,
- createContextByConfig,
- type CreateBuilderOptions,
- NormalizedSharedOutputConfig,
-} from '@modern-js/builder-shared';
-import { initHooks } from './initHooks';
-import { validateBuilderConfig } from '../config/validate';
-import { withDefaultConfig } from '../config/defaults';
-import type { Context, BuilderConfig } from '../types';
-
-/**
- * Generate the actual context used in the build,
- * which can have a lot of overhead and take some side effects.
- */
-export async function createContext(
- options: Required,
- userBuilderConfig: BuilderConfig,
-): Promise {
- const builderConfig = withDefaultConfig(userBuilderConfig);
- const context = createContextByConfig(
- options,
- builderConfig.output as NormalizedSharedOutputConfig,
- 'rspack',
- );
- const configValidatingTask = Promise.resolve();
-
- await validateBuilderConfig(builderConfig);
-
- const tsconfigPath = join(context.rootPath, TS_CONFIG_FILE);
-
- return {
- ...context,
- hooks: initHooks(),
- configValidatingTask,
- config: { ...builderConfig },
- originalConfig: userBuilderConfig,
- tsconfigPath: (await isFileExists(tsconfigPath)) ? tsconfigPath : undefined,
- };
-}
diff --git a/packages/builder/builder-rspack-provider/src/core/devMiddleware.ts b/packages/builder/builder-rspack-provider/src/core/devMiddleware.ts
deleted file mode 100644
index 791897e81342..000000000000
--- a/packages/builder/builder-rspack-provider/src/core/devMiddleware.ts
+++ /dev/null
@@ -1,61 +0,0 @@
-import webpackDevMiddleware from '@modern-js/builder-shared/webpack-dev-middleware';
-import type { ModernDevServerOptions } from '@modern-js/server';
-import { setupServerHooks, isClientCompiler } from '@modern-js/builder-shared';
-
-import type { Compiler, MultiCompiler } from '@rspack/core';
-
-type DevMiddlewareOptions = ModernDevServerOptions['devMiddleware'];
-
-export function getHotRuntimeEntries(compiler: Compiler) {
- const hot = compiler.options.devServer?.hot ?? true;
- const refresh = compiler.options.builtins?.react?.refresh ?? true;
-
- if (hot && refresh) {
- const reactRefreshEntryPath = require.resolve(
- '@rspack/plugin-react-refresh/react-refresh-entry',
- );
- return [reactRefreshEntryPath];
- }
-
- return [];
-}
-
-function applyHMREntry(compiler: Compiler, clientPath: string) {
- if (!isClientCompiler(compiler)) {
- return;
- }
-
- const hotRuntimeEntires = getHotRuntimeEntries(compiler);
-
- const entires = [...hotRuntimeEntires, clientPath];
-
- for (const key in compiler.options.entry) {
- compiler.options.entry[key].import = [
- ...entires,
- ...(compiler.options.entry[key].import || []),
- ];
- }
-}
-
-export const getDevMiddleware: (
- compiler: Compiler | MultiCompiler,
-) => NonNullable = compiler => options => {
- const { hmrClientPath, callbacks, ...restOptions } = options;
-
- if ((compiler as MultiCompiler).compilers) {
- (compiler as MultiCompiler).compilers.forEach(compiler => {
- hmrClientPath && applyHMREntry(compiler, hmrClientPath);
-
- // register hooks for each compilation, update socket stats if recompiled
- setupServerHooks(compiler, callbacks);
- });
- } else {
- hmrClientPath && applyHMREntry(compiler as Compiler, hmrClientPath);
-
- // register hooks for each compilation, update socket stats if recompiled
- setupServerHooks(compiler as Compiler, callbacks);
- }
-
- // @ts-expect-error
- return webpackDevMiddleware(compiler, restOptions);
-};
diff --git a/packages/builder/builder-rspack-provider/src/core/initConfigs.ts b/packages/builder/builder-rspack-provider/src/core/initConfigs.ts
deleted file mode 100644
index ecd5333cb639..000000000000
--- a/packages/builder/builder-rspack-provider/src/core/initConfigs.ts
+++ /dev/null
@@ -1,77 +0,0 @@
-import {
- debug,
- isDebug,
- initPlugins,
- mergeBuilderConfig,
- type PluginStore,
- type InspectConfigOptions,
- type CreateBuilderOptions,
-} from '@modern-js/builder-shared';
-import { inspectConfig } from './inspectConfig';
-import { generateRspackConfig } from './rspackConfig';
-import { normalizeConfig } from '../config/normalize';
-import type { Context } from '../types';
-
-async function modifyBuilderConfig(context: Context) {
- debug('modify builder config');
- const [modified] = await context.hooks.modifyBuilderConfigHook.call(
- context.config,
- { mergeBuilderConfig },
- );
- context.config = modified;
-
- debug('modify builder config done');
-}
-
-export type InitConfigsOptions = {
- context: Context;
- pluginStore: PluginStore;
- builderOptions: Required;
-};
-
-export async function initConfigs({
- context,
- pluginStore,
- builderOptions,
-}: InitConfigsOptions) {
- const { ensureArray } = await import('@modern-js/utils');
-
- await context.configValidatingTask;
- await initPlugins({
- pluginAPI: context.pluginAPI,
- pluginStore,
- });
-
- await modifyBuilderConfig(context);
- context.normalizedConfig = normalizeConfig(context.config);
-
- const targets = ensureArray(builderOptions.target);
- const rspackConfigs = await Promise.all(
- targets.map(target => generateRspackConfig({ target, context })),
- );
-
- // write builder config and Rspack config to disk in debug mode
- if (isDebug()) {
- const inspect = () => {
- const inspectOptions: InspectConfigOptions = {
- verbose: true,
- writeToDisk: true,
- };
- inspectConfig({
- context,
- pluginStore,
- inspectOptions,
- builderOptions,
- bundlerConfigs: rspackConfigs,
- });
- };
-
- // run inspect later to avoid cleaned by cleanOutput plugin
- context.hooks.onBeforeBuildHook.tap(inspect);
- context.hooks.onBeforeStartDevServerHook.tap(inspect);
- }
-
- return {
- rspackConfigs,
- };
-}
diff --git a/packages/builder/builder-rspack-provider/src/core/initHooks.ts b/packages/builder/builder-rspack-provider/src/core/initHooks.ts
deleted file mode 100644
index 9bf7a240af31..000000000000
--- a/packages/builder/builder-rspack-provider/src/core/initHooks.ts
+++ /dev/null
@@ -1,45 +0,0 @@
-import {
- createAsyncHook,
- OnExitFn,
- OnAfterBuildFn,
- OnBeforeBuildFn,
- OnDevCompileDoneFn,
- ModifyBuilderConfigFn,
- OnAfterStartDevServerFn,
- OnBeforeStartDevServerFn,
- OnAfterCreateCompilerFn,
- OnBeforeCreateCompilerFn,
- ModifyBundlerChainFn,
-} from '@modern-js/builder-shared';
-import type {
- Compiler,
- MultiCompiler,
- RspackConfig,
- BuilderConfig,
- ModifyRspackConfigFn,
-} from '../types';
-
-export function initHooks() {
- return {
- /** parameters are not bundler-related */
- onExitHook: createAsyncHook(),
- onDevCompileDoneHook: createAsyncHook(),
- onAfterStartDevServerHook: createAsyncHook(),
- onBeforeStartDevServerHook: createAsyncHook(),
-
- /** parameters are bundler-related */
- onAfterBuildHook: createAsyncHook(),
- onBeforeBuildHook: createAsyncHook>(),
- modifyRspackConfigHook: createAsyncHook(),
- modifyBuilderConfigHook:
- createAsyncHook>(),
- onAfterCreateCompilerHook:
- createAsyncHook>(),
- onBeforeCreateCompilerHook:
- createAsyncHook>(),
-
- modifyBundlerChainHook: createAsyncHook(),
- };
-}
-
-export type Hooks = ReturnType;
diff --git a/packages/builder/builder-rspack-provider/src/core/initPlugins.ts b/packages/builder/builder-rspack-provider/src/core/initPlugins.ts
deleted file mode 100644
index 8b0bb2a53e94..000000000000
--- a/packages/builder/builder-rspack-provider/src/core/initPlugins.ts
+++ /dev/null
@@ -1,71 +0,0 @@
-import {
- onExitProcess,
- createPublicContext,
- getHTMLPathByEntry,
- type PluginStore,
-} from '@modern-js/builder-shared';
-import type { Context, BuilderPluginAPI } from '../types';
-
-export function getPluginAPI({
- context,
- pluginStore,
-}: {
- context: Context;
- pluginStore: PluginStore;
-}): BuilderPluginAPI {
- const { hooks } = context;
- const publicContext = createPublicContext(context);
-
- const getBuilderConfig = () => {
- if (!context.normalizedConfig) {
- throw new Error(
- 'Cannot access builder config until modifyBuilderConfig is called.',
- );
- }
- return context.config;
- };
-
- const getNormalizedConfig = () => {
- if (!context.normalizedConfig) {
- throw new Error(
- 'Cannot access normalized config until modifyBuilderConfig is called.',
- );
- }
- return context.normalizedConfig;
- };
-
- const getHTMLPaths = () => {
- return Object.keys(context.entry).reduce>(
- (prev, key) => {
- prev[key] = getHTMLPathByEntry(key, getNormalizedConfig());
- return prev;
- },
- {},
- );
- };
-
- onExitProcess(() => {
- hooks.onExitHook.call();
- });
-
- return {
- context: publicContext,
- getHTMLPaths,
- getBuilderConfig,
- getNormalizedConfig,
- isPluginExists: pluginStore.isPluginExists,
-
- // Hooks
- onExit: hooks.onExitHook.tap,
- onAfterBuild: hooks.onAfterBuildHook.tap,
- onBeforeBuild: hooks.onBeforeBuildHook.tap,
- onDevCompileDone: hooks.onDevCompileDoneHook.tap,
- modifyRspackConfig: hooks.modifyRspackConfigHook.tap,
- modifyBuilderConfig: hooks.modifyBuilderConfigHook.tap,
- modifyBundlerChain: hooks.modifyBundlerChainHook.tap,
- onAfterCreateCompiler: hooks.onAfterCreateCompilerHook.tap,
- onBeforeCreateCompiler: hooks.onBeforeCreateCompilerHook.tap,
- onAfterStartDevServer: hooks.onAfterStartDevServerHook.tap,
- onBeforeStartDevServer: hooks.onBeforeStartDevServerHook.tap,
- };
-}
diff --git a/packages/builder/builder-rspack-provider/src/core/inspectConfig.ts b/packages/builder/builder-rspack-provider/src/core/inspectConfig.ts
deleted file mode 100644
index c0137df4c691..000000000000
--- a/packages/builder/builder-rspack-provider/src/core/inspectConfig.ts
+++ /dev/null
@@ -1,72 +0,0 @@
-import { join, isAbsolute } from 'path';
-import { initConfigs, InitConfigsOptions } from './initConfigs';
-import {
- InspectConfigOptions,
- outputInspectConfigFiles,
- stringifyConfig,
-} from '@modern-js/builder-shared';
-import type { RspackConfig } from '../types';
-
-export async function inspectConfig({
- context,
- pluginStore,
- builderOptions,
- bundlerConfigs,
- inspectOptions = {},
-}: InitConfigsOptions & {
- inspectOptions?: InspectConfigOptions;
- bundlerConfigs?: RspackConfig[];
-}) {
- if (inspectOptions.env) {
- process.env.NODE_ENV = inspectOptions.env;
- } else if (!process.env.NODE_ENV) {
- process.env.NODE_ENV = 'development';
- }
-
- const rspackConfigs =
- bundlerConfigs ||
- (
- await initConfigs({
- context,
- pluginStore,
- builderOptions,
- })
- ).rspackConfigs;
-
- const rawBuilderConfig = await stringifyConfig(
- context.config,
- inspectOptions.verbose,
- );
- const rawBundlerConfigs = await Promise.all(
- rspackConfigs.map(config =>
- stringifyConfig(config, inspectOptions.verbose),
- ),
- );
-
- let outputPath = inspectOptions.outputPath || context.distPath;
- if (!isAbsolute(outputPath)) {
- outputPath = join(context.rootPath, outputPath);
- }
-
- if (inspectOptions.writeToDisk) {
- await outputInspectConfigFiles({
- builderConfig: rawBuilderConfig,
- bundlerConfigs: rawBundlerConfigs,
- inspectOptions: {
- ...inspectOptions,
- outputPath,
- },
- builderOptions,
- configType: 'rspack',
- });
- }
-
- return {
- builderConfig: rawBuilderConfig,
- bundlerConfigs: rawBundlerConfigs,
- origin: {
- builderConfig: context.config,
- bundlerConfigs: rspackConfigs,
- },
- };
-}
diff --git a/packages/builder/builder-rspack-provider/src/core/rspackConfig.ts b/packages/builder/builder-rspack-provider/src/core/rspackConfig.ts
deleted file mode 100644
index d31e899ff88a..000000000000
--- a/packages/builder/builder-rspack-provider/src/core/rspackConfig.ts
+++ /dev/null
@@ -1,149 +0,0 @@
-import {
- debug,
- BundlerConfig,
- modifyBundlerChain,
- type NodeEnv,
- type BuilderTarget,
- type ModifyChainUtils,
-} from '@modern-js/builder-shared';
-import { castArray } from '@modern-js/utils/lodash';
-import { getCompiledPath } from '../shared';
-import type { Context, RspackConfig, ModifyRspackConfigUtils } from '../types';
-
-async function modifyRspackConfig(
- context: Context,
- rspackConfig: RspackConfig,
- utils: ModifyRspackConfigUtils,
-) {
- debug('modify Rspack config');
- let [modifiedConfig] = await context.hooks.modifyRspackConfigHook.call(
- rspackConfig,
- utils,
- );
-
- if (context.config.tools?.rspack) {
- const { applyOptionsChain } = await import('@modern-js/utils');
-
- modifiedConfig = applyOptionsChain(
- modifiedConfig,
- context.config.tools.rspack,
- utils,
- utils.mergeConfig,
- );
- }
-
- debug('modify Rspack config done');
- return modifiedConfig;
-}
-
-async function getConfigUtils(
- config: RspackConfig,
- chainUtils: ModifyChainUtils,
-): Promise {
- const { merge } = await import('@modern-js/builder-shared/webpack-merge');
- const rspack = await import('@rspack/core');
-
- return {
- ...chainUtils,
-
- rspack,
-
- mergeConfig: merge,
-
- addRules(rules) {
- const ruleArr = castArray(rules);
- if (!config.module) {
- config.module = {};
- }
- if (!config.module.rules) {
- config.module.rules = [];
- }
- config.module.rules.unshift(...ruleArr);
- },
-
- prependPlugins(plugins) {
- const pluginArr = castArray(plugins);
- if (!config.plugins) {
- config.plugins = [];
- }
- config.plugins.unshift(...pluginArr);
- },
-
- appendPlugins(plugins) {
- const pluginArr = castArray(plugins);
- if (!config.plugins) {
- config.plugins = [];
- }
- config.plugins.push(...pluginArr);
- },
-
- removePlugin(pluginName) {
- if (config.plugins) {
- config.plugins = config.plugins.filter(p => p && p.name !== pluginName);
- }
- },
- };
-}
-
-async function getChainUtils(target: BuilderTarget): Promise {
- const nodeEnv = process.env.NODE_ENV as NodeEnv;
- const { CHAIN_ID } = await import('@modern-js/utils');
- const { default: HtmlPlugin } = await import('@rspack/plugin-html');
- const { default: webpack } = await import('webpack');
-
- return {
- env: nodeEnv,
- target,
- isProd: nodeEnv === 'production',
- isServer: target === 'node',
- isServiceWorker: target === 'service-worker',
- isWebWorker: target === 'web-worker',
- getCompiledPath,
- CHAIN_ID,
- HtmlPlugin,
- webpack,
- };
-}
-
-/**
- * BundlerConfig type is similar to WebpackConfig.
- *
- * The type is not strictly compatible with rspack, such as devtool (string or const).
- *
- * There is no need to consider it in builder, and it is handed over to rspack for verification
- */
-const convertToRspackConfig = (config: BundlerConfig): RspackConfig => {
- return config as unknown as RspackConfig;
-};
-
-export async function generateRspackConfig({
- target,
- context,
-}: {
- target: BuilderTarget;
- context: Context;
-}) {
- const chainUtils = await getChainUtils(target);
- const { BannerPlugin, DefinePlugin, ProvidePlugin } = await import(
- '@rspack/core'
- );
-
- const chain = await modifyBundlerChain(context, {
- ...chainUtils,
- bundler: {
- BannerPlugin,
- DefinePlugin,
- ProvidePlugin,
- },
- });
-
- let rspackConfig = convertToRspackConfig(chain.toConfig());
-
- rspackConfig = await modifyRspackConfig(
- context,
- rspackConfig,
- await getConfigUtils(rspackConfig, chainUtils),
- );
-
- return rspackConfig;
-}
diff --git a/packages/builder/builder-rspack-provider/src/core/startDevServer.ts b/packages/builder/builder-rspack-provider/src/core/startDevServer.ts
deleted file mode 100644
index 9888deb4e223..000000000000
--- a/packages/builder/builder-rspack-provider/src/core/startDevServer.ts
+++ /dev/null
@@ -1,75 +0,0 @@
-import {
- debug,
- startDevServer as baseStartDevServer,
- StartDevServerOptions,
- getDevServerOptions,
-} from '@modern-js/builder-shared';
-import { createCompiler } from './createCompiler';
-import { initConfigs, InitConfigsOptions } from './initConfigs';
-import type { Compiler, MultiCompiler } from '../types';
-import { getDevMiddleware } from './devMiddleware';
-
-type ServerOptions = Exclude;
-
-export async function createDevServer(
- options: InitConfigsOptions,
- port: number,
- serverOptions: ServerOptions,
- customCompiler?: Compiler | MultiCompiler,
-) {
- const { Server } = await import('@modern-js/server');
-
- let compiler: Compiler | MultiCompiler;
- if (customCompiler) {
- compiler = customCompiler;
- } else {
- const { rspackConfigs } = await initConfigs(options);
- compiler = await createCompiler({
- context: options.context,
- rspackConfigs,
- });
- }
-
- debug('create dev server');
-
- const builderConfig = options.context.config;
- const { config, devConfig } = await getDevServerOptions({
- builderConfig,
- serverOptions,
- port,
- });
-
- const server = new Server({
- pwd: options.context.rootPath,
- devMiddleware: getDevMiddleware(compiler),
- ...serverOptions,
- dev: devConfig,
- config,
- });
-
- debug('create dev server done');
-
- return server;
-}
-
-export async function startDevServer(
- options: InitConfigsOptions,
- startDevServerOptions: StartDevServerOptions = {},
-) {
- return baseStartDevServer(
- options,
- (
- options: InitConfigsOptions,
- port: number,
- serverOptions: ServerOptions,
- compiler: StartDevServerOptions['compiler'],
- ) =>
- createDevServer(
- options,
- port,
- serverOptions,
- compiler as unknown as Compiler,
- ),
- startDevServerOptions,
- );
-}
diff --git a/packages/builder/builder-rspack-provider/src/index.ts b/packages/builder/builder-rspack-provider/src/index.ts
deleted file mode 100644
index 5b14999767bf..000000000000
--- a/packages/builder/builder-rspack-provider/src/index.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-export { getRspackVersion } from './shared/rspackVersion';
-export { builderRspackProvider } from './provider';
-export type { BuilderRspackProvider } from './provider';
-
-export type {
- // Config Types
- BuilderConfig,
- NormalizedConfig,
- DevConfig,
- OutputConfig,
- ToolsConfig,
- SourceConfig,
- SecurityConfig,
- PerformanceConfig,
-
- // Hook Callback Types
- ModifyRspackConfigFn,
- ModifyRspackConfigUtils,
-
- // Plugin Types
- BuilderPluginAPI,
-
- // Rspack
- Rspack,
- RspackConfig,
- Compiler as RspackCompiler,
- MultiCompiler as RspackMultiCompiler,
-} from './types';
diff --git a/packages/builder/builder-rspack-provider/src/plugins/babel.ts b/packages/builder/builder-rspack-provider/src/plugins/babel.ts
deleted file mode 100644
index 2178f2408420..000000000000
--- a/packages/builder/builder-rspack-provider/src/plugins/babel.ts
+++ /dev/null
@@ -1,126 +0,0 @@
-import {
- mergeRegex,
- applyScriptCondition,
- JS_REGEX,
- TS_REGEX,
-} from '@modern-js/builder-shared';
-import { cloneDeep, isEqual } from '@modern-js/utils/lodash';
-import { BuilderPlugin, NormalizedConfig } from '../types';
-import type { BabelOptions } from '@modern-js/types';
-
-/**
- * The `@babel/preset-typescript` default options.
- */
-export const DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS = {
- allowNamespaces: true,
- allExtensions: true,
- allowDeclareFields: true,
- // aligns Babel's behavior with TypeScript's default behavior.
- // https://babeljs.io/docs/en/babel-preset-typescript#optimizeconstenums
- optimizeConstEnums: true,
- isTSX: true,
-};
-
-export const builderPluginBabel = (): BuilderPlugin => ({
- name: 'builder-plugin-babel',
- setup(api) {
- api.modifyBundlerChain(
- async (chain, { CHAIN_ID, isProd, getCompiledPath }) => {
- const config = api.getNormalizedConfig();
- if (!config.tools.babel) {
- // we would not use babel loader in rspack, unless user need to use.
- return;
- }
-
- const { applyUserBabelConfig } = await import('@modern-js/utils');
-
- const getBabelOptions = (config: NormalizedConfig) => {
- // 1. Create babel utils function about include/exclude,
- const includes: Array = [];
- const excludes: Array = [];
-
- const babelUtils = {
- addIncludes(items: string | RegExp | Array) {
- if (Array.isArray(items)) {
- includes.push(...items);
- } else {
- includes.push(items);
- }
- },
- addExcludes(items: string | RegExp | Array) {
- if (Array.isArray(items)) {
- excludes.push(...items);
- } else {
- excludes.push(items);
- }
- },
- };
-
- const baseConfig = {
- plugins: [],
- presets: [
- [
- require.resolve('@babel/preset-typescript'),
- DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS,
- ],
- ],
- };
-
- const userBabelConfig = applyUserBabelConfig(
- cloneDeep(baseConfig),
- config.tools.babel,
- babelUtils,
- );
-
- const notModify =
- isEqual(baseConfig, userBabelConfig) &&
- !includes?.length &&
- !excludes?.length;
-
- if (notModify) {
- return {};
- }
-
- const babelOptions: BabelOptions = {
- babelrc: false,
- configFile: false,
- compact: isProd,
- ...userBabelConfig,
- };
-
- return {
- babelOptions,
- includes,
- excludes,
- };
- };
-
- const {
- babelOptions,
- includes = [],
- excludes = [],
- } = getBabelOptions(config);
-
- if (!babelOptions) {
- return;
- }
-
- const rule = chain.module.rule(CHAIN_ID.RULE.JS);
-
- applyScriptCondition({
- rule,
- config,
- context: api.context,
- includes,
- excludes,
- });
-
- rule
- .test(mergeRegex(JS_REGEX, TS_REGEX))
- .use(CHAIN_ID.USE.BABEL)
- .loader(getCompiledPath('babel-loader'))
- .options(babelOptions);
- },
- );
- },
-});
diff --git a/packages/builder/builder-rspack-provider/src/plugins/basic.ts b/packages/builder/builder-rspack-provider/src/plugins/basic.ts
deleted file mode 100644
index 04e9fa7ea14d..000000000000
--- a/packages/builder/builder-rspack-provider/src/plugins/basic.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import type { BuilderPlugin } from '../types';
-import { applyBuilderBasicPlugin } from '@modern-js/builder-shared';
-
-/**
- * Provide some basic configs of rspack
- */
-export const builderPluginBasic = (): BuilderPlugin => ({
- name: 'builder-plugin-basic',
-
- setup(api) {
- applyBuilderBasicPlugin(api);
- },
-});
diff --git a/packages/builder/builder-rspack-provider/src/plugins/css.ts b/packages/builder/builder-rspack-provider/src/plugins/css.ts
deleted file mode 100644
index 1792894d96ea..000000000000
--- a/packages/builder/builder-rspack-provider/src/plugins/css.ts
+++ /dev/null
@@ -1,291 +0,0 @@
-import {
- getBrowserslistWithDefault,
- isUseCssExtract,
- isUseCssSourceMap,
- CSS_REGEX,
- CSS_MODULES_REGEX,
- getCssLoaderOptions,
- setConfig,
- logger,
- getCssModulesAutoRule,
- getPostcssConfig,
- getCssModuleLocalIdentName,
- resolvePackage,
- type BundlerChain,
- type BuilderContext,
- type StyleLoaderOptions,
- type ModifyBundlerChainUtils,
-} from '@modern-js/builder-shared';
-import path from 'path';
-import type {
- BuilderPlugin,
- NormalizedConfig,
- RspackRule,
- RuleSetRule,
-} from '../types';
-import { getCompiledPath } from '../shared';
-
-export const enableNativeCss = (config: NormalizedConfig) =>
- !config.output.disableCssExtract;
-
-export async function applyBaseCSSRule({
- rule,
- config,
- context,
- utils: { target, isProd, isServer, isWebWorker, CHAIN_ID },
- importLoaders = 1,
-}: {
- rule: ReturnType;
- config: NormalizedConfig;
- context: BuilderContext;
- utils: ModifyBundlerChainUtils;
- importLoaders?: number;
-}) {
- // 1. Check user config
- const enableExtractCSS = isUseCssExtract(config, target);
- const enableSourceMap = isUseCssSourceMap(config);
- const enableCSSModuleTS = Boolean(config.output.enableCssModuleTSDeclaration);
- const { applyOptionsChain } = await import('@modern-js/utils');
-
- const browserslist = await getBrowserslistWithDefault(
- context.rootPath,
- config,
- target,
- );
-
- const enableCssMinify = !enableExtractCSS && isProd;
-
- // when disableExtractCSS, use css-loader + style-loader
- if (!enableNativeCss(config)) {
- const localIdentName = getCssModuleLocalIdentName(config, isProd);
-
- const cssLoaderOptions = await getCssLoaderOptions({
- config,
- enableSourceMap,
- importLoaders,
- isServer,
- isWebWorker,
- localIdentName,
- });
-
- if (!isServer && !isWebWorker) {
- const styleLoaderOptions = applyOptionsChain(
- {
- // todo: hmr does not work while esModule is true
- // @ts-expect-error
- esModule: false,
- },
- config.tools.styleLoader,
- );
- rule
- .use(CHAIN_ID.USE.STYLE)
- .loader(require.resolve('style-loader'))
- .options(styleLoaderOptions)
- .end();
-
- // use css-modules-typescript-loader
- if (enableCSSModuleTS && cssLoaderOptions.modules) {
- rule
- .use(CHAIN_ID.USE.CSS_MODULES_TS)
- .loader(
- resolvePackage(
- '@modern-js/builder-shared/css-modules-typescript-loader',
- __dirname,
- ),
- )
- .options({
- modules: cssLoaderOptions.modules,
- })
- .end();
- }
- } else {
- rule
- .use(CHAIN_ID.USE.IGNORE_CSS)
- .loader(
- resolvePackage(
- '@modern-js/builder-shared/ignore-css-loader',
- __dirname,
- ),
- )
- .end();
- }
-
- rule
- .use(CHAIN_ID.USE.CSS)
- .loader(getCompiledPath('css-loader'))
- .options(cssLoaderOptions)
- .end();
- } else {
- // can not get experiment.css result, so we fake a css-modules-typescript-pre-loader
- if (!isServer && !isWebWorker && enableCSSModuleTS) {
- const { cssModules, disableCssModuleExtension } = config.output;
-
- const cssModulesAuto = getCssModulesAutoRule(
- cssModules,
- disableCssModuleExtension,
- );
-
- rule
- .use(CHAIN_ID.USE.CSS_MODULES_TS)
- .loader(
- path.resolve(
- __dirname,
- '../rspackLoader/css-modules-typescript-pre-loader',
- ),
- )
- .options({
- modules: {
- exportLocalsConvention: cssModules.exportLocalsConvention,
- auto: cssModulesAuto,
- },
- })
- .end();
- }
-
- rule.type('css');
- }
-
- if (!isServer && !isWebWorker) {
- const postcssLoaderOptions = await getPostcssConfig({
- enableSourceMap,
- browserslist,
- config,
- enableCssMinify,
- });
-
- rule
- .use(CHAIN_ID.USE.POSTCSS)
- .loader(getCompiledPath('postcss-loader'))
- .options(postcssLoaderOptions)
- .end();
- }
-
- // CSS imports should always be treated as sideEffects
- rule.merge({ sideEffects: true });
-
- // Enable preferRelative by default, which is consistent with the default behavior of css-loader
- // see: https://github.com/webpack-contrib/css-loader/blob/579fc13/src/plugins/postcss-import-parser.js#L234
- rule.resolve.preferRelative(true);
-}
-
-/**
- * Use type: "css/module" rule instead of css-loader modules.auto config
- *
- * applyCSSModuleRule in modifyRspackConfig, so that other plugins can easily adjust css rule in Chain.
- */
-export const applyCSSModuleRule = (
- rules: RspackRule[] | undefined,
- ruleTest: RegExp,
- config: NormalizedConfig,
-) => {
- if (!rules || !enableNativeCss(config)) {
- return;
- }
-
- const ruleIndex = rules.findIndex(
- r => r !== '...' && r && r.test === ruleTest,
- );
-
- if (ruleIndex === -1) {
- return;
- }
-
- const cssModulesAuto = getCssModulesAutoRule(
- config.output.cssModules,
- config.output.disableCssModuleExtension,
- );
-
- if (!cssModulesAuto) {
- return;
- }
-
- const rule = rules[ruleIndex] as RuleSetRule;
-
- const { test, type, ...rest } = rule;
-
- rules[ruleIndex] = {
- test: ruleTest,
- oneOf: [
- {
- ...rest,
- test:
- typeof cssModulesAuto !== 'boolean'
- ? cssModulesAuto
- : // auto: true
- CSS_MODULES_REGEX,
- type: 'css/module',
- },
- {
- ...rest,
- type: 'css',
- },
- ],
- };
-};
-
-export const builderPluginCss = (): BuilderPlugin => {
- return {
- name: 'builder-plugin-css',
- setup(api) {
- api.modifyBundlerChain(async (chain, utils) => {
- const config = api.getNormalizedConfig();
-
- const rule = chain.module.rule(utils.CHAIN_ID.RULE.CSS);
- rule.test(CSS_REGEX);
-
- await applyBaseCSSRule({
- rule,
- utils,
- config,
- context: api.context,
- });
-
- const enableSourceMap = isUseCssSourceMap(config);
- const enableExtractCSS = isUseCssExtract(config, utils.target);
-
- // TODO: there is no switch to turn off experiments.css sourcemap in rspack, so we manually remove css sourcemap in builder
- if (!enableSourceMap && enableExtractCSS) {
- const { RemoveCssSourcemapPlugin } = await import(
- '../rspackPlugin/removeCssSourcemapPlugin'
- );
- chain
- .plugin('remove-css-sourcemap')
- .use(RemoveCssSourcemapPlugin, [utils.HtmlPlugin]);
- }
- });
- api.modifyRspackConfig(
- async (rspackConfig, { isProd, isServer, isWebWorker }) => {
- const config = api.getNormalizedConfig();
-
- if (!enableNativeCss(config)) {
- setConfig(rspackConfig, 'experiments.css', false);
- return;
- }
-
- let localIdentName =
- config.output.cssModuleLocalIdentName ||
- // Using shorter classname in production to reduce bundle size
- (isProd ? '[local]-[hash:6]' : '[path][name]__[local]-[hash:6]');
-
- if (localIdentName.includes(':base64')) {
- logger.warn(
- `Custom hashDigest in output.cssModuleLocalIdentName is currently not supported when using Rspack, the 'base64' will be ignored.`,
- );
- localIdentName = localIdentName.replace(':base64', '');
- }
-
- // need use type: "css/module" rule instead of modules.auto config
- setConfig(rspackConfig, 'builtins.css.modules', {
- localsConvention: config.output.cssModules.exportLocalsConvention,
- localIdentName,
- exportsOnly: isServer || isWebWorker,
- });
-
- const rules = rspackConfig.module?.rules;
-
- applyCSSModuleRule(rules, CSS_REGEX, config);
- },
- );
- },
- };
-};
diff --git a/packages/builder/builder-rspack-provider/src/plugins/fallback.ts b/packages/builder/builder-rspack-provider/src/plugins/fallback.ts
deleted file mode 100644
index affaf5339ea6..000000000000
--- a/packages/builder/builder-rspack-provider/src/plugins/fallback.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-import { join } from 'path';
-import {
- getDistPath,
- getFilename,
- setConfig,
- resourceRuleFallback,
-} from '@modern-js/builder-shared';
-import type { BuilderPlugin } from '../types';
-
-export const builderPluginFallback = (): BuilderPlugin => ({
- name: 'builder-plugin-fallback',
-
- setup(api) {
- api.modifyRspackConfig((config, { isProd }) => {
- const builderConfig = api.getNormalizedConfig();
-
- if (!builderConfig.output.enableAssetFallback) {
- return;
- }
-
- const distDir = getDistPath(builderConfig.output, 'media');
- const filename = getFilename(builderConfig.output, 'media', isProd);
-
- setConfig(config, 'output.assetModuleFilename', join(distDir, filename));
-
- if (!config.module) {
- return;
- }
-
- setConfig(
- config,
- 'module.rules',
- // Rspack RuleSetRule is not exactly aligned with webpack. But it doesn't matter in resourceRuleFallback.
- // @ts-expect-error
- resourceRuleFallback(config.module?.rules),
- );
- });
- },
-});
diff --git a/packages/builder/builder-rspack-provider/src/plugins/hmr.ts b/packages/builder/builder-rspack-provider/src/plugins/hmr.ts
deleted file mode 100644
index 6ed30e4cfa74..000000000000
--- a/packages/builder/builder-rspack-provider/src/plugins/hmr.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import type { BuilderPlugin } from '../types';
-
-import { setConfig, isUsingHMR } from '@modern-js/builder-shared';
-
-export const builderPluginHMR = (): BuilderPlugin => ({
- name: 'builder-plugin-hmr',
-
- setup(api) {
- api.modifyRspackConfig((rspackConfig, utils) => {
- const config = api.getNormalizedConfig();
-
- const usingHMR = isUsingHMR(config, utils);
-
- setConfig(rspackConfig, 'devServer.hot', usingHMR);
- });
- },
-});
diff --git a/packages/builder/builder-rspack-provider/src/plugins/less.ts b/packages/builder/builder-rspack-provider/src/plugins/less.ts
deleted file mode 100644
index bdf8b0cd7ec1..000000000000
--- a/packages/builder/builder-rspack-provider/src/plugins/less.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-import type { BuilderPlugin } from '../types';
-import {
- isUseCssSourceMap,
- LESS_REGEX,
- getLessLoaderOptions,
-} from '@modern-js/builder-shared';
-
-export function builderPluginLess(): BuilderPlugin {
- return {
- name: 'builder-plugin-less',
- setup(api) {
- api.modifyBundlerChain(async (chain, utils) => {
- const config = api.getNormalizedConfig();
- const { applyBaseCSSRule } = await import('./css');
-
- const rule = chain.module
- .rule(utils.CHAIN_ID.RULE.LESS)
- .test(LESS_REGEX);
-
- await applyBaseCSSRule({
- rule,
- utils,
- config,
- context: api.context,
- importLoaders: 2,
- });
-
- const { excludes, options } = await getLessLoaderOptions(
- config.tools.less,
- isUseCssSourceMap(config),
- );
-
- excludes.forEach(item => {
- rule.exclude.add(item);
- });
-
- await applyBaseCSSRule({
- rule,
- utils,
- config,
- context: api.context,
- });
-
- rule
- .use(utils.CHAIN_ID.USE.LESS)
- .loader(utils.getCompiledPath('less-loader'))
- .options(options);
- });
-
- api.modifyRspackConfig(async rspackConfig => {
- const { applyCSSModuleRule } = await import('./css');
- const config = api.getNormalizedConfig();
-
- const rules = rspackConfig.module?.rules;
-
- applyCSSModuleRule(rules, LESS_REGEX, config);
- });
- },
- };
-}
diff --git a/packages/builder/builder-rspack-provider/src/plugins/manifest.ts b/packages/builder/builder-rspack-provider/src/plugins/manifest.ts
deleted file mode 100644
index 26f713b9d045..000000000000
--- a/packages/builder/builder-rspack-provider/src/plugins/manifest.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import type { BuilderPlugin } from '../types';
-import { generateManifest } from '@modern-js/builder-shared';
-
-export const builderPluginManifest = (): BuilderPlugin => ({
- name: 'builder-plugin-manifest',
-
- setup(api) {
- api.modifyBundlerChain(async (chain, { CHAIN_ID, target }) => {
- const config = api.getNormalizedConfig();
-
- if (!config.output.enableAssetManifest) {
- return;
- }
-
- const { WebpackManifestPlugin } = await import('rspack-manifest-plugin');
- const publicPath = chain.output.get('publicPath');
-
- chain.plugin(CHAIN_ID.PLUGIN.MANIFEST).use(WebpackManifestPlugin, [
- {
- fileName:
- target === 'web'
- ? 'asset-manifest.json'
- : `asset-manifest-${target}.json`,
- publicPath,
- generate: generateManifest,
- },
- ]);
- });
- },
-});
diff --git a/packages/builder/builder-rspack-provider/src/plugins/minimize.ts b/packages/builder/builder-rspack-provider/src/plugins/minimize.ts
deleted file mode 100644
index bdc21ab3a8bc..000000000000
--- a/packages/builder/builder-rspack-provider/src/plugins/minimize.ts
+++ /dev/null
@@ -1,66 +0,0 @@
-import { CHAIN_ID } from '@modern-js/utils/chain-id';
-import { applyCSSMinimizer, BundlerChain } from '@modern-js/builder-shared';
-import type {
- BuilderPlugin,
- NormalizedConfig,
- RspackBuiltinsConfig,
-} from '../types';
-import { SwcJsMinimizerRspackPlugin } from '@rspack/core';
-
-export async function applyJSMinimizer(
- chain: BundlerChain,
- config: NormalizedConfig,
-) {
- const options: RspackBuiltinsConfig['minifyOptions'] = {};
-
- const { removeConsole } = config.performance;
-
- if (removeConsole === true) {
- options.dropConsole = true;
- } else if (Array.isArray(removeConsole)) {
- const pureFuncs = removeConsole.map(method => `console.${method}`);
- options.pureFuncs = pureFuncs;
- }
-
- switch (config.output.legalComments) {
- case 'inline':
- options.comments = 'some';
- options.extractComments = false;
- break;
- case 'linked':
- options.extractComments = true;
- break;
- case 'none':
- options.comments = false;
- options.extractComments = false;
- break;
- default:
- break;
- }
-
- options.asciiOnly = config.output.charset === 'ascii';
-
- chain.optimization
- .minimizer(CHAIN_ID.MINIMIZER.JS)
- .use(SwcJsMinimizerRspackPlugin, [options])
- .end();
-}
-
-export const builderPluginMinimize = (): BuilderPlugin => ({
- name: 'builder-plugin-minimize',
-
- setup(api) {
- api.modifyBundlerChain(async (chain, { isProd }) => {
- const config = api.getNormalizedConfig();
- const isMinimize = isProd && !config.output.disableMinimize;
-
- // set minimize to allow users to disable minimize
- chain.optimization.minimize(isMinimize);
-
- if (isMinimize) {
- await applyJSMinimizer(chain, config);
- await applyCSSMinimizer(chain, config);
- }
- });
- },
-});
diff --git a/packages/builder/builder-rspack-provider/src/plugins/output.ts b/packages/builder/builder-rspack-provider/src/plugins/output.ts
deleted file mode 100644
index 599658d4befa..000000000000
--- a/packages/builder/builder-rspack-provider/src/plugins/output.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-import { posix } from 'path';
-import {
- getDistPath,
- getFilename,
- applyBuilderOutputPlugin,
-} from '@modern-js/builder-shared';
-import type { BuilderPlugin } from '../types';
-
-export const builderPluginOutput = (): BuilderPlugin => ({
- name: 'builder-plugin-output',
-
- setup(api) {
- applyBuilderOutputPlugin(api);
-
- api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
- const config = api.getNormalizedConfig();
-
- if (config.output.copy) {
- const { CopyRspackPlugin } = await import('@rspack/core');
- const { copy } = config.output;
- const options = Array.isArray(copy) ? { patterns: copy } : copy;
-
- chain.plugin(CHAIN_ID.PLUGIN.COPY).use(CopyRspackPlugin, [options]);
- }
- });
-
- api.modifyRspackConfig(async (rspackConfig, { isProd }) => {
- const config = api.getNormalizedConfig();
-
- const cssPath = getDistPath(config.output, 'css');
- const cssFilename = getFilename(config.output, 'css', isProd);
-
- rspackConfig.output ||= {};
- rspackConfig.output.cssFilename = posix.join(cssPath, cssFilename);
- rspackConfig.output.cssChunkFilename = posix.join(
- cssPath,
- `async/${cssFilename}`,
- );
- });
- },
-});
diff --git a/packages/builder/builder-rspack-provider/src/plugins/progress.ts b/packages/builder/builder-rspack-provider/src/plugins/progress.ts
deleted file mode 100644
index b972e800a0f6..000000000000
--- a/packages/builder/builder-rspack-provider/src/plugins/progress.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import { TARGET_ID_MAP } from '@modern-js/builder-shared';
-import type { BuilderPlugin } from '../types';
-
-export const builderPluginProgress = (): BuilderPlugin => ({
- name: 'builder-plugin-progress',
- setup(api) {
- api.modifyBundlerChain(async (chain, { target, CHAIN_ID }) => {
- const config = api.getNormalizedConfig();
- const options = config.dev.progressBar;
-
- if (!options) {
- return;
- }
-
- const { ProgressPlugin } = await import('@rspack/core');
-
- chain.plugin(CHAIN_ID.PLUGIN.PROGRESS).use(ProgressPlugin, [
- {
- prefix: TARGET_ID_MAP[target],
- ...(options === true ? {} : options),
- },
- ]);
- });
- },
-});
diff --git a/packages/builder/builder-rspack-provider/src/plugins/pug.ts b/packages/builder/builder-rspack-provider/src/plugins/pug.ts
deleted file mode 100644
index 018dbfd90588..000000000000
--- a/packages/builder/builder-rspack-provider/src/plugins/pug.ts
+++ /dev/null
@@ -1,53 +0,0 @@
-import type { BuilderPlugin } from '../types';
-import type { PugOptions } from '@modern-js/builder-shared';
-import { getCompiledPath } from '../shared';
-
-const getPugTemplateCompiler = (userOptions: PugOptions) => ({
- async compile(
- content: string,
- compileOptions: {
- filename: string;
- },
- ) {
- const options = {
- filename: compileOptions.filename,
- doctype: 'html',
- compileDebug: false,
- ...userOptions,
- };
- const pug = require(getCompiledPath('pug'));
- return `${pug.compileClient(content, options)};\ntemplate;`;
- },
-});
-
-export const builderPluginPug = (): BuilderPlugin => ({
- name: 'builder-plugin-pug',
-
- setup(api) {
- api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
- const config = api.getNormalizedConfig();
- const { pug } = config.tools;
- if (!pug) {
- return;
- }
-
- const entries = chain.entryPoints.entries() || {};
- const entryNames = Object.keys(entries);
-
- const { applyOptionsChain } = await import('@modern-js/utils');
-
- const pugOptions = applyOptionsChain({}, pug === true ? {} : pug);
- // not support childCompiler in Rspack html-plugin, use templateCompiler instead.
- const templateCompiler = getPugTemplateCompiler(pugOptions);
-
- entryNames.forEach(entry => {
- chain.plugin(`${CHAIN_ID.PLUGIN.HTML}-${entry}`).tap(options => {
- if (options[0]?.template.endsWith('.pug')) {
- options[0].templateCompiler = templateCompiler;
- }
- return options;
- });
- });
- });
- },
-});
diff --git a/packages/builder/builder-rspack-provider/src/plugins/react.ts b/packages/builder/builder-rspack-provider/src/plugins/react.ts
deleted file mode 100644
index ba3aa0256a55..000000000000
--- a/packages/builder/builder-rspack-provider/src/plugins/react.ts
+++ /dev/null
@@ -1,77 +0,0 @@
-import type { BuilderPlugin, Rspack } from '../types';
-import {
- setConfig,
- isUsingHMR,
- isClientCompiler,
- isProd,
-} from '@modern-js/builder-shared';
-
-// Not needed in Rsbuild
-const setupCompiler = (compiler: Rspack.Compiler) => {
- if (!isClientCompiler(compiler)) {
- return;
- }
-
- // fix react refresh not work in Micro front-end projects when use legacy transformByDefault
- // https://github.com/web-infra-dev/rspack/pull/4628/files#diff-81b3afbbf84bc30f7332fb7bd43d52a4544ae16190d41b4b0fe8e8d4c9ca89e0R59
- const definedModules = {
- // For Mutiple Instance Mode
- __react_refresh_library__: JSON.stringify(
- compiler.webpack.Template.toIdentifier(
- compiler.options.output.uniqueName || compiler.options.output.library,
- ),
- ),
- };
- new compiler.webpack.DefinePlugin(definedModules).apply(compiler);
-};
-
-export const builderPluginReact = (): BuilderPlugin => ({
- name: 'builder-plugin-react',
-
- setup(api) {
- api.modifyRspackConfig(async (rspackConfig, utils) => {
- const config = api.getNormalizedConfig();
-
- const usingHMR = isUsingHMR(config, utils);
-
- setConfig(rspackConfig, 'builtins.react', {
- development: !utils.isProd,
- refresh: usingHMR,
- // https://swc.rs/docs/configuration/compilation#jsctransformreactruntime
- runtime: 'automatic',
- });
- });
-
- api.modifyBundlerChain(async (chain, utils) => {
- const config = api.getNormalizedConfig();
-
- const usingHMR = isUsingHMR(config, utils);
-
- const { bundler } = utils;
-
- if (usingHMR) {
- chain.plugin('ReactRefreshRuntime').use(bundler.ProvidePlugin, [
- {
- $ReactRefreshRuntime$: [
- require.resolve('@rspack/plugin-react-refresh/react-refresh'),
- ],
- },
- ]);
- }
- });
-
- api.onAfterCreateCompiler(({ compiler: multiCompiler }) => {
- if (isProd()) {
- return;
- }
-
- if ((multiCompiler as Rspack.MultiCompiler).compilers) {
- (multiCompiler as Rspack.MultiCompiler).compilers.forEach(
- setupCompiler,
- );
- } else {
- setupCompiler(multiCompiler as Rspack.Compiler);
- }
- });
- },
-});
diff --git a/packages/builder/builder-rspack-provider/src/plugins/resolve.ts b/packages/builder/builder-rspack-provider/src/plugins/resolve.ts
deleted file mode 100644
index 110a69f83792..000000000000
--- a/packages/builder/builder-rspack-provider/src/plugins/resolve.ts
+++ /dev/null
@@ -1,48 +0,0 @@
-import type { BuilderPlugin } from '../types';
-import {
- setConfig,
- applyBuilderResolvePlugin,
-} from '@modern-js/builder-shared';
-
-export const builderPluginResolve = (): BuilderPlugin => ({
- name: 'builder-plugin-resolve',
-
- setup(api) {
- applyBuilderResolvePlugin(api);
-
- api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
- const config = api.getNormalizedConfig();
-
- if (
- chain.module.rules.get(CHAIN_ID.RULE.JS_DATA_URI) &&
- config.source.compileJsDataURI
- ) {
- chain.module
- .rule(CHAIN_ID.RULE.JS_DATA_URI)
- .resolve.set('fullySpecified', false);
- }
- });
-
- api.modifyRspackConfig(async (rspackConfig, { isServer }) => {
- const isTsProject = Boolean(api.context.tsconfigPath);
- const config = api.getNormalizedConfig();
-
- if (isTsProject && config.source.aliasStrategy === 'prefer-tsconfig') {
- setConfig(
- rspackConfig,
- 'resolve.tsConfigPath',
- api.context.tsconfigPath,
- );
- }
-
- if (isServer) {
- // FIXME:
- // When targe = node, we no need to specify conditionsNames.
- // We gueess the webpack would auto specify refrence to target.
- // Rspack has't the action, so we need manually specify.
- const nodeConditionNames = ['require', 'node'];
- setConfig(rspackConfig, 'resolve.conditionNames', nodeConditionNames);
- }
- });
- },
-});
diff --git a/packages/builder/builder-rspack-provider/src/plugins/rspack-profile.ts b/packages/builder/builder-rspack-provider/src/plugins/rspack-profile.ts
deleted file mode 100644
index 0acc2609601c..000000000000
--- a/packages/builder/builder-rspack-provider/src/plugins/rspack-profile.ts
+++ /dev/null
@@ -1,103 +0,0 @@
-import type { BuilderPlugin } from '../types';
-import path from 'path';
-import {
- experimental_registerGlobalTrace as registerGlobalTrace,
- experimental_cleanupGlobalTrace as cleanupGlobalTrace,
-} from '@rspack/core';
-// eslint-disable-next-line node/no-unsupported-features/node-builtins
-import inspector from 'inspector';
-// eslint-disable-next-line @typescript-eslint/no-restricted-imports
-import { fs } from '@modern-js/utils';
-import { logger } from '@modern-js/builder-shared';
-
-export const stopProfiler = (
- output: string,
- profileSession?: inspector.Session,
-) => {
- if (!profileSession) {
- return;
- }
- profileSession.post('Profiler.stop', (error, param) => {
- if (error) {
- logger.error('Failed to generate JS CPU profile:', error);
- return;
- }
- fs.writeFileSync(output, JSON.stringify(param.profile));
- });
-};
-
-// Reference rspack-cli
-// https://github.com/modern-js-dev/rspack/blob/509abcfc523bc20125459f5d428dc1645751700c/packages/rspack-cli/src/utils/profile.ts
-export const builderPluginRspackProfile = (): BuilderPlugin => ({
- name: 'builder-plugin-rspack-profile',
-
- setup(api) {
- /**
- * RSPACK_PROFILE=ALL
- * RSPACK_PROFILE=TRACE|CPU|LOGGING
- */
- const RSPACK_PROFILE = process.env.RSPACK_PROFILE?.toUpperCase();
-
- if (!RSPACK_PROFILE) {
- return;
- }
-
- const timestamp = Date.now();
- const profileDir = path.join(
- api.context.distPath,
- `rspack-profile-${timestamp}`,
- );
-
- let profileSession: inspector.Session | undefined;
-
- const enableProfileTrace =
- RSPACK_PROFILE === 'ALL' || RSPACK_PROFILE.includes('TRACE');
-
- const enableCPUProfile =
- RSPACK_PROFILE === 'ALL' || RSPACK_PROFILE.includes('CPU');
-
- const enableLogging =
- RSPACK_PROFILE === 'ALL' || RSPACK_PROFILE.includes('LOGGING');
-
- const traceFilePath = path.join(profileDir, 'trace.json');
- const cpuProfilePath = path.join(profileDir, 'jscpuprofile.json');
- const loggingFilePath = path.join(profileDir, 'logging.json');
-
- const onStart = () => {
- fs.ensureDirSync(profileDir);
-
- if (enableProfileTrace) {
- registerGlobalTrace('trace', 'chrome', traceFilePath);
- }
-
- if (enableCPUProfile) {
- profileSession = new inspector.Session();
- profileSession.connect();
- profileSession.post('Profiler.enable');
- profileSession.post('Profiler.start');
- }
- };
-
- api.onBeforeBuild(onStart);
- api.onBeforeStartDevServer(onStart);
-
- api.onAfterBuild(async ({ stats }) => {
- if (enableLogging && stats) {
- const logging = stats.toJson({
- all: false,
- logging: 'verbose',
- loggingTrace: true,
- });
- fs.writeFileSync(loggingFilePath, JSON.stringify(logging));
- }
- });
-
- api.onExit(() => {
- enableProfileTrace && cleanupGlobalTrace();
-
- stopProfiler(cpuProfilePath, profileSession);
-
- logger.info(`Saved Rspack profile file to ${profileDir}`);
- });
- },
-});
diff --git a/packages/builder/builder-rspack-provider/src/plugins/sass.ts b/packages/builder/builder-rspack-provider/src/plugins/sass.ts
deleted file mode 100644
index 3bce0e9cd90f..000000000000
--- a/packages/builder/builder-rspack-provider/src/plugins/sass.ts
+++ /dev/null
@@ -1,70 +0,0 @@
-import {
- SASS_REGEX,
- getSassLoaderOptions,
- patchCompilerGlobalLocation,
- getResolveUrlJoinFn,
-} from '@modern-js/builder-shared';
-import type { BuilderPlugin } from '../types';
-
-export function builderPluginSass(): BuilderPlugin {
- return {
- name: 'builder-plugin-sass',
- async setup(api) {
- api.onAfterCreateCompiler(({ compiler }) => {
- patchCompilerGlobalLocation(compiler);
- });
-
- api.modifyBundlerChain(async (chain, utils) => {
- const config = api.getNormalizedConfig();
- const { applyBaseCSSRule } = await import('./css');
-
- const { excludes, options } = await getSassLoaderOptions(
- config.tools.sass,
- // source-maps required for loaders preceding resolve-url-loader
- true,
- );
-
- const rule = chain.module
- .rule(utils.CHAIN_ID.RULE.SASS)
- .test(SASS_REGEX);
-
- excludes.forEach(item => {
- rule.exclude.add(item);
- });
-
- await applyBaseCSSRule({
- rule,
- utils,
- config,
- context: api.context,
- // postcss-loader, resolve-url-loader, sass-loader
- importLoaders: 3,
- });
-
- rule
- .use(utils.CHAIN_ID.USE.RESOLVE_URL_LOADER_FOR_SASS)
- .loader(utils.getCompiledPath('resolve-url-loader'))
- .options({
- join: await getResolveUrlJoinFn(),
- // 'resolve-url-loader' relies on 'adjust-sourcemap-loader',
- // it has performance regression issues in some scenarios,
- // so we need to disable the sourceMap option.
- sourceMap: false,
- })
- .end()
- .use(utils.CHAIN_ID.USE.SASS)
- .loader(utils.getCompiledPath('sass-loader'))
- .options(options);
- });
-
- api.modifyRspackConfig(async rspackConfig => {
- const { applyCSSModuleRule } = await import('./css');
- const config = api.getNormalizedConfig();
-
- const rules = rspackConfig.module?.rules;
-
- applyCSSModuleRule(rules, SASS_REGEX, config);
- });
- },
- };
-}
diff --git a/packages/builder/builder-rspack-provider/src/plugins/swc.ts b/packages/builder/builder-rspack-provider/src/plugins/swc.ts
deleted file mode 100644
index 08272930da58..000000000000
--- a/packages/builder/builder-rspack-provider/src/plugins/swc.ts
+++ /dev/null
@@ -1,149 +0,0 @@
-import * as path from 'path';
-
-import {
- BuilderTarget,
- getBrowserslistWithDefault,
- logger,
- setConfig,
- isWebTarget,
- addCoreJsEntry,
-} from '@modern-js/builder-shared';
-import type {
- BuilderPlugin,
- BuilderPluginAPI,
- NormalizedConfig,
- RspackConfig,
-} from '../types';
-import { Builtins } from '@rspack/core';
-
-/**
- * Provide some swc configs of rspack
- */
-export const builderPluginSwc = (): BuilderPlugin => ({
- name: 'builder-plugin-swc-rspack',
-
- setup(api) {
- api.modifyBundlerChain(async (chain, { isServer, isServiceWorker }) => {
- const config = api.getNormalizedConfig();
-
- addCoreJsEntry({
- chain,
- config,
- isServer,
- isServiceWorker,
- });
- });
-
- api.modifyRspackConfig(async (rspackConfig, { target }) => {
- const builderConfig = api.getNormalizedConfig();
-
- // Apply decorator and presetEnv
- await applyDefaultConfig(rspackConfig, builderConfig, api, target);
- });
- },
-});
-
-async function applyDefaultConfig(
- rspackConfig: RspackConfig,
- builderConfig: NormalizedConfig,
- api: BuilderPluginAPI,
- target: BuilderTarget,
-) {
- const legacy = !builderConfig.output.enableLatestDecorators;
- /**
- * Swc only enable latestDecorator for JS module, not TS module.
- */
- setConfig(rspackConfig, 'builtins.decorator', {
- legacy,
- emitMetadata: legacy,
- });
-
- rspackConfig.builtins ??= {};
- rspackConfig.builtins.presetEnv ??= {};
-
- await setBrowserslist(
- api.context.rootPath,
- builderConfig,
- target,
- rspackConfig,
- );
-
- /**
- * Enable preset-env polyfill: set rspackConfig.target === 'browserslist'
- */
- if (isWebTarget(target)) {
- const polyfillMode = builderConfig.output.polyfill;
-
- // TODO: remove this when Rspack support `usage` mode
- if (polyfillMode === 'usage') {
- logger.warn(
- 'Cannot use `usage` mode polyfill for now, Rspack will support it soon',
- );
- rspackConfig.builtins.presetEnv.mode = undefined;
- return;
- }
-
- if (polyfillMode === 'off' || polyfillMode === 'ua') {
- rspackConfig.builtins.presetEnv.mode = undefined;
- } else {
- rspackConfig.builtins.presetEnv.mode = polyfillMode;
- /* Apply core-js version and path alias */
- await applyCoreJs(rspackConfig);
- }
- }
-
- applyTransformImport(rspackConfig, builderConfig.source.transformImport);
-}
-
-async function setBrowserslist(
- rootPath: string,
- builderConfig: NormalizedConfig,
- target: BuilderTarget,
- rspackConfig: RspackConfig,
-) {
- const browserslist = await getBrowserslistWithDefault(
- rootPath,
- builderConfig,
- target,
- );
-
- if (browserslist) {
- rspackConfig.builtins!.presetEnv!.targets = browserslist;
- }
-}
-
-async function applyCoreJs(rspackConfig: RspackConfig) {
- const { getCoreJsVersion } = await import('@modern-js/utils');
- const coreJsPath = require.resolve('core-js/package.json');
- const version = getCoreJsVersion(coreJsPath);
-
- rspackConfig.builtins!.presetEnv!.coreJs = version;
-
- rspackConfig.resolve ??= {};
- rspackConfig.resolve.alias ??= {};
- rspackConfig.resolve.alias['core-js'] = path.dirname(coreJsPath);
-}
-
-async function applyTransformImport(
- rspackConfig: RspackConfig,
- pluginImport?: false | Builtins['pluginImport'],
-) {
- if (pluginImport !== false && pluginImport) {
- ensureNoJsFunction(pluginImport);
- rspackConfig.builtins ??= {};
- rspackConfig.builtins.pluginImport ??= [];
- rspackConfig.builtins.pluginImport.push(...pluginImport);
- }
-}
-
-function ensureNoJsFunction(pluginImport: Array>) {
- for (const item of pluginImport) {
- for (const key in item) {
- if (typeof item[key] === 'function') {
- throw new TypeError(
- '`builtins.pluginImport` can not contain Function configuration',
- );
- }
- }
- }
-}
diff --git a/packages/builder/builder-rspack-provider/src/plugins/transition.ts b/packages/builder/builder-rspack-provider/src/plugins/transition.ts
deleted file mode 100644
index 0353e3ea05d1..000000000000
--- a/packages/builder/builder-rspack-provider/src/plugins/transition.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import type { BuilderPlugin } from '../types';
-import { setConfig } from '@modern-js/builder-shared';
-/**
- * Provide some temporary configurations for Rspack early transition
- */
-export const builderPluginTransition = (): BuilderPlugin => ({
- name: 'builder-plugin-transition',
-
- setup(api) {
- process.env.RSPACK_CONFIG_VALIDATE = 'loose-silent';
-
- api.modifyBundlerChain(async (chain, { isProd }) => {
- if (isProd) {
- chain.optimization.chunkIds('deterministic');
- }
- });
-
- api.modifyRspackConfig(config => {
- setConfig(
- config,
- 'experiments.rspackFuture.disableTransformByDefault',
- false,
- );
- });
- },
-});
diff --git a/packages/builder/builder-rspack-provider/src/provider.ts b/packages/builder/builder-rspack-provider/src/provider.ts
deleted file mode 100644
index 8d72b361e204..000000000000
--- a/packages/builder/builder-rspack-provider/src/provider.ts
+++ /dev/null
@@ -1,119 +0,0 @@
-import {
- startProdServer,
- pickBuilderConfig,
- createPublicContext,
- type BuilderProvider,
-} from '@modern-js/builder-shared';
-import chalk from '@modern-js/utils/chalk';
-import { createContext } from './core/createContext';
-import { initConfigs } from './core/initConfigs';
-import { getPluginAPI } from './core/initPlugins';
-import { applyDefaultPlugins } from './shared/plugin';
-import {
- isSatisfyRspackMinimumVersion,
- supportedRspackMinimumVersion,
-} from './shared/rspackVersion';
-import type {
- Compiler,
- RspackConfig,
- BuilderConfig,
- NormalizedConfig,
- MultiCompiler,
-} from './types';
-
-export type BuilderRspackProvider = BuilderProvider<
- BuilderConfig,
- RspackConfig,
- NormalizedConfig,
- Compiler | MultiCompiler
->;
-
-export function builderRspackProvider({
- builderConfig: originalBuilderConfig,
-}: {
- builderConfig: BuilderConfig;
-}): BuilderRspackProvider {
- const builderConfig = pickBuilderConfig(originalBuilderConfig);
-
- return async ({ pluginStore, builderOptions, plugins }) => {
- if (!(await isSatisfyRspackMinimumVersion())) {
- throw new Error(
- `The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${chalk.green(
- supportedRspackMinimumVersion,
- )}`,
- );
- }
-
- const context = await createContext(builderOptions, builderConfig);
- const pluginAPI = getPluginAPI({ context, pluginStore });
-
- context.pluginAPI = pluginAPI;
-
- return {
- bundler: 'rspack',
-
- pluginAPI,
-
- publicContext: createPublicContext(context),
-
- async applyDefaultPlugins() {
- pluginStore.addPlugins(await applyDefaultPlugins(plugins));
- },
-
- async createCompiler() {
- const { createCompiler } = await import('./core/createCompiler');
- const { rspackConfigs } = await initConfigs({
- context,
- pluginStore,
- builderOptions,
- });
-
- // todo: compiler 类型定义
- return createCompiler({
- context,
- rspackConfigs,
- }) as any;
- },
-
- async startDevServer(options) {
- const { startDevServer } = await import('./core/startDevServer');
- return startDevServer(
- { context, pluginStore, builderOptions },
- options,
- );
- },
-
- async serve() {
- return startProdServer(context, context.config);
- },
-
- async build(options) {
- const { build: buildImpl, rspackBuild } = await import('./core/build');
- return buildImpl(
- { context, pluginStore, builderOptions },
- options,
- rspackBuild,
- );
- },
-
- async initConfigs() {
- const { rspackConfigs } = await initConfigs({
- context,
- pluginStore,
- builderOptions,
- });
- return rspackConfigs;
- },
-
- async inspectConfig(inspectOptions) {
- const { inspectConfig } = await import('./core/inspectConfig');
- return inspectConfig({
- context,
- pluginStore,
- builderOptions,
- inspectOptions,
- });
- },
- };
- };
-}
diff --git a/packages/builder/builder-rspack-provider/src/rspackLoader/css-modules-typescript-pre-loader/index.ts b/packages/builder/builder-rspack-provider/src/rspackLoader/css-modules-typescript-pre-loader/index.ts
deleted file mode 100644
index fccac4b99905..000000000000
--- a/packages/builder/builder-rspack-provider/src/rspackLoader/css-modules-typescript-pre-loader/index.ts
+++ /dev/null
@@ -1,102 +0,0 @@
-import cssModulesTypescriptLoader from '@modern-js/builder-shared/css-modules-typescript-loader';
-import {
- isCssModules,
- isInNodeModules,
- CssModules,
-} from '@modern-js/builder-shared';
-import type { LoaderContext } from '@rspack/core';
-import type { PostcssParsePluginOptions } from './postcss-icss-extract-plugin';
-import type { CssModuleLocalsConvention } from '@modern-js/builder-shared';
-
-async function processCss(
- inputSource: string,
- {
- exportLocalsConvention,
- }: {
- exportLocalsConvention: CssModuleLocalsConvention;
- },
-) {
- const { default: postcss } = await import('postcss');
-
- const { default: localByDefault } = await import(
- '@modern-js/builder-shared/postcss-modules-local-by-default'
- );
-
- const { default: modulesScope } = await import(
- '@modern-js/builder-shared/postcss-modules-scope'
- );
-
- const { default: postcssICSSExtractPlugin } = await import(
- './postcss-icss-extract-plugin'
- );
-
- const { default: extractImports } = await import(
- '@modern-js/builder-shared/postcss-modules-extract-imports'
- );
-
- const { default: modulesValues } = await import(
- '@modern-js/builder-shared/postcss-modules-values'
- );
-
- const parserOptions = {
- exportLocalsConvention,
- } as PostcssParsePluginOptions;
-
- // https://github.com/webpack-contrib/css-loader/blob/4673caa4aa68d5fb1127c172b4afd081bd56eb73/src/utils.js#L776
- const pipeline = postcss([
- localByDefault({
- mode: 'local',
- }),
- extractImports(),
- modulesValues,
- modulesScope({
- // scopedName is not important in this scenario
- generateScopedName: (exportName: string) => exportName,
- exportGlobals: false,
- }),
- postcssICSSExtractPlugin(parserOptions),
- ]);
-
- await pipeline.process(inputSource, {
- from: `/fake-css-modules-loader`,
- to: undefined,
- });
-
- return {
- cssModuleKeys: parserOptions.cssModuleKeys,
- };
-}
-
-export default async function (
- this: LoaderContext<{
- modules: Required;
- mode: string;
- }>,
- content: string,
- ...input: any[]
-) {
- if (this.cacheable) {
- this.cacheable();
- }
-
- const filename = this.resourcePath;
- const { modules } = this.getOptions() || {};
- const callback = this.async();
-
- // filter files
- if (!isCssModules(filename, modules) || isInNodeModules(filename)) {
- return callback(null, content, ...input);
- }
-
- // handle css modules like css-loader, but only get cssModuleKeys not modify the source.
- const { cssModuleKeys } = await processCss(content, {
- exportLocalsConvention: modules.exportLocalsConvention,
- });
-
- // @ts-expect-error
- this.cssModuleKeys = cssModuleKeys;
-
- // rspack loader type is not exactly the same as webpack loader type
- // @ts-expect-error
- return cssModulesTypescriptLoader.call(this, content, ...input);
-}
diff --git a/packages/builder/builder-rspack-provider/src/rspackLoader/css-modules-typescript-pre-loader/postcss-icss-extract-plugin.ts b/packages/builder/builder-rspack-provider/src/rspackLoader/css-modules-typescript-pre-loader/postcss-icss-extract-plugin.ts
deleted file mode 100644
index 2ec45c12d69c..000000000000
--- a/packages/builder/builder-rspack-provider/src/rspackLoader/css-modules-typescript-pre-loader/postcss-icss-extract-plugin.ts
+++ /dev/null
@@ -1,64 +0,0 @@
-// @ts-expect-error
-import { extractICSS } from '@modern-js/builder-shared/icss-utils';
-import { camelCase } from '@modern-js/utils/lodash';
-import type { CssModuleLocalsConvention } from '@modern-js/builder-shared';
-
-import type { AcceptedPlugin as PostCSSPlugin } from 'postcss';
-
-const dashesCamelCase = (str: string) =>
- str.replace(/-+(\w)/g, (_match, firstLetter) => firstLetter.toUpperCase());
-
-export type PostcssParsePluginOptions = {
- exportLocalsConvention: CssModuleLocalsConvention;
- cssModuleKeys: string[];
-};
-
-const getExportLocalsConvention = (
- name: string,
- exportLocalsConventionType: CssModuleLocalsConvention,
-) => {
- switch (exportLocalsConventionType) {
- case 'camelCase': {
- const camelName = camelCase(name);
- return camelName === name ? [name] : [name, camelCase(name)];
- }
- case 'camelCaseOnly': {
- return [camelCase(name)];
- }
- case 'dashes': {
- const dashesCamelName = dashesCamelCase(name);
- return dashesCamelName === name ? [name] : [name, dashesCamelCase(name)];
- }
- case 'dashesOnly': {
- return [dashesCamelCase(name)];
- }
- case 'asIs':
- default:
- return [name];
- }
-};
-
-const plugin = (options: PostcssParsePluginOptions): PostCSSPlugin => {
- return {
- postcssPlugin: 'postcss-icss-extract',
- OnceExit(root) {
- const { icssExports } = extractICSS(root);
-
- const cssModuleKeys = Object.keys(icssExports).reduce(
- (total, key) => {
- total.push(
- ...getExportLocalsConvention(key, options.exportLocalsConvention),
- );
- return total;
- },
- [],
- );
-
- options.cssModuleKeys = cssModuleKeys;
- },
- };
-};
-
-plugin.postcss = true;
-
-export default plugin;
diff --git a/packages/builder/builder-rspack-provider/src/rspackPlugin/removeCssSourcemapPlugin.ts b/packages/builder/builder-rspack-provider/src/rspackPlugin/removeCssSourcemapPlugin.ts
deleted file mode 100644
index 652f376a77a1..000000000000
--- a/packages/builder/builder-rspack-provider/src/rspackPlugin/removeCssSourcemapPlugin.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-import type { Compiler, Compilation } from '@rspack/core';
-import type HtmlPlugin from '@rspack/plugin-html';
-import { COMPILATION_PROCESS_STAGE } from '@modern-js/builder-shared';
-
-export class RemoveCssSourcemapPlugin {
- name: string;
-
- htmlPlugin: typeof HtmlPlugin;
-
- constructor(htmlPlugin: typeof HtmlPlugin) {
- this.name = 'RemoveCssSourcemapPlugin';
- this.htmlPlugin = htmlPlugin;
- }
-
- apply(compiler: Compiler) {
- compiler.hooks.compilation.tap(this.name, (compilation: Compilation) => {
- compilation.hooks.processAssets.tap(
- {
- name: this.name,
- stage: COMPILATION_PROCESS_STAGE.PROCESS_ASSETS_STAGE_SUMMARIZE,
- },
- () => {
- Object.keys(compilation.assets).forEach(name => {
- if (name.endsWith('.css.map')) {
- compilation.deleteAsset(name);
- }
- });
- },
- );
- });
- }
-}
diff --git a/packages/builder/builder-rspack-provider/src/shared/constants.ts b/packages/builder/builder-rspack-provider/src/shared/constants.ts
deleted file mode 100644
index 4e3b0f85478c..000000000000
--- a/packages/builder/builder-rspack-provider/src/shared/constants.ts
+++ /dev/null
@@ -1 +0,0 @@
-export const BUILTIN_LOADER = 'builtin:';
diff --git a/packages/builder/builder-rspack-provider/src/shared/fs.ts b/packages/builder/builder-rspack-provider/src/shared/fs.ts
deleted file mode 100644
index 7e92bcb4afa0..000000000000
--- a/packages/builder/builder-rspack-provider/src/shared/fs.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { join } from 'path';
-import {
- getSharedPkgCompiledPath,
- SharedCompiledPkgNames,
-} from '@modern-js/builder-shared';
-// eslint-disable-next-line @typescript-eslint/no-restricted-imports
-import { fs } from '@modern-js/utils';
-
-export const getCompiledPath = (packageName: string) => {
- const providerCompilerPath = join(__dirname, '../../compiled', packageName);
- if (fs.existsSync(providerCompilerPath)) {
- return providerCompilerPath;
- } else {
- return getSharedPkgCompiledPath(packageName as SharedCompiledPkgNames);
- }
-};
diff --git a/packages/builder/builder-rspack-provider/src/shared/index.ts b/packages/builder/builder-rspack-provider/src/shared/index.ts
deleted file mode 100644
index 78e6ad8db3ef..000000000000
--- a/packages/builder/builder-rspack-provider/src/shared/index.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export * from './fs';
-export * from './constants';
-export * from './rspackVersion';
diff --git a/packages/builder/builder-rspack-provider/src/shared/plugin.ts b/packages/builder/builder-rspack-provider/src/shared/plugin.ts
deleted file mode 100644
index 8e032aadc6df..000000000000
--- a/packages/builder/builder-rspack-provider/src/shared/plugin.ts
+++ /dev/null
@@ -1,58 +0,0 @@
-import { BuilderPlugin } from '../types';
-import { awaitableGetter, Plugins } from '@modern-js/builder-shared';
-
-export const applyDefaultPlugins = (plugins: Plugins) =>
- awaitableGetter([
- import('../plugins/transition').then(m => m.builderPluginTransition()),
- import('../plugins/basic').then(m => m.builderPluginBasic()),
- plugins.antd(),
- plugins.arco(),
- plugins.entry(),
- // plugins.cache(),
- plugins.target(),
- import('../plugins/output').then(m => m.builderPluginOutput()),
- plugins.devtool(),
- import('../plugins/resolve').then(m => m.builderPluginResolve()),
- plugins.fileSize(),
- // cleanOutput plugin should before the html plugin
- plugins.cleanOutput(),
- plugins.font(),
- plugins.image(),
- plugins.media(),
- plugins.svg(),
- plugins.html(),
- plugins.tsChecker(),
- plugins.wasm(),
- plugins.moment(),
- plugins.nodeAddons(),
- // pug plugin should after html plugin
- import('../plugins/pug').then(m => m.builderPluginPug()),
- import('../plugins/babel').then(m => m.builderPluginBabel()),
- plugins.define(),
- import('../plugins/css').then(m => m.builderPluginCss()),
- import('../plugins/less').then(m => m.builderPluginLess()),
- import('../plugins/sass').then(m => m.builderPluginSass()),
- import('../plugins/minimize').then(m => m.builderPluginMinimize()),
- import('../plugins/manifest').then(m => m.builderPluginManifest()),
- plugins.rem(),
- import('../plugins/hmr').then(m => m.builderPluginHMR()),
- import('../plugins/progress').then(m => m.builderPluginProgress()),
- import('../plugins/react').then(m => m.builderPluginReact()),
- import('../plugins/swc').then(m => m.builderPluginSwc()),
- plugins.externals(),
- plugins.toml(),
- plugins.yaml(),
- plugins.splitChunks(),
- plugins.startUrl(),
- plugins.inlineChunk(),
- plugins.bundleAnalyzer(),
- plugins.assetsRetry(),
- plugins.checkSyntax(),
- plugins.networkPerformance(),
- plugins.preloadOrPrefetch(),
- plugins.performance(),
- import('../plugins/rspack-profile').then(m =>
- m.builderPluginRspackProfile(),
- ),
- import('../plugins/fallback').then(m => m.builderPluginFallback()), // fallback should be the last plugin
- ]);
diff --git a/packages/builder/builder-rspack-provider/src/shared/rspackVersion.ts b/packages/builder/builder-rspack-provider/src/shared/rspackVersion.ts
deleted file mode 100644
index 65c7b88ae893..000000000000
--- a/packages/builder/builder-rspack-provider/src/shared/rspackVersion.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import path from 'path';
-
-export const getRspackVersion = async (): Promise => {
- try {
- const core = require.resolve('@rspack/core');
- const pkg = await import(path.join(core, '../../package.json'));
-
- return pkg?.version;
- } catch (err) {
- // don't block build process
- console.error(err);
- return '';
- }
-};
-
-// depend on rspack builtin plugins
-export const supportedRspackMinimumVersion = '0.3.3';
-
-export const isSatisfyRspackMinimumVersion = async (customVersion?: string) => {
- let version = customVersion || (await getRspackVersion());
- const { semver } = await import('@modern-js/utils');
-
- // The nightly version of rspack is to append `-canary-xxx` to the current version
- if (version.includes('-canary')) {
- version = version.split('-canary')[0];
- }
-
- return version ? semver.lte(supportedRspackMinimumVersion, version) : true;
-};
diff --git a/packages/builder/builder-rspack-provider/src/types/config/dev.ts b/packages/builder/builder-rspack-provider/src/types/config/dev.ts
deleted file mode 100644
index ccff1f9101ba..000000000000
--- a/packages/builder/builder-rspack-provider/src/types/config/dev.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import type {
- SharedDevConfig,
- NormalizedSharedDevConfig,
-} from '@modern-js/builder-shared';
-
-export type DevConfig = SharedDevConfig;
-
-export type NormalizedDevConfig = NormalizedSharedDevConfig;
diff --git a/packages/builder/builder-rspack-provider/src/types/config/html.ts b/packages/builder/builder-rspack-provider/src/types/config/html.ts
deleted file mode 100644
index e35e9954e07f..000000000000
--- a/packages/builder/builder-rspack-provider/src/types/config/html.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import type {
- SharedHtmlConfig,
- NormalizedSharedHtmlConfig,
-} from '@modern-js/builder-shared';
-
-export type HtmlConfig = SharedHtmlConfig;
-
-export type NormalizedHtmlConfig = NormalizedSharedHtmlConfig;
diff --git a/packages/builder/builder-rspack-provider/src/types/config/index.ts b/packages/builder/builder-rspack-provider/src/types/config/index.ts
deleted file mode 100644
index 41b55fbd58d6..000000000000
--- a/packages/builder/builder-rspack-provider/src/types/config/index.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-import type { DeepReadonly } from '@modern-js/builder-shared';
-import type { DevConfig, NormalizedDevConfig } from './dev';
-import type { HtmlConfig, NormalizedHtmlConfig } from './html';
-import type { NormalizedOutputConfig, OutputConfig } from './output';
-import type {
- NormalizedPerformanceConfig,
- PerformanceConfig,
-} from './performance';
-import type { NormalizedSecurityConfig, SecurityConfig } from './security';
-import type { NormalizedSourceConfig, SourceConfig } from './source';
-import type { NormalizedToolsConfig, ToolsConfig } from './tools';
-
-/** The Builder Config when using rspack-provider */
-export interface BuilderConfig {
- dev?: DevConfig;
- html?: HtmlConfig;
- tools?: ToolsConfig;
- source?: SourceConfig;
- output?: OutputConfig;
- security?: SecurityConfig;
- performance?: PerformanceConfig;
-}
-
-export type NormalizedConfig = DeepReadonly<{
- dev: NormalizedDevConfig;
- html: NormalizedHtmlConfig;
- tools: NormalizedToolsConfig;
- source: NormalizedSourceConfig;
- output: NormalizedOutputConfig;
- security: NormalizedSecurityConfig;
- performance: NormalizedPerformanceConfig;
-}>;
-
-/* eslint-disable @typescript-eslint/no-restricted-imports */
-export * from './dev';
-export * from './html';
-export * from './output';
-export * from './performance';
-export * from './security';
-export * from './source';
-export * from './tools';
-/* eslint-enable @typescript-eslint/no-restricted-imports */
diff --git a/packages/builder/builder-rspack-provider/src/types/config/output.ts b/packages/builder/builder-rspack-provider/src/types/config/output.ts
deleted file mode 100644
index 44ce490c9a0e..000000000000
--- a/packages/builder/builder-rspack-provider/src/types/config/output.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import type {
- SharedOutputConfig,
- NormalizedSharedOutputConfig,
-} from '@modern-js/builder-shared';
-import type { Builtins } from '@rspack/core';
-
-export type OutputConfig = SharedOutputConfig & {
- /**
- * Copies the specified file or directory to the dist directory.
- */
- copy?: Builtins['copy'] | NonNullable['patterns'];
-};
-
-export type NormalizedOutputConfig = OutputConfig &
- NormalizedSharedOutputConfig;
diff --git a/packages/builder/builder-rspack-provider/src/types/config/performance.ts b/packages/builder/builder-rspack-provider/src/types/config/performance.ts
deleted file mode 100644
index 2daeec325ec9..000000000000
--- a/packages/builder/builder-rspack-provider/src/types/config/performance.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import type {
- SharedPerformanceConfig,
- NormalizedSharedPerformanceConfig,
-} from '@modern-js/builder-shared';
-
-export type PerformanceConfig = SharedPerformanceConfig;
-
-export type NormalizedPerformanceConfig = NormalizedSharedPerformanceConfig;
diff --git a/packages/builder/builder-rspack-provider/src/types/config/security.ts b/packages/builder/builder-rspack-provider/src/types/config/security.ts
deleted file mode 100644
index 9b35a8611f85..000000000000
--- a/packages/builder/builder-rspack-provider/src/types/config/security.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import type {
- SharedSecurityConfig,
- NormalizedSharedSecurityConfig,
-} from '@modern-js/builder-shared';
-
-export type SecurityConfig = SharedSecurityConfig;
-
-export type NormalizedSecurityConfig = NormalizedSharedSecurityConfig;
diff --git a/packages/builder/builder-rspack-provider/src/types/config/source.ts b/packages/builder/builder-rspack-provider/src/types/config/source.ts
deleted file mode 100644
index 5ed8953c012c..000000000000
--- a/packages/builder/builder-rspack-provider/src/types/config/source.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import type {
- SharedSourceConfig,
- NormalizedSharedSourceConfig,
-} from '@modern-js/builder-shared';
-import type { Builtins } from '@rspack/core';
-import type { RspackBuiltinsConfig } from '../rspack';
-
-export type SourceConfig = SharedSourceConfig & {
- define?: RspackBuiltinsConfig['define'];
- transformImport?: false | Builtins['pluginImport'];
-};
-
-export type NormalizedSourceConfig = NormalizedSharedSourceConfig & {
- define: Record;
- transformImport?: false | Builtins['pluginImport'];
-};
diff --git a/packages/builder/builder-rspack-provider/src/types/config/tools.ts b/packages/builder/builder-rspack-provider/src/types/config/tools.ts
deleted file mode 100644
index 0e5eaefbe203..000000000000
--- a/packages/builder/builder-rspack-provider/src/types/config/tools.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-import type {
- ChainedConfig,
- SharedToolsConfig,
- ToolsLessConfig,
- ToolsSassConfig,
- PostCSSLoaderOptions,
- PostCSSPlugin,
-} from '@modern-js/builder-shared';
-import type { Options as HTMLPluginOptions } from '@rspack/plugin-html';
-import type { RspackConfig } from '../rspack';
-import type { ModifyRspackConfigUtils } from '../hooks';
-
-export type ToolsPostCSSLoaderConfig = ChainedConfig<
- PostCSSLoaderOptions,
- {
- addPlugins: (plugins: PostCSSPlugin | PostCSSPlugin[]) => void;
- }
->;
-
-type ToolsHtmlPluginConfig = ChainedConfig<
- HTMLPluginOptions,
- {
- entryName: string;
- entryValue: string | string[];
- }
->;
-
-export type ToolsRspackConfig = ChainedConfig<
- RspackConfig,
- ModifyRspackConfigUtils
->;
-
-export interface ToolsConfig extends SharedToolsConfig {
- htmlPlugin?: false | ToolsHtmlPluginConfig;
- postcss?: ToolsPostCSSLoaderConfig;
- rspack?: ToolsRspackConfig;
- less?: ToolsLessConfig;
- sass?: ToolsSassConfig;
-}
-
-export type NormalizedToolsConfig = ToolsConfig;
diff --git a/packages/builder/builder-rspack-provider/src/types/context.ts b/packages/builder/builder-rspack-provider/src/types/context.ts
deleted file mode 100644
index 554d3b20f971..000000000000
--- a/packages/builder/builder-rspack-provider/src/types/context.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import type { BuilderContext } from '@modern-js/builder-shared';
-import type { Hooks } from '../core/initHooks';
-import type { BuilderConfig, NormalizedConfig } from './config';
-import type { BuilderPluginAPI } from './plugin';
-
-/** The inner context. */
-export type Context = BuilderContext & {
- /** All hooks. */
- hooks: Readonly;
- /** Current builder config. */
- config: Readonly;
- /** The async task to validate schema of config. */
- configValidatingTask: Promise;
- /** The original builder config passed from the createBuilder method. */
- originalConfig: Readonly;
- /** The normalized builder config. */
- normalizedConfig?: NormalizedConfig;
- /** The plugin API. */
- pluginAPI?: BuilderPluginAPI;
-};
diff --git a/packages/builder/builder-rspack-provider/src/types/hooks.ts b/packages/builder/builder-rspack-provider/src/types/hooks.ts
deleted file mode 100644
index 67f3971c9fe7..000000000000
--- a/packages/builder/builder-rspack-provider/src/types/hooks.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import type { ModifyChainUtils } from '@modern-js/builder-shared';
-import type { RspackConfig, RspackRule, RspackPluginInstance } from './rspack';
-
-export type ModifyRspackConfigUtils = ModifyChainUtils & {
- addRules: (rules: RspackRule | RspackRule[]) => void;
- prependPlugins: (
- plugins: RspackPluginInstance | RspackPluginInstance[],
- ) => void;
- appendPlugins: (
- plugins: RspackPluginInstance | RspackPluginInstance[],
- ) => void;
- removePlugin: (pluginName: string) => void;
- mergeConfig: typeof import('@modern-js/builder-shared/webpack-merge').merge;
- rspack: typeof import('@rspack/core');
-};
-
-export type ModifyRspackConfigFn = (
- config: RspackConfig,
- utils: ModifyRspackConfigUtils,
-) => Promise | RspackConfig | void;
diff --git a/packages/builder/builder-rspack-provider/src/types/index.ts b/packages/builder/builder-rspack-provider/src/types/index.ts
deleted file mode 100644
index 13782109e1b9..000000000000
--- a/packages/builder/builder-rspack-provider/src/types/index.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-/* eslint-disable @typescript-eslint/no-restricted-imports */
-export * from './hooks';
-export * from './config';
-export * from './plugin';
-export * from './context';
-export * from './rspack';
-/* eslint-enable @typescript-eslint/no-restricted-imports */
diff --git a/packages/builder/builder-rspack-provider/src/types/plugin.ts b/packages/builder/builder-rspack-provider/src/types/plugin.ts
deleted file mode 100644
index 3d009d11a7cc..000000000000
--- a/packages/builder/builder-rspack-provider/src/types/plugin.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import type {
- DefaultBuilderPluginAPI,
- BuilderPlugin as BaseBuilderPlugin,
-} from '@modern-js/builder-shared';
-import type { BuilderConfig, NormalizedConfig } from './config';
-import type { ModifyRspackConfigFn } from './hooks';
-import type { Compiler, MultiCompiler, RspackConfig } from './rspack';
-
-export interface BuilderPluginAPI
- extends DefaultBuilderPluginAPI<
- BuilderConfig,
- NormalizedConfig,
- RspackConfig,
- Compiler | MultiCompiler
- > {
- modifyRspackConfig: (fn: ModifyRspackConfigFn) => void;
-}
-
-export type BuilderPlugin = BaseBuilderPlugin;
diff --git a/packages/builder/builder-rspack-provider/src/types/rspack.ts b/packages/builder/builder-rspack-provider/src/types/rspack.ts
deleted file mode 100644
index 8be26c5ec52d..000000000000
--- a/packages/builder/builder-rspack-provider/src/types/rspack.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-import type * as Rspack from '@rspack/core';
-
-type Compiler = Rspack.Compiler;
-type RspackOptions = Rspack.RspackOptions;
-type MultiCompiler = Rspack.MultiCompiler;
-
-export type { Compiler, MultiCompiler, Rspack };
-
-export type RspackBuiltinsConfig = Omit<
- NonNullable,
- 'html'
->;
-
-export interface RspackConfig extends RspackOptions {
- /** multi type is useless in builder and make get value difficult */
- entry?: Record;
- // can't use htmlPlugin & builtins.html at the same time.
- builtins?: RspackBuiltinsConfig;
- /** rspack-dev-server is not used in modern.js */
- devServer?: {
- hot?: boolean;
- };
-}
-
-/** T[] => T */
-type GetElementType = T extends (infer U)[] ? U : never;
-
-export type RspackRule = GetElementType<
- NonNullable['rules']>
->;
-
-export type RuleSetRule = Rspack.RuleSetRule;
-
-export type RspackPluginInstance = GetElementType<
- NonNullable
->;
diff --git a/packages/builder/builder-rspack-provider/tests/.eslintrc.js b/packages/builder/builder-rspack-provider/tests/.eslintrc.js
deleted file mode 100644
index 2136c691080e..000000000000
--- a/packages/builder/builder-rspack-provider/tests/.eslintrc.js
+++ /dev/null
@@ -1,9 +0,0 @@
-// eslint-disable-next-line import/no-commonjs
-module.exports = {
- root: true,
- extends: '@modern-js-app',
- parserOptions: {
- tsconfigRootDir: __dirname,
- project: require.resolve('./tsconfig.json'),
- },
-};
diff --git a/packages/builder/builder-rspack-provider/tests/core/validate.test.ts b/packages/builder/builder-rspack-provider/tests/core/validate.test.ts
deleted file mode 100644
index ef7be3dfc275..000000000000
--- a/packages/builder/builder-rspack-provider/tests/core/validate.test.ts
+++ /dev/null
@@ -1,62 +0,0 @@
-import { performance } from 'perf_hooks';
-import { describe, expect, it } from 'vitest';
-import { createDefaultConfig } from '@/config/defaults';
-import { validateBuilderConfig } from '@/config/validate';
-import { BuilderConfig } from '@/types';
-
-describe('validateBuilderConfig', () => {
- it('should accept empty object', async () => {
- await expect(validateBuilderConfig({})).resolves.toEqual({});
- });
- it('should remove unknown properties', async () => {
- await expect(validateBuilderConfig({ foo: 123 })).resolves.toEqual({});
- });
-
- it('should throw error when shape wrong', async () => {
- const config = {
- dev: { hmr: false },
- html: { faviconByEntries: [] },
- };
- await expect(
- validateBuilderConfig({
- output: {
- polyfill: 'usage',
- },
- }),
- ).rejects.toThrowErrorMatchingInlineSnapshot(`
- "Builder config validation error:
- * Invalid enum value. Expected 'entry' | 'ua' | 'off', received 'usage' at \\"output.polyfill\\""
- `);
-
- await expect(validateBuilderConfig(config)).rejects
- .toThrowErrorMatchingInlineSnapshot(`
- "Builder config validation error:
- * Expected object, received array at \\"html.faviconByEntries\\""
- `);
- });
- it('should accept correct chained config', async () => {
- const config: BuilderConfig = {
- tools: {
- htmlPlugin: false,
- rspack: (_: any) => ({}),
- },
- };
- await expect(validateBuilderConfig(config)).resolves.toMatchInlineSnapshot(`
- {
- "tools": {
- "htmlPlugin": false,
- "rspack": [Function],
- },
- }
- `);
- });
- it('should validate config and cost less than 100ms', async () => {
- const config = createDefaultConfig();
- const startedAt = performance.now();
- await validateBuilderConfig(config);
- const endedAt = performance.now();
- const cost = endedAt - startedAt;
- console.log(`config validator cost: ${cost.toFixed(2)}ms`);
- expect(cost).lessThan(100);
- });
-});
diff --git a/packages/builder/builder-rspack-provider/tests/helper.ts b/packages/builder/builder-rspack-provider/tests/helper.ts
deleted file mode 100644
index b09646b0f090..000000000000
--- a/packages/builder/builder-rspack-provider/tests/helper.ts
+++ /dev/null
@@ -1,74 +0,0 @@
-import {
- pick,
- createPluginStore,
- applyDefaultBuilderOptions,
- type CreateBuilderOptions,
-} from '@modern-js/builder-shared';
-import { BuilderPlugin, BuilderConfig, RspackConfig } from '../src/types';
-import { builderRspackProvider } from '../src/provider';
-
-export const getBuilderPlugins = async () => {
- const { plugins } = await import('../../builder/src/plugins');
-
- return plugins;
-};
-
-/** Match plugin by constructor name. */
-export const matchPlugin = (config: RspackConfig, pluginName: string) => {
- const result = config.plugins?.filter(
- item => item?.constructor.name === pluginName,
- );
-
- if (Array.isArray(result)) {
- return result[0] || null;
- } else {
- return result || null;
- }
-};
-
-/**
- * different with builder.createBuilder. support add custom plugins instead of applyDefaultPlugins.
- */
-export async function createBuilder({
- builderConfig = {},
- plugins,
- ...options
-}: CreateBuilderOptions & {
- builderConfig?: BuilderConfig;
- plugins?: BuilderPlugin[];
-}) {
- const builderOptions = applyDefaultBuilderOptions(options);
-
- const provider = builderRspackProvider({
- builderConfig,
- });
-
- const pluginStore = createPluginStore();
- const {
- build,
- publicContext,
- inspectConfig,
- createCompiler,
- startDevServer,
- applyDefaultPlugins,
- } = await provider({
- pluginStore,
- builderOptions,
- plugins: await getBuilderPlugins(),
- });
-
- if (plugins) {
- pluginStore.addPlugins(plugins);
- } else {
- await applyDefaultPlugins(pluginStore);
- }
-
- return {
- ...pick(pluginStore, ['addPlugins', 'removePlugins', 'isPluginExists']),
- build,
- createCompiler,
- inspectConfig,
- startDevServer,
- context: publicContext,
- };
-}
diff --git a/packages/builder/builder-rspack-provider/tests/plugins/__snapshots__/babel.test.ts.snap b/packages/builder/builder-rspack-provider/tests/plugins/__snapshots__/babel.test.ts.snap
deleted file mode 100644
index 243517216472..000000000000
--- a/packages/builder/builder-rspack-provider/tests/plugins/__snapshots__/babel.test.ts.snap
+++ /dev/null
@@ -1,61 +0,0 @@
-// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
-
-exports[`plugins/babel > should not set babel-loader 1`] = `{}`;
-
-exports[`plugins/babel > should not set babel-loader when babel config is null 1`] = `{}`;
-
-exports[`plugins/babel > should not set babel-loader when babel config is return null 1`] = `{}`;
-
-exports[`plugins/babel > should set babel-loader 1`] = `
-{
- "module": {
- "rules": [
- {
- "include": [
- {
- "and": [
- "",
- {
- "not": /\\[\\\\\\\\/\\]node_modules\\[\\\\\\\\/\\]/,
- },
- ],
- },
- ],
- "test": /\\\\\\.\\(js\\|mjs\\|cjs\\|jsx\\)\\$\\|\\\\\\.\\(ts\\|mts\\|cts\\|tsx\\)\\$/,
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/babel-loader",
- "options": {
- "babelrc": false,
- "compact": false,
- "configFile": false,
- "plugins": [
- [
- "babel-plugin-import",
- {
- "libraryDirectory": "es",
- "libraryName": "xxx-components",
- "style": true,
- },
- ],
- ],
- "presets": [
- [
- "/node_modules//@babel/preset-typescript/lib/index.js",
- {
- "allExtensions": true,
- "allowDeclareFields": true,
- "allowNamespaces": true,
- "isTSX": true,
- "optimizeConstEnums": true,
- },
- ],
- ],
- },
- },
- ],
- },
- ],
- },
-}
-`;
diff --git a/packages/builder/builder-rspack-provider/tests/plugins/__snapshots__/css.test.ts.snap b/packages/builder/builder-rspack-provider/tests/plugins/__snapshots__/css.test.ts.snap
deleted file mode 100644
index 3909e45a997f..000000000000
--- a/packages/builder/builder-rspack-provider/tests/plugins/__snapshots__/css.test.ts.snap
+++ /dev/null
@@ -1,1259 +0,0 @@
-// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
-
-exports[`plugins/css > should apply custom css-modules-typescript-loader when enableCssModuleTSDeclarationg 1`] = `
-{
- "builtins": {
- "css": {
- "modules": {
- "exportsOnly": false,
- "localIdentName": "[path][name]__[local]-[hash:6]",
- "localsConvention": "camelCase",
- },
- },
- },
- "module": {
- "rules": [
- {
- "oneOf": [
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "test": /\\\\\\.module\\\\\\.\\\\w\\+\\$/i,
- "type": "css/module",
- "use": [
- {
- "loader": "/src/rspackLoader/css-modules-typescript-pre-loader",
- "options": {
- "modules": {
- "auto": true,
- "exportLocalsConvention": "camelCase",
- },
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- ],
- },
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "type": "css",
- "use": [
- {
- "loader": "/src/rspackLoader/css-modules-typescript-pre-loader",
- "options": {
- "modules": {
- "auto": true,
- "exportLocalsConvention": "camelCase",
- },
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- ],
- },
- ],
- "test": /\\\\\\.css\\$/,
- },
- ],
- },
-}
-`;
-
-exports[`plugins/css > should override browserslist of autoprefixer when using output.overrideBrowserslist config 1`] = `
-{
- "builtins": {
- "css": {
- "modules": {
- "exportsOnly": false,
- "localIdentName": "[path][name]__[local]-[hash:6]",
- "localsConvention": "camelCase",
- },
- },
- },
- "module": {
- "rules": [
- {
- "oneOf": [
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "test": /\\\\\\.module\\\\\\.\\\\w\\+\\$/i,
- "type": "css/module",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "Chrome 80",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "Chrome 80",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- ],
- },
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "type": "css",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "Chrome 80",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "Chrome 80",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- ],
- },
- ],
- "test": /\\\\\\.css\\$/,
- },
- ],
- },
-}
-`;
-
-exports[`plugins/css > should use custom cssModules rule when using output.cssModules config 1`] = `
-{
- "builtins": {
- "css": {
- "modules": {
- "exportsOnly": false,
- "localIdentName": "[path][name]__[local]-[hash:6]",
- "localsConvention": "camelCase",
- },
- },
- },
- "module": {
- "rules": [
- {
- "oneOf": [
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "test": [Function],
- "type": "css/module",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- ],
- },
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "type": "css",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- ],
- },
- ],
- "test": /\\\\\\.css\\$/,
- },
- ],
- },
-}
-`;
-
-exports[`plugins/css disableCssExtract > should apply ignoreCssLoader when disableCssExtract is true and target is node 1`] = `
-{
- "experiments": {
- "css": false,
- },
- "module": {
- "rules": [
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "test": /\\\\\\.css\\$/,
- "use": [
- {
- "loader": "@modern-js/builder-shared/ignore-css-loader",
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/css-loader",
- "options": {
- "importLoaders": 1,
- "modules": {
- "auto": true,
- "exportLocalsConvention": "camelCase",
- "exportOnlyLocals": true,
- "localIdentName": "[path][name]__[local]-[hash:base64:6]",
- },
- "sourceMap": true,
- },
- },
- ],
- },
- ],
- },
-}
-`;
-
-exports[`plugins/css disableCssExtract > should use css-loader + style-loader when disableCssExtract is true 1`] = `
-{
- "experiments": {
- "css": false,
- },
- "module": {
- "rules": [
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "test": /\\\\\\.css\\$/,
- "use": [
- {
- "loader": "/node_modules//style-loader/dist/cjs.js",
- "options": {
- "esModule": false,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/css-loader",
- "options": {
- "importLoaders": 1,
- "modules": {
- "auto": true,
- "exportLocalsConvention": "camelCase",
- "localIdentName": "[path][name]__[local]-[hash:base64:6]",
- },
- "sourceMap": true,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- ],
- },
- ],
- },
-}
-`;
-
-exports[`plugins/less > should add less-loader 1`] = `
-{
- "module": {
- "rules": [
- {
- "oneOf": [
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "test": /\\\\\\.module\\\\\\.\\\\w\\+\\$/i,
- "type": "css/module",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/less-loader",
- "options": {
- "implementation": "/packages/builder/builder-shared/compiled/less",
- "lessOptions": {
- "javascriptEnabled": true,
- },
- "sourceMap": true,
- },
- },
- ],
- },
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "type": "css",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/less-loader",
- "options": {
- "implementation": "/packages/builder/builder-shared/compiled/less",
- "lessOptions": {
- "javascriptEnabled": true,
- },
- "sourceMap": true,
- },
- },
- ],
- },
- ],
- "test": /\\\\\\.less\\$/,
- },
- ],
- },
-}
-`;
-
-exports[`plugins/less > should add less-loader and css-loader when disableCssExtract 1`] = `
-{
- "module": {
- "rules": [
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "test": /\\\\\\.less\\$/,
- "use": [
- {
- "loader": "/node_modules//style-loader/dist/cjs.js",
- "options": {
- "esModule": false,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/css-loader",
- "options": {
- "importLoaders": 1,
- "modules": {
- "auto": true,
- "exportLocalsConvention": "camelCase",
- "localIdentName": "[path][name]__[local]-[hash:base64:6]",
- },
- "sourceMap": true,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/less-loader",
- "options": {
- "implementation": "/packages/builder/builder-shared/compiled/less",
- "lessOptions": {
- "javascriptEnabled": true,
- },
- "sourceMap": true,
- },
- },
- ],
- },
- ],
- },
-}
-`;
-
-exports[`plugins/less > should add less-loader with excludes 1`] = `
-{
- "module": {
- "rules": [
- {
- "oneOf": [
- {
- "exclude": [
- /node_modules/,
- ],
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "test": /\\\\\\.module\\\\\\.\\\\w\\+\\$/i,
- "type": "css/module",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/less-loader",
- "options": {
- "implementation": "/packages/builder/builder-shared/compiled/less",
- "lessOptions": {
- "javascriptEnabled": true,
- },
- "sourceMap": true,
- },
- },
- ],
- },
- {
- "exclude": [
- /node_modules/,
- ],
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "type": "css",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/less-loader",
- "options": {
- "implementation": "/packages/builder/builder-shared/compiled/less",
- "lessOptions": {
- "javascriptEnabled": true,
- },
- "sourceMap": true,
- },
- },
- ],
- },
- ],
- "test": /\\\\\\.less\\$/,
- },
- ],
- },
-}
-`;
-
-exports[`plugins/less > should add less-loader with tools.less 1`] = `
-{
- "module": {
- "rules": [
- {
- "oneOf": [
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "test": /\\\\\\.module\\\\\\.\\\\w\\+\\$/i,
- "type": "css/module",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/less-loader",
- "options": {
- "implementation": "/packages/builder/builder-shared/compiled/less",
- "lessOptions": {
- "javascriptEnabled": false,
- },
- "sourceMap": true,
- },
- },
- ],
- },
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "type": "css",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/less-loader",
- "options": {
- "implementation": "/packages/builder/builder-shared/compiled/less",
- "lessOptions": {
- "javascriptEnabled": false,
- },
- "sourceMap": true,
- },
- },
- ],
- },
- ],
- "test": /\\\\\\.less\\$/,
- },
- ],
- },
-}
-`;
-
-exports[`plugins/sass > should add sass-loader 1`] = `
-{
- "module": {
- "rules": [
- {
- "oneOf": [
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "test": /\\\\\\.module\\\\\\.\\\\w\\+\\$/i,
- "type": "css/module",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/resolve-url-loader",
- "options": {
- "join": [Function],
- "sourceMap": false,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/sass-loader",
- "options": {
- "implementation": "/packages/builder/builder-shared/compiled/sass",
- "sourceMap": true,
- },
- },
- ],
- },
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "type": "css",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/resolve-url-loader",
- "options": {
- "join": [Function],
- "sourceMap": false,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/sass-loader",
- "options": {
- "implementation": "/packages/builder/builder-shared/compiled/sass",
- "sourceMap": true,
- },
- },
- ],
- },
- ],
- "test": /\\\\\\.s\\(a\\|c\\)ss\\$/,
- },
- ],
- },
-}
-`;
-
-exports[`plugins/sass > should add sass-loader and css-loader when disableCssExtract 1`] = `
-{
- "module": {
- "rules": [
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "test": /\\\\\\.s\\(a\\|c\\)ss\\$/,
- "use": [
- {
- "loader": "/node_modules//style-loader/dist/cjs.js",
- "options": {
- "esModule": false,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/css-loader",
- "options": {
- "importLoaders": 3,
- "modules": {
- "auto": true,
- "exportLocalsConvention": "camelCase",
- "localIdentName": "[path][name]__[local]-[hash:base64:6]",
- },
- "sourceMap": true,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/resolve-url-loader",
- "options": {
- "join": [Function],
- "sourceMap": false,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/sass-loader",
- "options": {
- "implementation": "/packages/builder/builder-shared/compiled/sass",
- "sourceMap": true,
- },
- },
- ],
- },
- ],
- },
-}
-`;
-
-exports[`plugins/sass > should add sass-loader with excludes 1`] = `
-{
- "module": {
- "rules": [
- {
- "oneOf": [
- {
- "exclude": [
- /node_modules/,
- ],
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "test": /\\\\\\.module\\\\\\.\\\\w\\+\\$/i,
- "type": "css/module",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/resolve-url-loader",
- "options": {
- "join": [Function],
- "sourceMap": false,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/sass-loader",
- "options": {
- "implementation": "/packages/builder/builder-shared/compiled/sass",
- "sourceMap": true,
- },
- },
- ],
- },
- {
- "exclude": [
- /node_modules/,
- ],
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "type": "css",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/resolve-url-loader",
- "options": {
- "join": [Function],
- "sourceMap": false,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/sass-loader",
- "options": {
- "implementation": "/packages/builder/builder-shared/compiled/sass",
- "sourceMap": true,
- },
- },
- ],
- },
- ],
- "test": /\\\\\\.s\\(a\\|c\\)ss\\$/,
- },
- ],
- },
-}
-`;
diff --git a/packages/builder/builder-rspack-provider/tests/plugins/__snapshots__/default.test.ts.snap b/packages/builder/builder-rspack-provider/tests/plugins/__snapshots__/default.test.ts.snap
deleted file mode 100644
index 027c5159e932..000000000000
--- a/packages/builder/builder-rspack-provider/tests/plugins/__snapshots__/default.test.ts.snap
+++ /dev/null
@@ -1,2722 +0,0 @@
-// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
-
-exports[`applyDefaultPlugins > should apply default plugins correctly 1`] = `
-{
- "builtins": {
- "css": {
- "modules": {
- "exportsOnly": false,
- "localIdentName": "[path][name]__[local]-[hash:6]",
- "localsConvention": "camelCase",
- },
- },
- "decorator": {
- "emitMetadata": true,
- "legacy": true,
- },
- "pluginImport": [
- {
- "libraryDirectory": "es",
- "libraryName": "antd",
- "style": true,
- },
- {
- "camelToDashComponentName": false,
- "libraryDirectory": "es",
- "libraryName": "@arco-design/web-react",
- "style": true,
- },
- {
- "camelToDashComponentName": false,
- "libraryDirectory": "react-icon",
- "libraryName": "@arco-design/web-react/icon",
- },
- ],
- "presetEnv": {
- "coreJs": "3.32",
- "mode": "entry",
- "targets": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "react": {
- "development": true,
- "refresh": true,
- "runtime": "automatic",
- },
- },
- "context": "",
- "devServer": {
- "hot": true,
- },
- "devtool": "cheap-module-source-map",
- "experiments": {
- "asyncWebAssembly": true,
- "rspackFuture": {
- "disableTransformByDefault": false,
- },
- },
- "infrastructureLogging": {
- "level": "error",
- },
- "mode": "development",
- "module": {
- "rules": [
- {
- "resolve": {
- "fullySpecified": false,
- },
- "test": /\\\\\\.m\\?js/,
- },
- {
- "oneOf": [
- {
- "generator": {
- "filename": "static/font/[name].[contenthash:8][ext]",
- },
- "resourceQuery": /\\(__inline=false\\|url\\)/,
- "type": "asset/resource",
- },
- {
- "resourceQuery": /inline/,
- "type": "asset/inline",
- },
- {
- "generator": {
- "filename": "static/font/[name].[contenthash:8][ext]",
- },
- "parser": {
- "dataUrlCondition": {
- "maxSize": 10000,
- },
- },
- "type": "asset",
- },
- ],
- "test": /\\\\\\.\\(woff\\|woff2\\|eot\\|ttf\\|otf\\|ttc\\)\\$/i,
- },
- {
- "oneOf": [
- {
- "generator": {
- "filename": "static/image/[name].[contenthash:8][ext]",
- },
- "resourceQuery": /\\(__inline=false\\|url\\)/,
- "type": "asset/resource",
- },
- {
- "resourceQuery": /inline/,
- "type": "asset/inline",
- },
- {
- "generator": {
- "filename": "static/image/[name].[contenthash:8][ext]",
- },
- "parser": {
- "dataUrlCondition": {
- "maxSize": 10000,
- },
- },
- "type": "asset",
- },
- ],
- "test": /\\\\\\.\\(png\\|jpg\\|jpeg\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tiff\\)\\$/i,
- },
- {
- "oneOf": [
- {
- "generator": {
- "filename": "static/media/[name].[contenthash:8][ext]",
- },
- "resourceQuery": /\\(__inline=false\\|url\\)/,
- "type": "asset/resource",
- },
- {
- "resourceQuery": /inline/,
- "type": "asset/inline",
- },
- {
- "generator": {
- "filename": "static/media/[name].[contenthash:8][ext]",
- },
- "parser": {
- "dataUrlCondition": {
- "maxSize": 10000,
- },
- },
- "type": "asset",
- },
- ],
- "test": /\\\\\\.\\(mp4\\|webm\\|ogg\\|mp3\\|wav\\|flac\\|aac\\|mov\\)\\$/i,
- },
- {
- "oneOf": [
- {
- "generator": {
- "filename": "static/svg/[name].[contenthash:8].svg",
- },
- "issuer": {
- "not": [
- /\\\\\\.\\(js\\|mjs\\|cjs\\|jsx\\)\\$/,
- /\\\\\\.\\(ts\\|mts\\|cts\\|tsx\\)\\$/,
- ],
- },
- "resourceQuery": /\\(__inline=false\\|url\\)/,
- "type": "asset/resource",
- },
- {
- "issuer": {
- "not": [
- /\\\\\\.\\(js\\|mjs\\|cjs\\|jsx\\)\\$/,
- /\\\\\\.\\(ts\\|mts\\|cts\\|tsx\\)\\$/,
- ],
- },
- "resourceQuery": /inline/,
- "type": "asset/inline",
- },
- {
- "generator": {
- "filename": "static/svg/[name].[contenthash:8].svg",
- },
- "issuer": {
- "not": [
- /\\\\\\.\\(js\\|mjs\\|cjs\\|jsx\\)\\$/,
- /\\\\\\.\\(ts\\|mts\\|cts\\|tsx\\)\\$/,
- ],
- },
- "parser": {
- "dataUrlCondition": {
- "maxSize": 10000,
- },
- },
- "type": "asset",
- },
- {
- "resourceQuery": /inline/,
- "type": "asset/inline",
- },
- {
- "generator": {
- "filename": "static/svg/[name].[contenthash:8].svg",
- },
- "resourceQuery": /url/,
- "type": "asset/resource",
- },
- {
- "type": "javascript/auto",
- "use": [
- {
- "loader": "/node_modules//@svgr/webpack/dist/index.js",
- "options": {
- "svgo": true,
- "svgoConfig": {
- "plugins": [
- {
- "name": "preset-default",
- "params": {
- "overrides": {
- "removeViewBox": false,
- },
- },
- },
- "prefixIds",
- ],
- },
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/url-loader",
- "options": {
- "limit": 10000,
- "name": "static/svg/[name].[contenthash:8].svg",
- },
- },
- ],
- },
- ],
- "test": /\\\\\\.svg\\$/,
- },
- {
- "dependency": "url",
- "generator": {
- "filename": "static/wasm/[hash].module.wasm",
- },
- "test": /\\\\\\.wasm\\$/,
- "type": "asset/resource",
- },
- {
- "oneOf": [
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "test": /\\\\\\.module\\\\\\.\\\\w\\+\\$/i,
- "type": "css/module",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- ],
- },
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "type": "css",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- ],
- },
- ],
- "test": /\\\\\\.css\\$/,
- },
- {
- "oneOf": [
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "test": /\\\\\\.module\\\\\\.\\\\w\\+\\$/i,
- "type": "css/module",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/less-loader",
- "options": {
- "implementation": "/packages/builder/builder-shared/compiled/less",
- "lessOptions": {
- "javascriptEnabled": true,
- },
- "sourceMap": true,
- },
- },
- ],
- },
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "type": "css",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/less-loader",
- "options": {
- "implementation": "/packages/builder/builder-shared/compiled/less",
- "lessOptions": {
- "javascriptEnabled": true,
- },
- "sourceMap": true,
- },
- },
- ],
- },
- ],
- "test": /\\\\\\.less\\$/,
- },
- {
- "oneOf": [
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "test": /\\\\\\.module\\\\\\.\\\\w\\+\\$/i,
- "type": "css/module",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/resolve-url-loader",
- "options": {
- "join": [Function],
- "sourceMap": false,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/sass-loader",
- "options": {
- "implementation": "/packages/builder/builder-shared/compiled/sass",
- "sourceMap": true,
- },
- },
- ],
- },
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "type": "css",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/resolve-url-loader",
- "options": {
- "join": [Function],
- "sourceMap": false,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/sass-loader",
- "options": {
- "implementation": "/packages/builder/builder-shared/compiled/sass",
- "sourceMap": true,
- },
- },
- ],
- },
- ],
- "test": /\\\\\\.s\\(a\\|c\\)ss\\$/,
- },
- {
- "test": /\\\\\\.toml\\$/,
- "type": "javascript/auto",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/toml-loader",
- },
- ],
- },
- {
- "test": /\\\\\\.ya\\?ml\\$/,
- "type": "javascript/auto",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/yaml-loader",
- },
- ],
- },
- ],
- },
- "name": "Client",
- "optimization": {
- "minimize": false,
- "runtimeChunk": {
- "name": "builder-runtime",
- },
- "splitChunks": {
- "cacheGroups": {
- "lib-antd": {
- "name": "lib-antd",
- "priority": 0,
- "reuseExistingChunk": true,
- "test": /\\[\\\\\\\\/\\]node_modules\\[\\\\\\\\/\\]\\(antd\\)\\[\\\\\\\\/\\]/,
- },
- "lib-arco": {
- "name": "lib-arco",
- "priority": 0,
- "reuseExistingChunk": true,
- "test": /\\[\\\\\\\\/\\]node_modules\\[\\\\\\\\/\\]\\(@\\?arco-design\\)\\[\\\\\\\\/\\]/,
- },
- "lib-axios": {
- "name": "lib-axios",
- "priority": 0,
- "reuseExistingChunk": true,
- "test": /\\[\\\\\\\\/\\]node_modules\\[\\\\\\\\/\\]\\(axios\\|axios-\\.\\+\\)\\[\\\\\\\\/\\]/,
- },
- "lib-lodash": {
- "name": "lib-lodash",
- "priority": 0,
- "reuseExistingChunk": true,
- "test": /\\[\\\\\\\\/\\]node_modules\\[\\\\\\\\/\\]\\(lodash\\|lodash-es\\)\\[\\\\\\\\/\\]/,
- },
- "lib-polyfill": {
- "name": "lib-polyfill",
- "priority": 0,
- "reuseExistingChunk": true,
- "test": /\\[\\\\\\\\/\\]node_modules\\[\\\\\\\\/\\]\\(tslib\\|core-js\\|@babel\\\\/runtime\\|@swc\\\\/helpers\\)\\[\\\\\\\\/\\]/,
- },
- "lib-react": {
- "name": "lib-react",
- "priority": 0,
- "reuseExistingChunk": true,
- "test": /\\[\\\\\\\\/\\]node_modules\\[\\\\\\\\/\\]\\(react\\|react-dom\\|scheduler\\)\\[\\\\\\\\/\\]/,
- },
- "lib-router": {
- "name": "lib-router",
- "priority": 0,
- "reuseExistingChunk": true,
- "test": /\\[\\\\\\\\/\\]node_modules\\[\\\\\\\\/\\]\\(react-router\\|react-router-dom\\|@remix-run\\\\/router\\|history\\)\\[\\\\\\\\/\\]/,
- },
- },
- "chunks": "all",
- "enforceSizeThreshold": 50000,
- },
- },
- "output": {
- "chunkFilename": "static/js/async/[name].js",
- "cssChunkFilename": "static/css/async/[name].css",
- "cssFilename": "static/css/[name].css",
- "filename": "static/js/[name].js",
- "hashFunction": "xxhash64",
- "path": "/dist",
- "pathinfo": false,
- "publicPath": "/",
- "webassemblyModuleFilename": "static/wasm/[hash].module.wasm",
- },
- "plugins": [
- ForkTsCheckerWebpackPlugin {
- "options": {
- "issue": {
- "exclude": [
- {
- "file": "**/*.(spec|test).ts",
- },
- {
- "file": "**/node_modules/**/*",
- },
- ],
- },
- "logger": {
- "error": [Function],
- "log": [Function],
- },
- "typescript": {
- "configFile": "/tsconfig.json",
- "memoryLimit": 8192,
- "typescriptPath": "/node_modules//typescript/lib/typescript.js",
- },
- },
- },
- DefinePlugin {
- "_options": {
- "process.env.ASSET_PREFIX": "\\"\\"",
- "process.env.NODE_ENV": "\\"development\\"",
- },
- "affectedHooks": "compilation",
- "name": "DefinePlugin",
- },
- ProgressPlugin {
- "_options": {
- "prefix": "Client",
- "profile": false,
- },
- "affectedHooks": undefined,
- "name": "ProgressPlugin",
- },
- ProvidePlugin {
- "_options": {
- "$ReactRefreshRuntime$": [
- "/node_modules//@rspack/plugin-react-refresh/client/reactRefresh.js",
- ],
- },
- "affectedHooks": undefined,
- "name": "ProvidePlugin",
- },
- ],
- "resolve": {
- "alias": {
- "core-js": "/node_modules//core-js",
- },
- "extensions": [
- ".ts",
- ".tsx",
- ".js",
- ".jsx",
- ".mjs",
- ".json",
- ],
- "tsConfigPath": "/tsconfig.json",
- },
- "target": [
- "web",
- "es5",
- ],
-}
-`;
-
-exports[`applyDefaultPlugins > should apply default plugins correctly when prod 1`] = `
-{
- "builtins": {
- "css": {
- "modules": {
- "exportsOnly": false,
- "localIdentName": "[local]-[hash:6]",
- "localsConvention": "camelCase",
- },
- },
- "decorator": {
- "emitMetadata": true,
- "legacy": true,
- },
- "pluginImport": [
- {
- "libraryDirectory": "es",
- "libraryName": "antd",
- "style": true,
- },
- {
- "camelToDashComponentName": false,
- "libraryDirectory": "es",
- "libraryName": "@arco-design/web-react",
- "style": true,
- },
- {
- "camelToDashComponentName": false,
- "libraryDirectory": "react-icon",
- "libraryName": "@arco-design/web-react/icon",
- },
- ],
- "presetEnv": {
- "coreJs": "3.32",
- "mode": "entry",
- "targets": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "react": {
- "development": false,
- "refresh": false,
- "runtime": "automatic",
- },
- },
- "context": "",
- "devServer": {
- "hot": false,
- },
- "devtool": "hidden-source-map",
- "experiments": {
- "asyncWebAssembly": true,
- "rspackFuture": {
- "disableTransformByDefault": false,
- },
- },
- "infrastructureLogging": {
- "level": "error",
- },
- "mode": "production",
- "module": {
- "rules": [
- {
- "resolve": {
- "fullySpecified": false,
- },
- "test": /\\\\\\.m\\?js/,
- },
- {
- "oneOf": [
- {
- "generator": {
- "filename": "static/font/[name].[contenthash:8][ext]",
- },
- "resourceQuery": /\\(__inline=false\\|url\\)/,
- "type": "asset/resource",
- },
- {
- "resourceQuery": /inline/,
- "type": "asset/inline",
- },
- {
- "generator": {
- "filename": "static/font/[name].[contenthash:8][ext]",
- },
- "parser": {
- "dataUrlCondition": {
- "maxSize": 10000,
- },
- },
- "type": "asset",
- },
- ],
- "test": /\\\\\\.\\(woff\\|woff2\\|eot\\|ttf\\|otf\\|ttc\\)\\$/i,
- },
- {
- "oneOf": [
- {
- "generator": {
- "filename": "static/image/[name].[contenthash:8][ext]",
- },
- "resourceQuery": /\\(__inline=false\\|url\\)/,
- "type": "asset/resource",
- },
- {
- "resourceQuery": /inline/,
- "type": "asset/inline",
- },
- {
- "generator": {
- "filename": "static/image/[name].[contenthash:8][ext]",
- },
- "parser": {
- "dataUrlCondition": {
- "maxSize": 10000,
- },
- },
- "type": "asset",
- },
- ],
- "test": /\\\\\\.\\(png\\|jpg\\|jpeg\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tiff\\)\\$/i,
- },
- {
- "oneOf": [
- {
- "generator": {
- "filename": "static/media/[name].[contenthash:8][ext]",
- },
- "resourceQuery": /\\(__inline=false\\|url\\)/,
- "type": "asset/resource",
- },
- {
- "resourceQuery": /inline/,
- "type": "asset/inline",
- },
- {
- "generator": {
- "filename": "static/media/[name].[contenthash:8][ext]",
- },
- "parser": {
- "dataUrlCondition": {
- "maxSize": 10000,
- },
- },
- "type": "asset",
- },
- ],
- "test": /\\\\\\.\\(mp4\\|webm\\|ogg\\|mp3\\|wav\\|flac\\|aac\\|mov\\)\\$/i,
- },
- {
- "oneOf": [
- {
- "generator": {
- "filename": "static/svg/[name].[contenthash:8].svg",
- },
- "issuer": {
- "not": [
- /\\\\\\.\\(js\\|mjs\\|cjs\\|jsx\\)\\$/,
- /\\\\\\.\\(ts\\|mts\\|cts\\|tsx\\)\\$/,
- ],
- },
- "resourceQuery": /\\(__inline=false\\|url\\)/,
- "type": "asset/resource",
- },
- {
- "issuer": {
- "not": [
- /\\\\\\.\\(js\\|mjs\\|cjs\\|jsx\\)\\$/,
- /\\\\\\.\\(ts\\|mts\\|cts\\|tsx\\)\\$/,
- ],
- },
- "resourceQuery": /inline/,
- "type": "asset/inline",
- },
- {
- "generator": {
- "filename": "static/svg/[name].[contenthash:8].svg",
- },
- "issuer": {
- "not": [
- /\\\\\\.\\(js\\|mjs\\|cjs\\|jsx\\)\\$/,
- /\\\\\\.\\(ts\\|mts\\|cts\\|tsx\\)\\$/,
- ],
- },
- "parser": {
- "dataUrlCondition": {
- "maxSize": 10000,
- },
- },
- "type": "asset",
- },
- {
- "resourceQuery": /inline/,
- "type": "asset/inline",
- },
- {
- "generator": {
- "filename": "static/svg/[name].[contenthash:8].svg",
- },
- "resourceQuery": /url/,
- "type": "asset/resource",
- },
- {
- "type": "javascript/auto",
- "use": [
- {
- "loader": "/node_modules//@svgr/webpack/dist/index.js",
- "options": {
- "svgo": true,
- "svgoConfig": {
- "plugins": [
- {
- "name": "preset-default",
- "params": {
- "overrides": {
- "removeViewBox": false,
- },
- },
- },
- "prefixIds",
- ],
- },
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/url-loader",
- "options": {
- "limit": 10000,
- "name": "static/svg/[name].[contenthash:8].svg",
- },
- },
- ],
- },
- ],
- "test": /\\\\\\.svg\\$/,
- },
- {
- "dependency": "url",
- "generator": {
- "filename": "static/wasm/[hash].module.wasm",
- },
- "test": /\\\\\\.wasm\\$/,
- "type": "asset/resource",
- },
- {
- "oneOf": [
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "test": /\\\\\\.module\\\\\\.\\\\w\\+\\$/i,
- "type": "css/module",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": false,
- },
- },
- ],
- },
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "type": "css",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": false,
- },
- },
- ],
- },
- ],
- "test": /\\\\\\.css\\$/,
- },
- {
- "oneOf": [
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "test": /\\\\\\.module\\\\\\.\\\\w\\+\\$/i,
- "type": "css/module",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": false,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/less-loader",
- "options": {
- "implementation": "/packages/builder/builder-shared/compiled/less",
- "lessOptions": {
- "javascriptEnabled": true,
- },
- "sourceMap": false,
- },
- },
- ],
- },
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "type": "css",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": false,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/less-loader",
- "options": {
- "implementation": "/packages/builder/builder-shared/compiled/less",
- "lessOptions": {
- "javascriptEnabled": true,
- },
- "sourceMap": false,
- },
- },
- ],
- },
- ],
- "test": /\\\\\\.less\\$/,
- },
- {
- "oneOf": [
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "test": /\\\\\\.module\\\\\\.\\\\w\\+\\$/i,
- "type": "css/module",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": false,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/resolve-url-loader",
- "options": {
- "join": [Function],
- "sourceMap": false,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/sass-loader",
- "options": {
- "implementation": "/packages/builder/builder-shared/compiled/sass",
- "sourceMap": true,
- },
- },
- ],
- },
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "type": "css",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": false,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/resolve-url-loader",
- "options": {
- "join": [Function],
- "sourceMap": false,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/sass-loader",
- "options": {
- "implementation": "/packages/builder/builder-shared/compiled/sass",
- "sourceMap": true,
- },
- },
- ],
- },
- ],
- "test": /\\\\\\.s\\(a\\|c\\)ss\\$/,
- },
- {
- "test": /\\\\\\.toml\\$/,
- "type": "javascript/auto",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/toml-loader",
- },
- ],
- },
- {
- "test": /\\\\\\.ya\\?ml\\$/,
- "type": "javascript/auto",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/yaml-loader",
- },
- ],
- },
- ],
- },
- "name": "Client",
- "optimization": {
- "chunkIds": "deterministic",
- "minimize": true,
- "minimizer": [
- SwcJsMinimizerRspackPlugin {
- "_options": {
- "compress": "{\\"passes\\":1,\\"pure_funcs\\":[],\\"drop_console\\":false}",
- "exclude": undefined,
- "extractComments": "true",
- "format": "{\\"comments\\":false,\\"asciiOnly\\":true}",
- "include": undefined,
- "mangle": "{\\"keep_classnames\\":false,\\"keep_fnames\\":false}",
- "module": undefined,
- "test": undefined,
- },
- "affectedHooks": "compilation",
- "name": "SwcJsMinimizerRspackPlugin",
- },
- CssMinimizerPlugin {
- "options": {
- "exclude": undefined,
- "include": undefined,
- "minimizer": {
- "implementation": [Function],
- "options": {
- "preset": [
- "default",
- {
- "mergeLonghand": false,
- },
- ],
- },
- },
- "parallel": true,
- "test": /\\\\\\.css\\(\\\\\\?\\.\\*\\)\\?\\$/i,
- "warningsFilter": [Function],
- },
- },
- ],
- "runtimeChunk": {
- "name": "builder-runtime",
- },
- "splitChunks": {
- "cacheGroups": {
- "lib-antd": {
- "name": "lib-antd",
- "priority": 0,
- "reuseExistingChunk": true,
- "test": /\\[\\\\\\\\/\\]node_modules\\[\\\\\\\\/\\]\\(antd\\)\\[\\\\\\\\/\\]/,
- },
- "lib-arco": {
- "name": "lib-arco",
- "priority": 0,
- "reuseExistingChunk": true,
- "test": /\\[\\\\\\\\/\\]node_modules\\[\\\\\\\\/\\]\\(@\\?arco-design\\)\\[\\\\\\\\/\\]/,
- },
- "lib-axios": {
- "name": "lib-axios",
- "priority": 0,
- "reuseExistingChunk": true,
- "test": /\\[\\\\\\\\/\\]node_modules\\[\\\\\\\\/\\]\\(axios\\|axios-\\.\\+\\)\\[\\\\\\\\/\\]/,
- },
- "lib-lodash": {
- "name": "lib-lodash",
- "priority": 0,
- "reuseExistingChunk": true,
- "test": /\\[\\\\\\\\/\\]node_modules\\[\\\\\\\\/\\]\\(lodash\\|lodash-es\\)\\[\\\\\\\\/\\]/,
- },
- "lib-polyfill": {
- "name": "lib-polyfill",
- "priority": 0,
- "reuseExistingChunk": true,
- "test": /\\[\\\\\\\\/\\]node_modules\\[\\\\\\\\/\\]\\(tslib\\|core-js\\|@babel\\\\/runtime\\|@swc\\\\/helpers\\)\\[\\\\\\\\/\\]/,
- },
- "lib-react": {
- "name": "lib-react",
- "priority": 0,
- "reuseExistingChunk": true,
- "test": /\\[\\\\\\\\/\\]node_modules\\[\\\\\\\\/\\]\\(react\\|react-dom\\|scheduler\\)\\[\\\\\\\\/\\]/,
- },
- "lib-router": {
- "name": "lib-router",
- "priority": 0,
- "reuseExistingChunk": true,
- "test": /\\[\\\\\\\\/\\]node_modules\\[\\\\\\\\/\\]\\(react-router\\|react-router-dom\\|@remix-run\\\\/router\\|history\\)\\[\\\\\\\\/\\]/,
- },
- },
- "chunks": "all",
- "enforceSizeThreshold": 50000,
- },
- },
- "output": {
- "chunkFilename": "static/js/async/[name].[contenthash:8].js",
- "cssChunkFilename": "static/css/async/[name].[contenthash:8].css",
- "cssFilename": "static/css/[name].[contenthash:8].css",
- "filename": "static/js/[name].[contenthash:8].js",
- "hashFunction": "xxhash64",
- "path": "/dist",
- "pathinfo": false,
- "publicPath": "/",
- "webassemblyModuleFilename": "static/wasm/[hash].module.wasm",
- },
- "plugins": [
- ForkTsCheckerWebpackPlugin {
- "options": {
- "issue": {
- "exclude": [
- {
- "file": "**/*.(spec|test).ts",
- },
- {
- "file": "**/node_modules/**/*",
- },
- ],
- },
- "logger": {
- "error": [Function],
- "log": [Function],
- },
- "typescript": {
- "configFile": "/tsconfig.json",
- "memoryLimit": 8192,
- "typescriptPath": "/node_modules//typescript/lib/typescript.js",
- },
- },
- },
- DefinePlugin {
- "_options": {
- "process.env.ASSET_PREFIX": "\\"\\"",
- "process.env.NODE_ENV": "\\"production\\"",
- },
- "affectedHooks": "compilation",
- "name": "DefinePlugin",
- },
- RemoveCssSourcemapPlugin {
- "htmlPlugin": [Function],
- "name": "RemoveCssSourcemapPlugin",
- },
- ProgressPlugin {
- "_options": {
- "prefix": "Client",
- "profile": false,
- },
- "affectedHooks": undefined,
- "name": "ProgressPlugin",
- },
- InlineChunkHtmlPlugin {
- "distPath": {
- "css": "static/css",
- "js": "static/js",
- },
- "htmlPlugin": [Function],
- "inlinedAssets": Set {},
- "name": "InlineChunkHtmlPlugin",
- "scriptTests": [
- /builder-runtime\\(\\[\\.\\]\\.\\+\\)\\?\\\\\\.js\\$/,
- ],
- "styleTests": [],
- },
- ],
- "resolve": {
- "alias": {
- "core-js": "/node_modules//core-js",
- },
- "extensions": [
- ".ts",
- ".tsx",
- ".js",
- ".jsx",
- ".mjs",
- ".json",
- ],
- "tsConfigPath": "/tsconfig.json",
- },
- "target": [
- "web",
- "es5",
- ],
-}
-`;
-
-exports[`applyDefaultPlugins > should apply default plugins correctyly when target = node 1`] = `
-{
- "builtins": {
- "css": {
- "modules": {
- "exportsOnly": true,
- "localIdentName": "[path][name]__[local]-[hash:6]",
- "localsConvention": "camelCase",
- },
- },
- "decorator": {
- "emitMetadata": true,
- "legacy": true,
- },
- "pluginImport": [
- {
- "libraryDirectory": "lib",
- "libraryName": "antd",
- "style": true,
- },
- {
- "camelToDashComponentName": false,
- "libraryDirectory": "lib",
- "libraryName": "@arco-design/web-react",
- "style": true,
- },
- {
- "camelToDashComponentName": false,
- "libraryDirectory": "react-icon-cjs",
- "libraryName": "@arco-design/web-react/icon",
- },
- ],
- "presetEnv": {
- "targets": [
- "node >= 14",
- ],
- },
- "react": {
- "development": true,
- "refresh": false,
- "runtime": "automatic",
- },
- },
- "context": "",
- "devServer": {
- "hot": false,
- },
- "devtool": "cheap-module-source-map",
- "experiments": {
- "asyncWebAssembly": true,
- "rspackFuture": {
- "disableTransformByDefault": false,
- },
- },
- "infrastructureLogging": {
- "level": "error",
- },
- "mode": "development",
- "module": {
- "rules": [
- {
- "resolve": {
- "fullySpecified": false,
- },
- "test": /\\\\\\.m\\?js/,
- },
- {
- "oneOf": [
- {
- "generator": {
- "filename": "static/font/[name].[contenthash:8][ext]",
- },
- "resourceQuery": /\\(__inline=false\\|url\\)/,
- "type": "asset/resource",
- },
- {
- "resourceQuery": /inline/,
- "type": "asset/inline",
- },
- {
- "generator": {
- "filename": "static/font/[name].[contenthash:8][ext]",
- },
- "parser": {
- "dataUrlCondition": {
- "maxSize": 10000,
- },
- },
- "type": "asset",
- },
- ],
- "test": /\\\\\\.\\(woff\\|woff2\\|eot\\|ttf\\|otf\\|ttc\\)\\$/i,
- },
- {
- "oneOf": [
- {
- "generator": {
- "filename": "static/image/[name].[contenthash:8][ext]",
- },
- "resourceQuery": /\\(__inline=false\\|url\\)/,
- "type": "asset/resource",
- },
- {
- "resourceQuery": /inline/,
- "type": "asset/inline",
- },
- {
- "generator": {
- "filename": "static/image/[name].[contenthash:8][ext]",
- },
- "parser": {
- "dataUrlCondition": {
- "maxSize": 10000,
- },
- },
- "type": "asset",
- },
- ],
- "test": /\\\\\\.\\(png\\|jpg\\|jpeg\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tiff\\)\\$/i,
- },
- {
- "oneOf": [
- {
- "generator": {
- "filename": "static/media/[name].[contenthash:8][ext]",
- },
- "resourceQuery": /\\(__inline=false\\|url\\)/,
- "type": "asset/resource",
- },
- {
- "resourceQuery": /inline/,
- "type": "asset/inline",
- },
- {
- "generator": {
- "filename": "static/media/[name].[contenthash:8][ext]",
- },
- "parser": {
- "dataUrlCondition": {
- "maxSize": 10000,
- },
- },
- "type": "asset",
- },
- ],
- "test": /\\\\\\.\\(mp4\\|webm\\|ogg\\|mp3\\|wav\\|flac\\|aac\\|mov\\)\\$/i,
- },
- {
- "oneOf": [
- {
- "generator": {
- "filename": "static/svg/[name].[contenthash:8].svg",
- },
- "issuer": {
- "not": [
- /\\\\\\.\\(js\\|mjs\\|cjs\\|jsx\\)\\$/,
- /\\\\\\.\\(ts\\|mts\\|cts\\|tsx\\)\\$/,
- ],
- },
- "resourceQuery": /\\(__inline=false\\|url\\)/,
- "type": "asset/resource",
- },
- {
- "issuer": {
- "not": [
- /\\\\\\.\\(js\\|mjs\\|cjs\\|jsx\\)\\$/,
- /\\\\\\.\\(ts\\|mts\\|cts\\|tsx\\)\\$/,
- ],
- },
- "resourceQuery": /inline/,
- "type": "asset/inline",
- },
- {
- "generator": {
- "filename": "static/svg/[name].[contenthash:8].svg",
- },
- "issuer": {
- "not": [
- /\\\\\\.\\(js\\|mjs\\|cjs\\|jsx\\)\\$/,
- /\\\\\\.\\(ts\\|mts\\|cts\\|tsx\\)\\$/,
- ],
- },
- "parser": {
- "dataUrlCondition": {
- "maxSize": 10000,
- },
- },
- "type": "asset",
- },
- {
- "resourceQuery": /inline/,
- "type": "asset/inline",
- },
- {
- "generator": {
- "filename": "static/svg/[name].[contenthash:8].svg",
- },
- "resourceQuery": /url/,
- "type": "asset/resource",
- },
- {
- "type": "javascript/auto",
- "use": [
- {
- "loader": "/node_modules//@svgr/webpack/dist/index.js",
- "options": {
- "svgo": true,
- "svgoConfig": {
- "plugins": [
- {
- "name": "preset-default",
- "params": {
- "overrides": {
- "removeViewBox": false,
- },
- },
- },
- "prefixIds",
- ],
- },
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/url-loader",
- "options": {
- "limit": 10000,
- "name": "static/svg/[name].[contenthash:8].svg",
- },
- },
- ],
- },
- ],
- "test": /\\\\\\.svg\\$/,
- },
- {
- "dependency": "url",
- "generator": {
- "filename": "static/wasm/[hash].module.wasm",
- },
- "test": /\\\\\\.wasm\\$/,
- "type": "asset/resource",
- },
- {
- "test": /\\\\\\.node\\$/,
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/node-loader",
- "options": {
- "name": [Function],
- },
- },
- ],
- },
- {
- "oneOf": [
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "test": /\\\\\\.module\\\\\\.\\\\w\\+\\$/i,
- "type": "css/module",
- },
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "type": "css",
- },
- ],
- "test": /\\\\\\.css\\$/,
- },
- {
- "oneOf": [
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "test": /\\\\\\.module\\\\\\.\\\\w\\+\\$/i,
- "type": "css/module",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/less-loader",
- "options": {
- "implementation": "/packages/builder/builder-shared/compiled/less",
- "lessOptions": {
- "javascriptEnabled": true,
- },
- "sourceMap": true,
- },
- },
- ],
- },
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "type": "css",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/less-loader",
- "options": {
- "implementation": "/packages/builder/builder-shared/compiled/less",
- "lessOptions": {
- "javascriptEnabled": true,
- },
- "sourceMap": true,
- },
- },
- ],
- },
- ],
- "test": /\\\\\\.less\\$/,
- },
- {
- "oneOf": [
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "test": /\\\\\\.module\\\\\\.\\\\w\\+\\$/i,
- "type": "css/module",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/resolve-url-loader",
- "options": {
- "join": [Function],
- "sourceMap": false,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/sass-loader",
- "options": {
- "implementation": "/packages/builder/builder-shared/compiled/sass",
- "sourceMap": true,
- },
- },
- ],
- },
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "type": "css",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/resolve-url-loader",
- "options": {
- "join": [Function],
- "sourceMap": false,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/sass-loader",
- "options": {
- "implementation": "/packages/builder/builder-shared/compiled/sass",
- "sourceMap": true,
- },
- },
- ],
- },
- ],
- "test": /\\\\\\.s\\(a\\|c\\)ss\\$/,
- },
- {
- "test": /\\\\\\.toml\\$/,
- "type": "javascript/auto",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/toml-loader",
- },
- ],
- },
- {
- "test": /\\\\\\.ya\\?ml\\$/,
- "type": "javascript/auto",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/yaml-loader",
- },
- ],
- },
- ],
- },
- "name": "Server",
- "optimization": {
- "minimize": false,
- "splitChunks": false,
- },
- "output": {
- "chunkFilename": "bundles/[name].js",
- "cssChunkFilename": "static/css/async/[name].css",
- "cssFilename": "static/css/[name].css",
- "filename": "bundles/[name].js",
- "hashFunction": "xxhash64",
- "libraryTarget": "commonjs2",
- "path": "/dist",
- "pathinfo": false,
- "publicPath": "/",
- "webassemblyModuleFilename": "static/wasm/[hash].module.wasm",
- },
- "plugins": [
- ForkTsCheckerWebpackPlugin {
- "options": {
- "issue": {
- "exclude": [
- {
- "file": "**/*.(spec|test).ts",
- },
- {
- "file": "**/node_modules/**/*",
- },
- ],
- },
- "logger": {
- "error": [Function],
- "log": [Function],
- },
- "typescript": {
- "configFile": "/tsconfig.json",
- "memoryLimit": 8192,
- "typescriptPath": "/node_modules//typescript/lib/typescript.js",
- },
- },
- },
- DefinePlugin {
- "_options": {
- "process.env.ASSET_PREFIX": "\\"\\"",
- "process.env.NODE_ENV": "\\"test\\"",
- },
- "affectedHooks": "compilation",
- "name": "DefinePlugin",
- },
- ProgressPlugin {
- "_options": {
- "prefix": "Server",
- "profile": false,
- },
- "affectedHooks": undefined,
- "name": "ProgressPlugin",
- },
- ],
- "resolve": {
- "conditionNames": [
- "require",
- "node",
- ],
- "extensions": [
- ".ts",
- ".tsx",
- ".js",
- ".jsx",
- ".mjs",
- ".json",
- ],
- "tsConfigPath": "/tsconfig.json",
- },
- "target": "node",
-}
-`;
-
-exports[`tools.rspack > should match snapshot 1`] = `
-{
- "builtins": {
- "css": {
- "modules": {
- "exportsOnly": false,
- "localIdentName": "[path][name]__[local]-[hash:6]",
- "localsConvention": "camelCase",
- },
- },
- "decorator": {
- "emitMetadata": true,
- "legacy": true,
- },
- "pluginImport": [
- {
- "libraryDirectory": "es",
- "libraryName": "antd",
- "style": true,
- },
- {
- "camelToDashComponentName": false,
- "libraryDirectory": "es",
- "libraryName": "@arco-design/web-react",
- "style": true,
- },
- {
- "camelToDashComponentName": false,
- "libraryDirectory": "react-icon",
- "libraryName": "@arco-design/web-react/icon",
- },
- ],
- "presetEnv": {
- "coreJs": "3.32",
- "mode": "entry",
- "targets": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "react": {
- "development": true,
- "refresh": true,
- "runtime": "automatic",
- },
- },
- "context": "",
- "devServer": {
- "hot": true,
- },
- "devtool": "cheap-module-source-map",
- "experiments": {
- "asyncWebAssembly": true,
- "rspackFuture": {
- "disableTransformByDefault": false,
- },
- },
- "infrastructureLogging": {
- "level": "error",
- },
- "mode": "development",
- "module": {
- "rules": [
- {
- "test": /\\\\\\.test\\$/,
- "use": [
- {
- "loader": "builtin:sass-loader",
- },
- ],
- },
- {
- "resolve": {
- "fullySpecified": false,
- },
- "test": /\\\\\\.m\\?js/,
- },
- {
- "oneOf": [
- {
- "generator": {
- "filename": "static/font/[name].[contenthash:8][ext]",
- },
- "resourceQuery": /\\(__inline=false\\|url\\)/,
- "type": "asset/resource",
- },
- {
- "resourceQuery": /inline/,
- "type": "asset/inline",
- },
- {
- "generator": {
- "filename": "static/font/[name].[contenthash:8][ext]",
- },
- "parser": {
- "dataUrlCondition": {
- "maxSize": 10000,
- },
- },
- "type": "asset",
- },
- ],
- "test": /\\\\\\.\\(woff\\|woff2\\|eot\\|ttf\\|otf\\|ttc\\)\\$/i,
- },
- {
- "oneOf": [
- {
- "generator": {
- "filename": "static/image/[name].[contenthash:8][ext]",
- },
- "resourceQuery": /\\(__inline=false\\|url\\)/,
- "type": "asset/resource",
- },
- {
- "resourceQuery": /inline/,
- "type": "asset/inline",
- },
- {
- "generator": {
- "filename": "static/image/[name].[contenthash:8][ext]",
- },
- "parser": {
- "dataUrlCondition": {
- "maxSize": 10000,
- },
- },
- "type": "asset",
- },
- ],
- "test": /\\\\\\.\\(png\\|jpg\\|jpeg\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tiff\\)\\$/i,
- },
- {
- "oneOf": [
- {
- "generator": {
- "filename": "static/media/[name].[contenthash:8][ext]",
- },
- "resourceQuery": /\\(__inline=false\\|url\\)/,
- "type": "asset/resource",
- },
- {
- "resourceQuery": /inline/,
- "type": "asset/inline",
- },
- {
- "generator": {
- "filename": "static/media/[name].[contenthash:8][ext]",
- },
- "parser": {
- "dataUrlCondition": {
- "maxSize": 10000,
- },
- },
- "type": "asset",
- },
- ],
- "test": /\\\\\\.\\(mp4\\|webm\\|ogg\\|mp3\\|wav\\|flac\\|aac\\|mov\\)\\$/i,
- },
- {
- "oneOf": [
- {
- "generator": {
- "filename": "static/svg/[name].[contenthash:8].svg",
- },
- "issuer": {
- "not": [
- /\\\\\\.\\(js\\|mjs\\|cjs\\|jsx\\)\\$/,
- /\\\\\\.\\(ts\\|mts\\|cts\\|tsx\\)\\$/,
- ],
- },
- "resourceQuery": /\\(__inline=false\\|url\\)/,
- "type": "asset/resource",
- },
- {
- "issuer": {
- "not": [
- /\\\\\\.\\(js\\|mjs\\|cjs\\|jsx\\)\\$/,
- /\\\\\\.\\(ts\\|mts\\|cts\\|tsx\\)\\$/,
- ],
- },
- "resourceQuery": /inline/,
- "type": "asset/inline",
- },
- {
- "generator": {
- "filename": "static/svg/[name].[contenthash:8].svg",
- },
- "issuer": {
- "not": [
- /\\\\\\.\\(js\\|mjs\\|cjs\\|jsx\\)\\$/,
- /\\\\\\.\\(ts\\|mts\\|cts\\|tsx\\)\\$/,
- ],
- },
- "parser": {
- "dataUrlCondition": {
- "maxSize": 10000,
- },
- },
- "type": "asset",
- },
- {
- "resourceQuery": /inline/,
- "type": "asset/inline",
- },
- {
- "generator": {
- "filename": "static/svg/[name].[contenthash:8].svg",
- },
- "resourceQuery": /url/,
- "type": "asset/resource",
- },
- {
- "type": "javascript/auto",
- "use": [
- {
- "loader": "/node_modules//@svgr/webpack/dist/index.js",
- "options": {
- "svgo": true,
- "svgoConfig": {
- "plugins": [
- {
- "name": "preset-default",
- "params": {
- "overrides": {
- "removeViewBox": false,
- },
- },
- },
- "prefixIds",
- ],
- },
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/url-loader",
- "options": {
- "limit": 10000,
- "name": "static/svg/[name].[contenthash:8].svg",
- },
- },
- ],
- },
- ],
- "test": /\\\\\\.svg\\$/,
- },
- {
- "dependency": "url",
- "generator": {
- "filename": "static/wasm/[hash].module.wasm",
- },
- "test": /\\\\\\.wasm\\$/,
- "type": "asset/resource",
- },
- {
- "oneOf": [
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "test": /\\\\\\.module\\\\\\.\\\\w\\+\\$/i,
- "type": "css/module",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- ],
- },
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "type": "css",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- ],
- },
- ],
- "test": /\\\\\\.css\\$/,
- },
- {
- "oneOf": [
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "test": /\\\\\\.module\\\\\\.\\\\w\\+\\$/i,
- "type": "css/module",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/less-loader",
- "options": {
- "implementation": "/packages/builder/builder-shared/compiled/less",
- "lessOptions": {
- "javascriptEnabled": true,
- },
- "sourceMap": true,
- },
- },
- ],
- },
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "type": "css",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/less-loader",
- "options": {
- "implementation": "/packages/builder/builder-shared/compiled/less",
- "lessOptions": {
- "javascriptEnabled": true,
- },
- "sourceMap": true,
- },
- },
- ],
- },
- ],
- "test": /\\\\\\.less\\$/,
- },
- {
- "oneOf": [
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "test": /\\\\\\.module\\\\\\.\\\\w\\+\\$/i,
- "type": "css/module",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/resolve-url-loader",
- "options": {
- "join": [Function],
- "sourceMap": false,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/sass-loader",
- "options": {
- "implementation": "/packages/builder/builder-shared/compiled/sass",
- "sourceMap": true,
- },
- },
- ],
- },
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "type": "css",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/resolve-url-loader",
- "options": {
- "join": [Function],
- "sourceMap": false,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/sass-loader",
- "options": {
- "implementation": "/packages/builder/builder-shared/compiled/sass",
- "sourceMap": true,
- },
- },
- ],
- },
- ],
- "test": /\\\\\\.s\\(a\\|c\\)ss\\$/,
- },
- {
- "test": /\\\\\\.toml\\$/,
- "type": "javascript/auto",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/toml-loader",
- },
- ],
- },
- {
- "test": /\\\\\\.ya\\?ml\\$/,
- "type": "javascript/auto",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/yaml-loader",
- },
- ],
- },
- ],
- },
- "name": "Client",
- "optimization": {
- "minimize": false,
- "runtimeChunk": {
- "name": "builder-runtime",
- },
- "splitChunks": {
- "cacheGroups": {
- "lib-antd": {
- "name": "lib-antd",
- "priority": 0,
- "reuseExistingChunk": true,
- "test": /\\[\\\\\\\\/\\]node_modules\\[\\\\\\\\/\\]\\(antd\\)\\[\\\\\\\\/\\]/,
- },
- "lib-arco": {
- "name": "lib-arco",
- "priority": 0,
- "reuseExistingChunk": true,
- "test": /\\[\\\\\\\\/\\]node_modules\\[\\\\\\\\/\\]\\(@\\?arco-design\\)\\[\\\\\\\\/\\]/,
- },
- "lib-axios": {
- "name": "lib-axios",
- "priority": 0,
- "reuseExistingChunk": true,
- "test": /\\[\\\\\\\\/\\]node_modules\\[\\\\\\\\/\\]\\(axios\\|axios-\\.\\+\\)\\[\\\\\\\\/\\]/,
- },
- "lib-lodash": {
- "name": "lib-lodash",
- "priority": 0,
- "reuseExistingChunk": true,
- "test": /\\[\\\\\\\\/\\]node_modules\\[\\\\\\\\/\\]\\(lodash\\|lodash-es\\)\\[\\\\\\\\/\\]/,
- },
- "lib-polyfill": {
- "name": "lib-polyfill",
- "priority": 0,
- "reuseExistingChunk": true,
- "test": /\\[\\\\\\\\/\\]node_modules\\[\\\\\\\\/\\]\\(tslib\\|core-js\\|@babel\\\\/runtime\\|@swc\\\\/helpers\\)\\[\\\\\\\\/\\]/,
- },
- "lib-react": {
- "name": "lib-react",
- "priority": 0,
- "reuseExistingChunk": true,
- "test": /\\[\\\\\\\\/\\]node_modules\\[\\\\\\\\/\\]\\(react\\|react-dom\\|scheduler\\)\\[\\\\\\\\/\\]/,
- },
- "lib-router": {
- "name": "lib-router",
- "priority": 0,
- "reuseExistingChunk": true,
- "test": /\\[\\\\\\\\/\\]node_modules\\[\\\\\\\\/\\]\\(react-router\\|react-router-dom\\|@remix-run\\\\/router\\|history\\)\\[\\\\\\\\/\\]/,
- },
- },
- "chunks": "all",
- "enforceSizeThreshold": 50000,
- },
- },
- "output": {
- "chunkFilename": "static/js/async/[name].js",
- "cssChunkFilename": "static/css/async/[name].css",
- "cssFilename": "static/css/[name].css",
- "filename": "static/js/[name].js",
- "hashFunction": "xxhash64",
- "path": "/dist",
- "pathinfo": false,
- "publicPath": "/",
- "webassemblyModuleFilename": "static/wasm/[hash].module.wasm",
- },
- "plugins": [
- TestPlugin {
- "name": "TestPlugin",
- },
- ForkTsCheckerWebpackPlugin {
- "options": {
- "issue": {
- "exclude": [
- {
- "file": "**/*.(spec|test).ts",
- },
- {
- "file": "**/node_modules/**/*",
- },
- ],
- },
- "logger": {
- "error": [Function],
- "log": [Function],
- },
- "typescript": {
- "configFile": "/tsconfig.json",
- "memoryLimit": 8192,
- "typescriptPath": "/node_modules//typescript/lib/typescript.js",
- },
- },
- },
- DefinePlugin {
- "_options": {
- "process.env.ASSET_PREFIX": "\\"\\"",
- "process.env.NODE_ENV": "\\"development\\"",
- },
- "affectedHooks": "compilation",
- "name": "DefinePlugin",
- },
- ProgressPlugin {
- "_options": {
- "prefix": "Client",
- "profile": false,
- },
- "affectedHooks": undefined,
- "name": "ProgressPlugin",
- },
- ProvidePlugin {
- "_options": {
- "$ReactRefreshRuntime$": [
- "/node_modules//@rspack/plugin-react-refresh/client/reactRefresh.js",
- ],
- },
- "affectedHooks": undefined,
- "name": "ProvidePlugin",
- },
- ],
- "resolve": {
- "alias": {
- "core-js": "/node_modules//core-js",
- },
- "extensions": [
- ".ts",
- ".tsx",
- ".js",
- ".jsx",
- ".mjs",
- ".json",
- ],
- "tsConfigPath": "/tsconfig.json",
- },
- "target": [
- "web",
- "es5",
- ],
-}
-`;
diff --git a/packages/builder/builder-rspack-provider/tests/plugins/__snapshots__/fallback.test.ts.snap b/packages/builder/builder-rspack-provider/tests/plugins/__snapshots__/fallback.test.ts.snap
deleted file mode 100644
index 6d4643fcd4a2..000000000000
--- a/packages/builder/builder-rspack-provider/tests/plugins/__snapshots__/fallback.test.ts.snap
+++ /dev/null
@@ -1,105 +0,0 @@
-// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
-
-exports[`plugins/fallback > should convert fallback rule correctly 1`] = `
-{
- "module": {
- "rules": [
- {
- "resolve": {
- "fullySpecified": false,
- },
- "test": /\\\\\\.m\\?js/,
- },
- {
- "oneOf": [
- {
- "test": /foo/,
- "use": [
- {
- "loader": "foo",
- },
- ],
- },
- {
- "mimetype": "text/javascript",
- "resolve": {
- "fullySpecified": false,
- },
- "use": [
- {
- "loader": "data-uri",
- },
- ],
- },
- {
- "test": /bar/,
- "use": [
- {
- "loader": "bar",
- },
- ],
- },
- {
- "exclude": [
- /\\\\\\.\\(js\\|mjs\\|cjs\\|jsx\\)\\$/,
- /\\\\\\.\\(ts\\|mts\\|cts\\|tsx\\)\\$/,
- /\\\\\\.html\\$/,
- /\\\\\\.json\\$/,
- ],
- "type": "asset/resource",
- },
- ],
- },
- ],
- },
- "output": {
- "assetModuleFilename": "static/media/[name].[contenthash:8][ext]",
- },
-}
-`;
-
-exports[`plugins/fallback > should not convert fallback rule when output.enableAssetFallback is not enabled 1`] = `
-{
- "module": {
- "rules": [
- {
- "resolve": {
- "fullySpecified": false,
- },
- "test": /\\\\\\.m\\?js/,
- },
- {
- "oneOf": [
- {
- "test": /foo/,
- "use": [
- {
- "loader": "foo",
- },
- ],
- },
- ],
- },
- {
- "mimetype": "text/javascript",
- "resolve": {
- "fullySpecified": false,
- },
- "use": [
- {
- "loader": "data-uri",
- },
- ],
- },
- {
- "test": /bar/,
- "use": [
- {
- "loader": "bar",
- },
- ],
- },
- ],
- },
-}
-`;
diff --git a/packages/builder/builder-rspack-provider/tests/plugins/__snapshots__/html.test.ts.snap b/packages/builder/builder-rspack-provider/tests/plugins/__snapshots__/html.test.ts.snap
deleted file mode 100644
index 32ab0d8d166f..000000000000
--- a/packages/builder/builder-rspack-provider/tests/plugins/__snapshots__/html.test.ts.snap
+++ /dev/null
@@ -1,186 +0,0 @@
-// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
-
-exports[`plugins/html > should allow to modify plugin options by tools.htmlPlugin 1`] = `
-{
- "entry": {
- "main": [
- "src/main.ts",
- ],
- },
- "plugins": [
- HtmlRspackPlugin {
- "name": "HtmlRspackPlugin",
- "userOptions": {
- "inject": true,
- },
- },
- ],
-}
-`;
-
-exports[`plugins/html > should allow to set favicon by html.favicon option 1`] = `
-{
- "entry": {
- "main": [
- "src/main.ts",
- ],
- },
- "plugins": [
- HtmlRspackPlugin {
- "name": "HtmlRspackPlugin",
- "userOptions": {
- "chunks": [
- "main",
- ],
- "favicon": "src/favicon.ico",
- "filename": "html/main/index.html",
- "inject": "head",
- "minify": false,
- "scriptLoading": "defer",
- "template": "/packages/builder/builder-shared/static/template.html",
- "templateParameters": [Function],
- },
- },
- ],
-}
-`;
-
-exports[`plugins/html > should allow to set inject by html.inject option 1`] = `
-{
- "entry": {
- "main": [
- "src/main.ts",
- ],
- },
- "plugins": [
- HtmlRspackPlugin {
- "name": "HtmlRspackPlugin",
- "userOptions": {
- "chunks": [
- "main",
- ],
- "filename": "html/main/index.html",
- "inject": "body",
- "minify": false,
- "scriptLoading": "defer",
- "template": "/packages/builder/builder-shared/static/template.html",
- "templateParameters": [Function],
- },
- },
- ],
-}
-`;
-
-exports[`plugins/html > should enable minify in production 1`] = `
-{
- "entry": {
- "main": [
- "src/main.ts",
- ],
- },
- "plugins": [
- HtmlRspackPlugin {
- "name": "HtmlRspackPlugin",
- "userOptions": {
- "chunks": [
- "main",
- ],
- "filename": "html/main/index.html",
- "inject": "head",
- "minify": {
- "collapseWhitespace": true,
- "keepClosingSlash": true,
- "minifyCSS": true,
- "minifyJS": {
- "format": {
- "ascii_only": true,
- },
- "mangle": {
- "safari10": true,
- },
- },
- "minifyURLs": true,
- "removeComments": false,
- "removeEmptyAttributes": true,
- "removeRedundantAttributes": true,
- "removeScriptTypeAttributes": true,
- "removeStyleLinkTypeAttributes": true,
- "useShortDoctype": true,
- },
- "scriptLoading": "defer",
- "template": "/packages/builder/builder-shared/static/template.html",
- "templateParameters": [Function],
- },
- },
- ],
-}
-`;
-
-exports[`plugins/html > should register html plugin correctly 1`] = `
-{
- "entry": {
- "main": [
- "src/main.ts",
- ],
- },
- "plugins": [
- HtmlRspackPlugin {
- "name": "HtmlRspackPlugin",
- "userOptions": {
- "chunks": [
- "main",
- ],
- "filename": "html/main/index.html",
- "inject": "head",
- "minify": false,
- "scriptLoading": "defer",
- "template": "/packages/builder/builder-shared/static/template.html",
- "templateParameters": [Function],
- },
- },
- ],
-}
-`;
-
-exports[`plugins/html > should support multi entry 1`] = `
-{
- "entry": {
- "foo": [
- "src/foo.ts",
- ],
- "main": [
- "src/main.ts",
- ],
- },
- "plugins": [
- HtmlRspackPlugin {
- "name": "HtmlRspackPlugin",
- "userOptions": {
- "chunks": [
- "main",
- ],
- "filename": "html/main/index.html",
- "inject": "head",
- "minify": false,
- "scriptLoading": "defer",
- "template": "foo",
- "templateParameters": [Function],
- },
- },
- HtmlRspackPlugin {
- "name": "HtmlRspackPlugin",
- "userOptions": {
- "chunks": [
- "foo",
- ],
- "filename": "html/foo/index.html",
- "inject": "head",
- "minify": false,
- "scriptLoading": "defer",
- "template": "bar",
- "templateParameters": [Function],
- },
- },
- ],
-}
-`;
diff --git a/packages/builder/builder-rspack-provider/tests/plugins/__snapshots__/output.test.ts.snap b/packages/builder/builder-rspack-provider/tests/plugins/__snapshots__/output.test.ts.snap
deleted file mode 100644
index 5a3492a702b9..000000000000
--- a/packages/builder/builder-rspack-provider/tests/plugins/__snapshots__/output.test.ts.snap
+++ /dev/null
@@ -1,140 +0,0 @@
-// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
-
-exports[`plugins/output > should allow to custom server directory with distPath.server 1`] = `
-{
- "output": {
- "chunkFilename": "server/[name].js",
- "cssChunkFilename": "static/css/async/[name].css",
- "cssFilename": "static/css/[name].css",
- "filename": "server/[name].js",
- "hashFunction": "xxhash64",
- "libraryTarget": "commonjs2",
- "path": "/dist",
- "pathinfo": false,
- "publicPath": "/",
- },
-}
-`;
-
-exports[`plugins/output > should allow to set distPath.js and distPath.css to empty string 1`] = `
-{
- "output": {
- "chunkFilename": "async/[name].js",
- "cssChunkFilename": "async/[name].css",
- "cssFilename": "[name].css",
- "filename": "[name].js",
- "hashFunction": "xxhash64",
- "path": "/dist",
- "pathinfo": false,
- "publicPath": "/",
- },
-}
-`;
-
-exports[`plugins/output > should allow to use copy plugin 1`] = `
-{
- "output": {
- "chunkFilename": "static/js/async/[name].js",
- "cssChunkFilename": "static/css/async/[name].css",
- "cssFilename": "static/css/[name].css",
- "filename": "static/js/[name].js",
- "hashFunction": "xxhash64",
- "path": "/dist",
- "pathinfo": false,
- "publicPath": "/",
- },
- "plugins": [
- CopyRspackPlugin {
- "_options": {
- "patterns": [
- {
- "force": false,
- "from": "test",
- "globOptions": {},
- "noErrorOnMissing": false,
- "priority": 0,
- },
- ],
- },
- "affectedHooks": undefined,
- "name": "CopyRspackPlugin",
- },
- ],
-}
-`;
-
-exports[`plugins/output > should allow to use copy plugin with multiply config 1`] = `
-{
- "output": {
- "chunkFilename": "static/js/async/[name].js",
- "cssChunkFilename": "static/css/async/[name].css",
- "cssFilename": "static/css/[name].css",
- "filename": "static/js/[name].js",
- "hashFunction": "xxhash64",
- "path": "/dist",
- "pathinfo": false,
- "publicPath": "/",
- },
- "plugins": [
- CopyRspackPlugin {
- "_options": {
- "patterns": [
- {
- "force": false,
- "from": "test",
- "globOptions": {},
- "noErrorOnMissing": false,
- "priority": 0,
- },
- {
- "force": false,
- "from": "src/assets/",
- "globOptions": {},
- "noErrorOnMissing": false,
- "priority": 0,
- },
- {
- "force": false,
- "from": "tests/",
- "globOptions": {},
- "noErrorOnMissing": false,
- "priority": 0,
- },
- ],
- },
- "affectedHooks": undefined,
- "name": "CopyRspackPlugin",
- },
- ],
-}
-`;
-
-exports[`plugins/output > should allow to use filename.js to modify filename 1`] = `
-{
- "output": {
- "chunkFilename": "static/js/async/foo.js",
- "cssChunkFilename": "static/css/async/[name].css",
- "cssFilename": "static/css/[name].css",
- "filename": "static/js/foo.js",
- "hashFunction": "xxhash64",
- "path": "/dist",
- "pathinfo": false,
- "publicPath": "/",
- },
-}
-`;
-
-exports[`plugins/output > should set output correctly 1`] = `
-{
- "output": {
- "chunkFilename": "static/js/async/[name].js",
- "cssChunkFilename": "static/css/async/[name].css",
- "cssFilename": "static/css/[name].css",
- "filename": "static/js/[name].js",
- "hashFunction": "xxhash64",
- "path": "/dist",
- "pathinfo": false,
- "publicPath": "/",
- },
-}
-`;
diff --git a/packages/builder/builder-rspack-provider/tests/plugins/__snapshots__/pug.test.ts.snap b/packages/builder/builder-rspack-provider/tests/plugins/__snapshots__/pug.test.ts.snap
deleted file mode 100644
index 40f96ae926cb..000000000000
--- a/packages/builder/builder-rspack-provider/tests/plugins/__snapshots__/pug.test.ts.snap
+++ /dev/null
@@ -1,47 +0,0 @@
-// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
-
-exports[`plugins/pug > should add pug correctly when tools.pug is used 1`] = `
-{
- "entry": {
- "foo": [
- "src/foo.ts",
- ],
- "main": [
- "src/main.ts",
- ],
- },
- "plugins": [
- HtmlRspackPlugin {
- "name": "HtmlRspackPlugin",
- "userOptions": {
- "chunks": [
- "main",
- ],
- "filename": "html/main/index.html",
- "inject": "head",
- "minify": false,
- "scriptLoading": "defer",
- "template": "foo.pug",
- "templateCompiler": {
- "compile": [Function],
- },
- "templateParameters": [Function],
- },
- },
- HtmlRspackPlugin {
- "name": "HtmlRspackPlugin",
- "userOptions": {
- "chunks": [
- "foo",
- ],
- "filename": "html/foo/index.html",
- "inject": "head",
- "minify": false,
- "scriptLoading": "defer",
- "template": "bar.html",
- "templateParameters": [Function],
- },
- },
- ],
-}
-`;
diff --git a/packages/builder/builder-rspack-provider/tests/plugins/__snapshots__/rem.test.ts.snap b/packages/builder/builder-rspack-provider/tests/plugins/__snapshots__/rem.test.ts.snap
deleted file mode 100644
index 8f6860cb2093..000000000000
--- a/packages/builder/builder-rspack-provider/tests/plugins/__snapshots__/rem.test.ts.snap
+++ /dev/null
@@ -1,1309 +0,0 @@
-// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
-
-exports[`plugins/rem > should not run htmlPlugin with enableRuntime is false 1`] = `
-{
- "builtins": {
- "css": {
- "modules": {
- "exportsOnly": false,
- "localIdentName": "[path][name]__[local]-[hash:6]",
- "localsConvention": "camelCase",
- },
- },
- },
- "module": {
- "rules": [
- {
- "oneOf": [
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "test": /\\\\\\.module\\\\\\.\\\\w\\+\\$/i,
- "type": "css/module",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- {
- "AtRule": [Function],
- "Declaration": [Function],
- "Once": [Function],
- "postcssPlugin": "postcss-pxtorem",
- },
- ],
- },
- "sourceMap": true,
- },
- },
- ],
- },
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "type": "css",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- {
- "AtRule": [Function],
- "Declaration": [Function],
- "Once": [Function],
- "postcssPlugin": "postcss-pxtorem",
- },
- ],
- },
- "sourceMap": true,
- },
- },
- ],
- },
- ],
- "test": /\\\\\\.css\\$/,
- },
- ],
- },
-}
-`;
-
-exports[`plugins/rem > should not run rem plugin when false 1`] = `
-{
- "builtins": {
- "css": {
- "modules": {
- "exportsOnly": false,
- "localIdentName": "[path][name]__[local]-[hash:6]",
- "localsConvention": "camelCase",
- },
- },
- },
- "module": {
- "rules": [
- {
- "oneOf": [
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "test": /\\\\\\.module\\\\\\.\\\\w\\+\\$/i,
- "type": "css/module",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- ],
- },
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "type": "css",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- ],
- },
- ],
- "test": /\\\\\\.css\\$/,
- },
- ],
- },
-}
-`;
-
-exports[`plugins/rem > should not run rem plugin without config 1`] = `
-{
- "builtins": {
- "css": {
- "modules": {
- "exportsOnly": false,
- "localIdentName": "[path][name]__[local]-[hash:6]",
- "localsConvention": "camelCase",
- },
- },
- },
- "module": {
- "rules": [
- {
- "oneOf": [
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "test": /\\\\\\.module\\\\\\.\\\\w\\+\\$/i,
- "type": "css/module",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- ],
- },
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "type": "css",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- ],
- },
- "sourceMap": true,
- },
- },
- ],
- },
- ],
- "test": /\\\\\\.css\\$/,
- },
- ],
- },
-}
-`;
-
-exports[`plugins/rem > should order plugins and run rem plugin with default config 1`] = `
-{
- "builtins": {
- "css": {
- "modules": {
- "exportsOnly": false,
- "localIdentName": "[path][name]__[local]-[hash:6]",
- "localsConvention": "camelCase",
- },
- },
- },
- "module": {
- "rules": [
- {
- "oneOf": [
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "test": /\\\\\\.module\\\\\\.\\\\w\\+\\$/i,
- "type": "css/module",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- {
- "AtRule": [Function],
- "Declaration": [Function],
- "Once": [Function],
- "postcssPlugin": "postcss-pxtorem",
- },
- ],
- },
- "sourceMap": true,
- },
- },
- ],
- },
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "type": "css",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- {
- "AtRule": [Function],
- "Declaration": [Function],
- "Once": [Function],
- "postcssPlugin": "postcss-pxtorem",
- },
- ],
- },
- "sourceMap": true,
- },
- },
- ],
- },
- ],
- "test": /\\\\\\.css\\$/,
- },
- {
- "oneOf": [
- {
- "resolve": {
- "preferRelative": true,
- },
- "sideEffects": true,
- "test": /\\\\\\.module\\\\\\.\\\\w\\+\\$/i,
- "type": "css/module",
- "use": [
- {
- "loader": "/packages/builder/builder-shared/compiled/postcss-loader",
- "options": {
- "postcssOptions": {
- "plugins": [
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- [Function],
- {
- "browsers": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- "info": [Function],
- "options": {
- "flexbox": "no-2009",
- "overrideBrowserslist": [
- "> 0.01%",
- "not dead",
- "not op_mini all",
- ],
- },
- "postcssPlugin": "autoprefixer",
- "prepare": [Function],
- },
- {
- "AtRule": [Function],
- "Declaration": [Function],
- "Once": [Function],
- "postcssPlugin": "postcss-pxtorem",
- },
- ],
- },
- "sourceMap": true,
- },
- },
- {
- "loader": "/packages/builder/builder-shared/compiled/less-loader",
- "options": {
- "implementation": "