From b0c8a91f65437d61f1c9db51c9d8b349008e8a0d Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Fri, 17 Jan 2020 17:10:01 +0800 Subject: [PATCH] cli:update config --- doric-cli/target/_package.json | 7 +++- doric-cli/target/_rollup.config.js | 67 ++++++++++++++++++++---------- doric-demo/rollup.config.js | 22 ---------- 3 files changed, 51 insertions(+), 45 deletions(-) diff --git a/doric-cli/target/_package.json b/doric-cli/target/_package.json index e2f4e682..53dcd3ed 100644 --- a/doric-cli/target/_package.json +++ b/doric-cli/target/_package.json @@ -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" } } \ No newline at end of file diff --git a/doric-cli/target/_rollup.config.js b/doric-cli/target/_rollup.config.js index 21088ad6..5b79ad46 100644 --- a/doric-cli/target/_rollup.config.js +++ b/doric-cli/target/_rollup.config.js @@ -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,25 +35,49 @@ const allFiles = [] dirs.forEach(e => { readDirs(e, allFiles) }) - -export default 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', '')) + .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); + } } - } - }) \ No newline at end of file + }).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); + } + } + })) \ No newline at end of file diff --git a/doric-demo/rollup.config.js b/doric-demo/rollup.config.js index 1cf521c2..5b79ad46 100644 --- a/doric-demo/rollup.config.js +++ b/doric-demo/rollup.config.js @@ -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', ''))