From 2b4a6d6440e25a054f5a4b3f71815dd7d9006113 Mon Sep 17 00:00:00 2001 From: Brian Zhang Date: Mon, 21 Jan 2019 23:28:41 -0800 Subject: [PATCH 1/2] try to add es6 export --- dist/react-chartjs.js | 25 +++++++++++---- index.js | 25 +++++++++++---- webpack.config.js | 75 ++++++++++++++++++++----------------------- 3 files changed, 70 insertions(+), 55 deletions(-) diff --git a/dist/react-chartjs.js b/dist/react-chartjs.js index 072008f..dfd2a29 100644 --- a/dist/react-chartjs.js +++ b/dist/react-chartjs.js @@ -54,16 +54,27 @@ return /******/ (function(modules) { // webpackBootstrap /* 0 */ /***/ (function(module, exports, __webpack_require__) { + const Bar = __webpack_require__(1); + const Doughnut = __webpack_require__(14); + const Line = __webpack_require__(15); + const Pie = __webpack_require__(16); + const PolarArea = __webpack_require__(17); + const Radar = __webpack_require__(18); + const createClass = __webpack_require__(2).createClass; + module.exports = { - Bar: __webpack_require__(1), - Doughnut: __webpack_require__(14), - Line: __webpack_require__(15), - Pie: __webpack_require__(16), - PolarArea: __webpack_require__(17), - Radar: __webpack_require__(18), - createClass: __webpack_require__(2).createClass + Bar, + Doughnut, + Line, + Pie, + PolarArea, + Radar, + createClass, }; + export { Bar, Doughnut, Line, Pie, PolarArea, Radar }; + + /***/ }), /* 1 */ diff --git a/index.js b/index.js index beaedd0..1ff61a7 100644 --- a/index.js +++ b/index.js @@ -1,9 +1,20 @@ +const Bar = require('./lib/bar'); +const Doughnut = require('./lib/doughnut'); +const Line = require('./lib/line'); +const Pie = require('./lib/pie'); +const PolarArea = require('./lib/polar-area'); +const Radar = require('./lib/radar'); +const createClass = require('./lib/core').createClass; + module.exports = { - Bar: require('./lib/bar'), - Doughnut: require('./lib/doughnut'), - Line: require('./lib/line'), - Pie: require('./lib/pie'), - PolarArea: require('./lib/polar-area'), - Radar: require('./lib/radar'), - createClass: require('./lib/core').createClass + Bar, + Doughnut, + Line, + Pie, + PolarArea, + Radar, + createClass, }; + +export { Bar, Doughnut, Line, Pie, PolarArea, Radar }; + diff --git a/webpack.config.js b/webpack.config.js index a810692..ec059d5 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,50 +1,43 @@ var webpack = require('webpack'), - plugins = []; + plugins = []; if (process.env.COMPRESS) { - plugins.push( - new webpack.optimize.UglifyJsPlugin({ - compressor: { - warnings: false - } - }) - ); + plugins.push( + new webpack.optimize.UglifyJsPlugin({ + compressor: { + warnings: false + } + }) + ); } module.exports = { - - output: { - library: 'react-chartjs', - libraryTarget: 'umd' + output: { + library: 'react-chartjs', + libraryTarget: 'umd' + }, + externals: [{ + 'react': { + root: 'React', + commonjs2: 'react', + commonjs: 'react', + amd: 'react' }, - - externals: [ - { - "react": { - root: "React", - commonjs2: "react", - commonjs: "react", - amd: "react" - }, - "react-dom": { - root: "ReactDOM", - commonjs2: "react-dom", - commonjs: "react-dom", - amd: "react-dom" - }, - "chart.js": { - root: "Chart", - commonjs2: "Chartjs", - commonjs: "Chartjs", - amd: "Chartjs" - } - } - ], - - node: { - Buffer: false + 'react-dom': { + root: 'ReactDOM', + commonjs2: 'react-dom', + commonjs: 'react-dom', + amd: 'react-dom' }, - - plugins: plugins - + 'chart.js': { + root: 'Chart', + commonjs2: 'Chartjs', + commonjs: 'Chartjs', + amd: 'Chartjs' + } + }], + node: { + Buffer: false + }, + plugins: plugins }; From ab939fb3ee2a81598b162535f488a90fb35bf260 Mon Sep 17 00:00:00 2001 From: Brian Zhang Date: Mon, 21 Jan 2019 23:31:01 -0800 Subject: [PATCH 2/2] react-chartjs -> ReactChartJs --- dist/react-chartjs.js | 4 ++-- webpack.config.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/react-chartjs.js b/dist/react-chartjs.js index dfd2a29..3306a53 100644 --- a/dist/react-chartjs.js +++ b/dist/react-chartjs.js @@ -4,9 +4,9 @@ else if(typeof define === 'function' && define.amd) define(["react", "react-dom", "Chartjs"], factory); else if(typeof exports === 'object') - exports["react-chartjs"] = factory(require("react"), require("react-dom"), require("Chartjs")); + exports["ReactChartJs"] = factory(require("react"), require("react-dom"), require("Chartjs")); else - root["react-chartjs"] = factory(root["React"], root["ReactDOM"], root["Chart"]); + root["ReactChartJs"] = factory(root["React"], root["ReactDOM"], root["Chart"]); })(this, function(__WEBPACK_EXTERNAL_MODULE_3__, __WEBPACK_EXTERNAL_MODULE_12__, __WEBPACK_EXTERNAL_MODULE_13__) { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache diff --git a/webpack.config.js b/webpack.config.js index ec059d5..ea6e4f4 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -13,7 +13,7 @@ if (process.env.COMPRESS) { module.exports = { output: { - library: 'react-chartjs', + library: 'ReactChartJs', libraryTarget: 'umd' }, externals: [{