Commit 000feaa0 authored by 邓晓峰's avatar 邓晓峰

fix: 修复esm commonjs build

parent 40fada3b
...@@ -26,15 +26,34 @@ const tailPkgs = pkgList ...@@ -26,15 +26,34 @@ const tailPkgs = pkgList
return `${path}/${name}`; return `${path}/${name}`;
}); });
export default { const type = process.env.BUILD_TYPE;
cjs: { type: 'babel', lazy: true }, let config = {};
esm: {
type: 'babel', if (type === 'lib') {
importLibToEs: true, config = {
}, cjs: { type: 'babel', lazy: true },
pkgs: [...headPkgs, ...tailPkgs], esm: false,
extraBabelPlugins: [ runtimeHelpers: true,
['babel-plugin-import', { libraryName: 'antd', libraryDirectory: 'es', style: true }, 'antd'], pkgs: [...headPkgs, ...tailPkgs],
[require('./scripts/replaceLib')], extraBabelPlugins: [
], ['babel-plugin-import', { libraryName: 'antd', libraryDirectory: 'es', style: true }, 'antd'],
}; ],
};
}
if (type === 'es') {
config = {
cjs: false,
esm: {
type: 'babel',
},
runtimeHelpers: true,
pkgs: [...headPkgs, ...tailPkgs],
extraBabelPlugins: [
[require('./scripts/replaceLib')],
['babel-plugin-import', { libraryName: 'antd', libraryDirectory: 'es', style: true }, 'antd'],
],
};
}
export default config;
# .npmrc
node-options=--max_old_space_size=8192
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
], ],
"scripts": { "scripts": {
"bootstrap": "node ./scripts/bootstrap.js", "bootstrap": "node ./scripts/bootstrap.js",
"build": "cross-env BUILD_TYPE=lib father-build && cross-env BUILD_TYPE=es father-build && webpack && node ./scripts/gen_less_entry.js", "build": "npm run build-lib && webpack && node ./scripts/gen_less_entry.js",
"build-lib": "cross-env BUILD_TYPE=lib father-build && cross-env BUILD_TYPE=es father-build",
"changelog": "pro-changelog", "changelog": "pro-changelog",
"createRelease": "node ./scripts/createRelease.js", "createRelease": "node ./scripts/createRelease.js",
"deploy": "npm run site && gh-pages -d ./dist", "deploy": "npm run site && gh-pages -d ./dist",
...@@ -42,6 +43,8 @@ ...@@ -42,6 +43,8 @@
"@babel/preset-env": "^7.8.3", "@babel/preset-env": "^7.8.3",
"@babel/preset-react": "^7.8.3", "@babel/preset-react": "^7.8.3",
"@babel/preset-typescript": "^7.8.3", "@babel/preset-typescript": "^7.8.3",
"@babel/runtime": "^7.17.9",
"@babel/plugin-transform-runtime": "^7.17.10",
"@octokit/core": "^3.2.5", "@octokit/core": "^3.2.5",
"@size-limit/preset-big-lib": "^4.5.5", "@size-limit/preset-big-lib": "^4.5.5",
"@testing-library/react": "^10.0.2", "@testing-library/react": "^10.0.2",
...@@ -62,6 +65,7 @@ ...@@ -62,6 +65,7 @@
"@types/warning": "^3.0.0", "@types/warning": "^3.0.0",
"@types/xhr-mock": "^2.0.0", "@types/xhr-mock": "^2.0.0",
"@umijs/babel-preset-umi": "^3.0.14", "@umijs/babel-preset-umi": "^3.0.14",
"@umijs/doctor": "^0.0.16",
"@umijs/fabric": "^2.0.0", "@umijs/fabric": "^2.0.0",
"@umijs/plugin-analytics": "^0.2.2", "@umijs/plugin-analytics": "^0.2.2",
"@umijs/plugin-antd": "^0.9.0", "@umijs/plugin-antd": "^0.9.0",
......
...@@ -22,5 +22,8 @@ ...@@ -22,5 +22,8 @@
}, },
"scripts": { "scripts": {
"test": "echo \"Error: run tests from root\" && exit 1" "test": "echo \"Error: run tests from root\" && exit 1"
},
"dependencies": {
"@babel/runtime": "^7.17.9"
} }
} }
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
"test": "echo \"Error: run tests from root\" && exit 1" "test": "echo \"Error: run tests from root\" && exit 1"
}, },
"dependencies": { "dependencies": {
"classnames": "^2.2.6" "classnames": "^2.2.6",
"@babel/runtime": "^7.17.9"
} }
} }
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
"test": "echo \"Error: run tests from root\" && exit 1" "test": "echo \"Error: run tests from root\" && exit 1"
}, },
"dependencies": { "dependencies": {
"moment": "^2.27.0" "moment": "^2.27.0",
"@babel/runtime": "^7.17.9"
} }
} }
...@@ -22,5 +22,8 @@ ...@@ -22,5 +22,8 @@
}, },
"scripts": { "scripts": {
"test": "echo \"Error: run tests from root\" && exit 1" "test": "echo \"Error: run tests from root\" && exit 1"
},
"dependencies": {
"@babel/runtime": "^7.17.9"
} }
} }
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
"test": "echo \"Error: run tests from root\" && exit 1" "test": "echo \"Error: run tests from root\" && exit 1"
}, },
"dependencies": { "dependencies": {
"classnames": "^2.2.6" "classnames": "^2.2.6",
"@babel/runtime": "^7.17.9"
} }
} }
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
"url": "https://g.civnet.cn:8443/ReactWeb5/wisdom-components.git" "url": "https://g.civnet.cn:8443/ReactWeb5/wisdom-components.git"
}, },
"dependencies": { "dependencies": {
"classnames": "^2.2.6" "classnames": "^2.2.6",
"@babel/runtime": "^7.17.9"
} }
} }
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
}, },
"dependencies": { "dependencies": {
"js-export-excel": "^1.1.4", "js-export-excel": "^1.1.4",
"jszip": "^3.5.0" "jszip": "^3.5.0",
"@babel/runtime": "^7.17.9"
} }
} }
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
"classnames": "^2.2.6", "classnames": "^2.2.6",
"highcharts": "^9.0.1", "highcharts": "^9.0.1",
"highcharts-react-official": "^3.0.0", "highcharts-react-official": "^3.0.0",
"moment": "^2.27.0" "moment": "^2.27.0",
"@babel/runtime": "^7.17.9"
} }
} }
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
"test": "echo \"Error: run tests from root\" && exit 1" "test": "echo \"Error: run tests from root\" && exit 1"
}, },
"dependencies": { "dependencies": {
"classnames": "^2.2.6" "classnames": "^2.2.6",
"@babel/runtime": "^7.17.9"
} }
} }
...@@ -22,5 +22,8 @@ ...@@ -22,5 +22,8 @@
}, },
"scripts": { "scripts": {
"test": "echo \"Error: run tests from root\" && exit 1" "test": "echo \"Error: run tests from root\" && exit 1"
},
"dependencies": {
"@babel/runtime": "^7.17.9"
} }
} }
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
"test": "echo \"Error: run tests from root\" && exit 1" "test": "echo \"Error: run tests from root\" && exit 1"
}, },
"dependencies": { "dependencies": {
"mqtt-client": "^1.0.12" "mqtt-client": "^1.0.12",
"@babel/runtime": "^7.17.9"
} }
} }
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
}, },
"dependencies": { "dependencies": {
"form-render": "^0.9.12", "form-render": "^0.9.12",
"parseForm": "^0.0.8" "parseForm": "^0.0.8",
"@babel/runtime": "^7.17.9"
} }
} }
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
"test": "echo \"Error: run tests from root\" && exit 1" "test": "echo \"Error: run tests from root\" && exit 1"
}, },
"dependencies": { "dependencies": {
"classnames": "^2.2.6" "classnames": "^2.2.6",
"@babel/runtime": "^7.17.9"
} }
} }
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
"test": "echo \"Error: run tests from root\" && exit 1" "test": "echo \"Error: run tests from root\" && exit 1"
}, },
"dependencies": { "dependencies": {
"classnames": "^2.2.6" "classnames": "^2.2.6",
"@babel/runtime": "^7.17.9"
} }
} }
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
"test": "echo \"Error: run tests from root\" && exit 1" "test": "echo \"Error: run tests from root\" && exit 1"
}, },
"dependencies": { "dependencies": {
"classnames": "^2.2.6" "classnames": "^2.2.6",
"@babel/runtime": "^7.17.9"
} }
} }
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
"build": "father-build" "build": "father-build"
}, },
"dependencies": { "dependencies": {
"lodash": "^4.17.21" "lodash": "^4.17.21",
"@babel/runtime": "^7.17.9"
} }
} }
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
"dependencies": { "dependencies": {
"@wisdom-components/ec_historyinfo": "1.2.20", "@wisdom-components/ec_historyinfo": "1.2.20",
"@wisdom-components/mqttview": "1.3.4", "@wisdom-components/mqttview": "1.3.4",
"cross-env": "^7.0.3" "cross-env": "^7.0.3",
"@babel/runtime": "^7.17.9"
} }
} }
...@@ -22,5 +22,8 @@ ...@@ -22,5 +22,8 @@
}, },
"scripts": { "scripts": {
"test": "echo \"Error: run tests from root\" && exit 1" "test": "echo \"Error: run tests from root\" && exit 1"
},
"dependencies": {
"@babel/runtime": "^7.17.9"
} }
} }
...@@ -22,5 +22,8 @@ ...@@ -22,5 +22,8 @@
}, },
"scripts": { "scripts": {
"test": "echo \"Error: run tests from root\" && exit 1" "test": "echo \"Error: run tests from root\" && exit 1"
},
"dependencies": {
"@babel/runtime": "^7.17.9"
} }
} }
...@@ -22,5 +22,8 @@ ...@@ -22,5 +22,8 @@
}, },
"scripts": { "scripts": {
"test": "echo \"Error: run tests from root\" && exit 1" "test": "echo \"Error: run tests from root\" && exit 1"
},
"dependencies": {
"@babel/runtime": "^7.17.9"
} }
} }
...@@ -22,5 +22,8 @@ ...@@ -22,5 +22,8 @@
}, },
"scripts": { "scripts": {
"test": "echo \"Error: run tests from root\" && exit 1" "test": "echo \"Error: run tests from root\" && exit 1"
},
"dependencies": {
"@babel/runtime": "^7.17.9"
} }
} }
const docker = require('@umijs/doctor');
const path = require('path');
const repo_path = path.join(__dirname, '..');
const genChangelogs = () => {
docker.genChangelogs(repo_path);
};
genChangelogs();
...@@ -52,6 +52,7 @@ const getMds = (allVersion = false) => { ...@@ -52,6 +52,7 @@ const getMds = (allVersion = false) => {
.filter((tag) => tag.includes(pkg)) .filter((tag) => tag.includes(pkg))
.map((tag) => tag.split('@').pop()); .map((tag) => tag.split('@').pop());
} }
console.log(versions.toString());
// eslint-disable-next-line array-callback-return // eslint-disable-next-line array-callback-return
versions.map((version) => { versions.map((version) => {
const versionPkg = `@wisdom-components/pro-${pkg}@${version}`; const versionPkg = `@wisdom-components/pro-${pkg}@${version}`;
......
...@@ -127,8 +127,8 @@ async function release() { ...@@ -127,8 +127,8 @@ async function release() {
const pkgs = args.publishOnly ? getPackages() : updated; const pkgs = args.publishOnly ? getPackages() : updated;
logStep(`publish packages: ${chalk.blue(pkgs.join(', '))}`); logStep(`publish packages: ${chalk.blue(pkgs.join(', '))}`);
// eslint-disable-next-line consistent-return // eslint-disable-next-line consistent-return,array-callback-return
pkgs.forEach((pkg, index) => { const publishList = pkgs.map((pkg, index) => {
const pkgMap = locMap[pkg]; const pkgMap = locMap[pkg];
const [p, shortName] = pkgMap.split('/'); const [p, shortName] = pkgMap.split('/');
const pkgPath = join(cwd, 'packages', p, shortName.replace('pro-', '')); const pkgPath = join(cwd, 'packages', p, shortName.replace('pro-', ''));
...@@ -147,14 +147,16 @@ async function release() { ...@@ -147,14 +147,16 @@ async function release() {
console.log( console.log(
`[${index + 1}/${pkgs.length}] Publish package ${name} ${isNext ? 'with next tag' : ''}`, `[${index + 1}/${pkgs.length}] Publish package ${name} ${isNext ? 'with next tag' : ''}`,
); );
const cliArgs = isNext ? ['publish', '--tag', 'next'] : ['publish']; const cliArgs = isNext ? ['publish', '--tag', 'next'] : ['publish', '--tag', 'beta'];
const { stdout } = execa.sync('npm', cliArgs, { return execa('npm', cliArgs, {
cwd: pkgPath, cwd: pkgPath,
}); });
console.log(stdout);
} }
}); });
console.log(`发布中${pkgs.join('/')}`);
await Promise.all(publishList);
console.log('发布成功! ');
await exec('npm', ['run', 'prettier']); await exec('npm', ['run', 'prettier']);
logStep('done'); logStep('done');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment