Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: revert compile with lib #38832

Merged
merged 4 commits into from Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 8 additions & 10 deletions .antd-tools.config.js
@@ -1,23 +1,21 @@
const fs = require('fs');
const path = require('path');

const restCssPath = path.join(process.cwd(), 'components', 'style', 'reset.css');

function finalizeCompile() {
if (fs.existsSync(path.join(__dirname, './es'))) {
// Build less entry file: dist/antd.less
fs.copyFileSync(
path.join(process.cwd(), 'components', 'style', 'reset.css'),
path.join(process.cwd(), 'es', 'style', 'reset.css'),
);
fs.copyFileSync(restCssPath, path.join(process.cwd(), 'es', 'style', 'reset.css'));
}

if (fs.existsSync(path.join(__dirname, './lib'))) {
fs.copyFileSync(restCssPath, path.join(process.cwd(), 'lib', 'style', 'reset.css'));
}
}

function finalizeDist() {
if (fs.existsSync(path.join(__dirname, './dist'))) {
// Build less entry file: dist/antd.less
fs.copyFileSync(
path.join(process.cwd(), 'components', 'style', 'reset.css'),
path.join(process.cwd(), 'dist', 'reset.css'),
);
fs.copyFileSync(restCssPath, path.join(process.cwd(), 'dist', 'reset.css'));
}
}

Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/test.yml
Expand Up @@ -250,6 +250,12 @@ jobs:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}

- name: cache lib
uses: actions/cache@v3
with:
path: lib
key: lib-${{ github.sha }}

- name: cache es
uses: actions/cache@v3
with:
Expand All @@ -258,6 +264,9 @@ jobs:

- name: compile
run: npm run compile

- name: check
run: node ./tests/dekko/lib.test.js
needs: setup

compiled-module-test:
Expand All @@ -266,7 +275,7 @@ jobs:
strategy:
matrix:
react: ['16', '17', '18']
module: [es]
module: [lib, es]
shard: ['1/2', '2/2']
env:
REACT: ${{ matrix.react }}
Expand Down
9 changes: 5 additions & 4 deletions package.json
Expand Up @@ -33,12 +33,13 @@
"files": [
"dist",
"es",
"lib",
"locale"
],
"sideEffects": [
"*.less"
],
"main": "dist/antd.js",
"main": "lib/index.js",
"module": "es/index.js",
"unpkg": "dist/antd.min.js",
"typings": "es/index.d.ts",
Expand All @@ -59,7 +60,7 @@
"pretest": "npm run version",
"predist": "npm run version",
"presite": "npm run version && npm run collect-token-statistic",
"compile": "npm run clean && antd-tools run compile-experimental",
"compile": "npm run clean && antd-tools run compile",
"changelog": "node ./scripts/print-changelog",
"predeploy": "antd-tools run clean && npm run site && cp CNAME _site && npm run site:test",
"deploy": "gh-pages -d _site -b gh-pages -f",
Expand All @@ -77,7 +78,7 @@
"lint:script": "eslint . --ext .js,.jsx,.ts,.tsx",
"pre-publish": "npm run test-all -- --skip-build",
"prettier": "prettier -c --write **/*",
"pub": "npm run version && npm run collect-token-statistic && antd-tools run pub-experimental",
"pub": "npm run version && npm run collect-token-statistic && antd-tools run pub",
"rome:format": "rome format --write .",
"prepublishOnly": "antd-tools run guard",
"postpublish": "node ./scripts/post-script.js",
Expand Down Expand Up @@ -157,7 +158,7 @@
"devDependencies": {
"@ant-design/bisheng-plugin": "^3.3.0-alpha.4",
"@ant-design/hitu": "^0.0.0-alpha.13",
"@ant-design/tools": "^16.0.0-alpha.3",
"@ant-design/tools": "^16.1.0-alpha.2",
"@docsearch/css": "^3.0.0",
"@emotion/babel-preset-css-prop": "^11.10.0",
"@emotion/css": "^11.10.5",
Expand Down
60 changes: 60 additions & 0 deletions tests/dekko/lib.test.js
@@ -0,0 +1,60 @@
const $ = require('dekko');
const chalk = require('chalk');
const path = require('path');

function getFileName(filePath) {
return filePath.slice(filePath.lastIndexOf(path.sep) + 1);
}

$('lib').isDirectory().hasFile('index.js').hasFile('index.d.ts');

$('lib/*')
.filter(
(filename) =>
!filename.endsWith('index.js') &&
!filename.endsWith('index.d.ts') &&
!filename.endsWith('.map'),
)
.isDirectory()
.filter(
(filename) =>
!filename.endsWith('style') && !filename.endsWith('_util') && !filename.endsWith('locale'),
)
.hasFile('index.js')
.hasFile('index.d.ts');

// locale

const filterLocaleFile = (filePath) => {
const fileName = getFileName(filePath);
return (
!fileName.endsWith('index.js') &&
!fileName.endsWith('.d.ts') &&
!fileName.endsWith('.map') &&
!fileName.endsWith('style') &&
!fileName.includes('-') &&
!fileName.endsWith('LocaleReceiver.js') &&
!fileName.endsWith('context.js')
);
};
const localeFiles = $('lib/locale/*').filter(filterLocaleFile);
const localeProviderFiles = $('lib/locale-provider/*').filter(filterLocaleFile);

function compare(originFiles, targetFiles, targetPath) {
originFiles.assert(
`not exist in '${targetPath}'. Please use 'scripts/generateLegacyLocale.js' to refresh locale files.`,
(filePath) => {
const fileName = getFileName(filePath);

return targetFiles.filenames.some(
(targetFilePath) => getFileName(targetFilePath) === fileName,
);
},
);
}

compare(localeFiles, localeProviderFiles, '/locale-provider');
compare(localeProviderFiles, localeFiles, '/locale');

// eslint-disable-next-line no-console
console.log(chalk.green('✨ `lib` directory is valid.'));