From e4429b714332305fb31d0b5a8505c0b56e40da66 Mon Sep 17 00:00:00 2001 From: Adrien Denat Date: Fri, 21 Jun 2019 12:43:05 -0300 Subject: [PATCH] Add support for es module build (#1374) --- package.json | 4 ++-- rollup.config.js | 51 ++++++++++++++++++++++++++++-------------------- 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index c2c467d..d9c125a 100644 --- a/package.json +++ b/package.json @@ -15,8 +15,8 @@ "datagrid" ], "main": "dist/index.js", - "_module": "dist/index.es.js", - "_jsnext:main": "dist/index.es.js", + "module": "dist/index.es.js", + "jsnext:main": "dist/index.es.js", "scripts": { "test": "cross-env CI=1 react-scripts test --env=jsdom", "test:watch": "react-scripts test --env=jsdom", diff --git a/rollup.config.js b/rollup.config.js index c215136..3898807 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -6,27 +6,36 @@ import { uglify } from 'rollup-plugin-uglify' import pkg from './package.json' -export default { - input: 'src/index.js', - output: [ - { +export default [ + { + input: 'src/index.js', + output: { file: pkg.main, format: 'cjs', sourcemap: true - } - // { - // file: pkg.module, - // format: "es", - // sourcemap: true - // } - ], - plugins: [ - external(), - babel({ - exclude: 'node_modules/**' - }), - resolve(), - commonjs(), - uglify() - ] -} + }, + plugins: [ + external(), + babel({ + exclude: 'node_modules/**' + }), + resolve(), + commonjs(), + uglify() + ] + }, + { + input: 'src/index.js', + external: Object.keys(pkg.peerDependencies), + output: { + file: pkg.module, + format: 'es', + sourcemap: true + }, + plugins: [ + babel({ + exclude: ['/**/node_modules/**'] + }) + ] + } +]