diff --git a/.fatherrc.ts b/.fatherrc.ts new file mode 100644 index 0000000000..7b58ba5f21 --- /dev/null +++ b/.fatherrc.ts @@ -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', + }, + ], + }, +}); diff --git a/.jest.js b/.jest.js index ab60544fd3..5da2852d24 100644 --- a/.jest.js +++ b/.jest.js @@ -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) { diff --git a/.npmrc b/.npmrc index 7b86c0ecce..6d9bc77221 100644 --- a/.npmrc +++ b/.npmrc @@ -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 \ No newline at end of file diff --git a/index-with-locales.js b/index-with-locales.js index 173bfb7d9f..2514604dce 100644 --- a/index-with-locales.js +++ b/index-with-locales.js @@ -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; diff --git a/package.json b/package.json index 4914b19944..8edc8bab20 100644 --- a/package.json +++ b/package.json @@ -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",