cli:update config

This commit is contained in:
pengfei.zhou 2020-01-17 17:10:01 +08:00 committed by osborn
parent b6f7588321
commit b0c8a91f65
3 changed files with 51 additions and 45 deletions

View File

@ -13,9 +13,12 @@
"doric": "0.2.3",
"reflect-metadata": "^0.1.13",
"rollup": "^1.27.14",
"@rollup/plugin-commonjs": "^11.0.0",
"@rollup/plugin-node-resolve": "^6.0.0",
"tslib": "^1.10.0",
"typescript": "^3.7.4"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^11.0.1",
"@rollup/plugin-node-resolve": "^7.0.0",
"@rollup/plugin-buble": "^0.21.0"
}
}

View File

@ -3,6 +3,7 @@ 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';
function readDirs(dirPath, files) {
if (fs.statSync(dirPath).isDirectory()) {
@ -34,8 +35,8 @@ const allFiles = []
dirs.forEach(e => {
readDirs(e, allFiles)
})
export default allFiles
export default
allFiles
.map(e => e.replace('.ts', ''))
.map(bundle => {
return {
@ -47,7 +48,7 @@ export default allFiles
},
plugins: [
resolve({ mainFields: ["jsnext"] }),
commonjs()
commonjs(),
],
external: ['reflect-metadata', 'doric'],
onwarn: function (warning) {
@ -55,4 +56,28 @@ export default allFiles
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);
}
}
}))

View File

@ -35,28 +35,6 @@ const allFiles = []
dirs.forEach(e => {
readDirs(e, allFiles)
})
const outFile = allFiles
.map(e => e.replace('.ts', ''))
.map(bundle => {
return {
input: `build/${bundle}.js`,
output: {
format: "cjs",
file: `bundle/${bundle}.js`,
sourcemap: true,
},
plugins: [
resolve({ mainFields: ["jsnext"] }),
commonjs(),
],
external: ['reflect-metadata', 'doric'],
onwarn: function (warning) {
if (warning.code === 'THIS_IS_UNDEFINED') { return; }
console.warn(warning.message);
}
}
})
export default
allFiles
.map(e => e.replace('.ts', ''))