feat:update cli template

This commit is contained in:
pengfei.zhou 2020-03-27 15:52:33 +08:00 committed by osborn
parent 438f729ec6
commit a0d72af82c
3 changed files with 34 additions and 28 deletions

View File

@ -19,6 +19,7 @@
"devDependencies": {
"@rollup/plugin-commonjs": "^11.0.1",
"@rollup/plugin-node-resolve": "^7.0.0",
"@rollup/plugin-buble": "^0.21.0"
"@rollup/plugin-buble": "^0.21.0",
"@rollup/plugin-json": "^4.0.2"
}
}

View File

@ -3,7 +3,8 @@ import commonjs from '@rollup/plugin-commonjs'
import bundles from './build/index'
import fs from 'fs'
import path from 'path'
import buble from '@rollup/plugin-buble';
import babel from 'rollup-plugin-babel';
import json from '@rollup/plugin-json'
function readDirs(dirPath, files) {
if (fs.statSync(dirPath).isDirectory()) {
@ -49,6 +50,7 @@ export default
plugins: [
resolve({ mainFields: ["jsnext"] }),
commonjs(),
json(),
],
external: ['reflect-metadata', 'doric'],
onwarn: function (warning) {
@ -56,28 +58,30 @@ export default
console.warn(warning.message);
}
}
}).concat(
allFiles
.map(e => e.replace('.ts', ''))
.map(bundle => {
return {
input: `build/${bundle}.js`,
output: {
format: "cjs",
file: `bundle/${bundle}.es5.js`,
sourcemap: true,
},
plugins: [
resolve({ mainFields: ["jsnext"] }),
commonjs(),
buble({
transforms: { dangerousForOf: true }
}),
],
external: ['reflect-metadata', 'doric'],
onwarn: function (warning) {
if (warning.code === 'THIS_IS_UNDEFINED') { return; }
console.warn(warning.message);
}
}
}))
})
// If need ES5 support enable following configs
// .concat(
// allFiles
// .map(e => e.replace('.ts', ''))
// .map(bundle => {
// return {
// input: `build/${bundle}.js`,
// output: {
// format: "cjs",
// file: `bundle/${bundle}.es5.js`,
// sourcemap: true,
// },
// plugins: [
// resolve({ mainFields: ["jsnext"] }),
// commonjs(),
// buble({
// transforms: { dangerousForOf: true }
// }),
// ],
// external: ['reflect-metadata', 'doric'],
// onwarn: function (warning) {
// if (warning.code === 'THIS_IS_UNDEFINED') { return; }
// console.warn(warning.message);
// }
// }
// }))

View File

@ -53,7 +53,8 @@
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
"experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
"emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */
"emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
"resolveJsonModule": true
},
"include": [
"**/*.ts",