Skip to content

Commit

Permalink
feat: commands for generating d.ts files
Browse files Browse the repository at this point in the history
  • Loading branch information
bushuai committed Dec 24, 2020
1 parent 217c6b7 commit cb3e166
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"@types/enzyme": "^3.1.12",
"@types/jest": "^23.3.1",
"@types/lodash": "^4.14.165",
"@types/node": "^10.5.2",
"@types/node": "^10.17.49",
"@types/react": "16.4.7",
"@types/react-dom": "16.0.7",
"@types/react-transition-group": "^2.9.2",
Expand Down
15 changes: 1 addition & 14 deletions tools/buildDist.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const webpack = require('webpack');
const ora = require('ora');
const config = require('../webpack.config.prod.dist');
const {chalkError, chalkSuccess, chalkWarning, chalkProcessing} = require('./chalkConfig');
// const copyComponentsStyle = require('./copyComponentsStyle');

console.log(chalkProcessing('dist: Generating minified bundle for production via Webpack. This will take a moment...'));

Expand All @@ -19,30 +18,19 @@ webpack(config).run((error, stats) => {
if (error) { // so a fatal error occurred. Stop here.
console.log(chalkError(error));
process.exit(1);
return 1;
}

const jsonStats = stats.toJson();

if (jsonStats.hasErrors) {
jsonStats.errors.map(error => console.log(chalkError(error)));
process.exit(1);
return;
}

if (jsonStats.hasWarnings) {
console.log(chalkWarning('Webpack generated the following warnings: '));
jsonStats.warnings.map(warning => console.log(chalkWarning(warning)));
}
spinner.start('dist: Copying style files...');
// try{
// copyComponentsStyle();
// }catch(e){
// console.log(chalkError(e));
// process.exit(1);
// return;
// }
spinner.stop();

console.log(stats.toString({
colors: true,
Expand All @@ -56,6 +44,5 @@ webpack(config).run((error, stats) => {

// if we got this far, the build succeeded.
console.log(chalkSuccess('Your app is compiled in production mode in /dist. It\'s ready to roll!'));

return 0;
process.exit(0);
});
4 changes: 3 additions & 1 deletion tools/buildOthers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,16 @@ cd ../../

# CommonJS
babel "./$temp_dir/" --out-dir "./$lib_dir/"
tsc --emitDeclarationOnly --outDir lib
node tools/compileTs/copy.js $lib_dir $node_dir

# less 编译为 css
compileLess $node_dir

# ES6
setBabelModules false
babel "./$temp_dir/" --out-dir "./$es_dir/"

tsc --emitDeclarationOnly --outDir es
# 清理、还原
rm -rf $temp_dir
setBabelModules commonjs
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"compilerOptions": {
"outDir": "./dist/",
"sourceMap": false,
"declaration": true,
"experimentalDecorators": true,
"module": "commonjs",
"target": "es5",
Expand Down

0 comments on commit cb3e166

Please sign in to comment.