chore: migrate from antd-tools to father to bundle umd (#54534)

This commit is contained in:
zoomdong
2025-08-20 15:36:56 +08:00
committed by GitHub
parent 519a994981
commit 14bd9dd797
5 changed files with 81 additions and 4 deletions

71
.fatherrc.ts Normal file
View File

@@ -0,0 +1,71 @@
import { defineConfig } from 'father';
import path from 'path';
const externalsConfig = {
react: {
root: 'React',
commonjs: 'react',
},
dayjs: {
root: 'dayjs',
commonjs: 'dayjs',
},
'react-dom': {
root: 'ReactDOM',
commonjs: 'react-dom',
},
};
const resolveAliasConfig = {
'@ant-design/cssinjs': path.resolve(__dirname, 'alias/cssinjs'),
};
// const restCssPath = path.join(process.cwd(), 'components', 'style', 'reset.css');
// const outputResetCssPath = path.join(process.cwd(), 'dist', 'reset.css');
export default defineConfig({
umd: {
entry: {
'./index.js': {
name: 'antd',
sourcemap: true,
generateUnminified: true,
bundler: 'utoopack',
externals: externalsConfig,
output: {
path: './dist',
filename: 'antd.js',
},
alias: {
...resolveAliasConfig,
},
concatenateModules: true,
},
'./index-with-locales.js': {
name: 'antd',
sourcemap: true,
generateUnminified: true,
bundler: 'utoopack',
externals: externalsConfig,
output: {
path: './dist',
filename: 'antd-with-locales.js',
},
alias: {
...resolveAliasConfig,
},
concatenateModules: true,
},
},
copy: [
{
from: './components/style/reset.css',
to: './reset.css',
},
{
from: './components/style/antd.css',
to: './antd.css',
},
],
},
});

View File

@@ -22,6 +22,8 @@ const transformIgnorePatterns = [
// Ignore modules without es dir.
// Update: @babel/runtime should also be transformed
`[/\\\\]node_modules[/\\\\](?!${ignoreList.join('|')})[^/\\\\]+?[/\\\\](?!(es)[/\\\\])`,
// Ignore antd umd js file
'[/\\\\]dist[/\\\\]antd.*\\.js$',
];
function getTestRegex(libDir) {

1
.npmrc
View File

@@ -2,3 +2,4 @@ package-lock=false
legacy-peer-deps=true
PUPPETEER_DOWNLOAD_BASE_URL="https://cdn.npmmirror.com/binaries/chrome-for-testing"
npm_config_sharp_libvips_binary_host="https://cdn.npmmirror.com/binaries/sharp-libvips"
public-hoist-pattern[]=@utoo/pack

View File

@@ -2,11 +2,13 @@ const antd = require('./components');
const req = require.context('./components', true, /^\.\/locale\/[A-Za-z]+_[A-Za-z]+\.tsx?$/);
antd.locales = {};
const antdWithLocales = { ...antd };
antdWithLocales.locales = {};
req.keys().forEach((mod) => {
const matches = mod.match(/\/([^/]+).tsx?$/);
antd.locales[matches[1]] = req(mod).default;
antdWithLocales.locales[matches[1]] = req(mod).default;
});
module.exports = antd;
module.exports = antdWithLocales;

View File

@@ -55,7 +55,7 @@
"deploy": "gh-pages -d _site -b gh-pages -f",
"deploy:china-mirror": "git checkout gh-pages && git pull origin gh-pages && git push git@gitee.com:ant-design/ant-design.git gh-pages -f",
"predist": "npm run version && npm run token:statistic && npm run token:meta && npm run style",
"dist": "antd-tools run dist",
"dist": "father build",
"format": "biome format --write .",
"install-react-18": "npm i --no-save --legacy-peer-deps react@18 react-dom@18 @testing-library/react@16",
"bun-install-react-18": "bun remove react react-dom @testing-library/react && bun add --no-save react@18 react-dom@18 @testing-library/react@16",
@@ -249,6 +249,7 @@
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.14",
"fast-glob": "^3.3.2",
"father": "4.6.2-canary.2",
"fs-extra": "^11.2.0",
"gh-pages": "^6.2.0",
"github-slugger": "^2.0.0",