Skip to content
This repository was archived by the owner on Jun 2, 2024. It is now read-only.

Commit f442148

Browse files
committed
build(rollup): add es module to package
1 parent 2dd547a commit f442148

File tree

3 files changed

+53
-9
lines changed

3 files changed

+53
-9
lines changed

package-lock.json

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
"type": "git",
88
"url": "https://github.com/csvenke/react-semantics.git"
99
},
10-
"main": "index.min.js",
10+
"main": "index.js",
11+
"module": "index.es.js",
1112
"types": "types/index.d.ts",
1213
"files": [
13-
"index.min.js",
14+
"index.js",
15+
"index.es.js",
1416
"types/index.d.ts",
1517
"types/components"
1618
],
@@ -54,6 +56,7 @@
5456
"react-styleguidist": "^7.1.0",
5557
"react": "^16.4.1",
5658
"rimraf": "^2.6.2",
59+
"rollup-plugin-terser": "^1.0.1",
5760
"rollup-plugin-typescript2": "^0.16.1",
5861
"rollup-plugin-uglify": "^4.0.0",
5962
"rollup": "^0.63.4",

rollup.config.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import typescript from 'rollup-plugin-typescript2';
22
import { uglify } from 'rollup-plugin-uglify';
3+
import { terser } from 'rollup-plugin-terser';
34
import pkg from './package.json';
45

56
const externals = [
67
...(Object.keys(pkg.dependencies) || {}),
78
...(Object.keys(pkg.peerDependencies) || {}),
89
];
910

10-
const createConfig = ({ output } = {}) => ({
11+
const createConfig = ({ output, plugins } = {}) => ({
1112
input: 'src/index.ts',
1213
output,
1314
external: externals,
@@ -17,16 +18,17 @@ const createConfig = ({ output } = {}) => ({
1718
tsconfig: './tsconfig.build.json',
1819
typescript: require('typescript'),
1920
}),
20-
uglify(),
21+
...plugins,
2122
],
2223
});
2324

2425
export default [
2526
createConfig({
26-
output: {
27-
file: 'lib/index.min.js',
28-
format: 'cjs',
29-
exports: 'named',
30-
},
27+
output: { file: 'lib/index.js', format: 'cjs' },
28+
plugins: [uglify()],
29+
}),
30+
createConfig({
31+
output: { file: 'lib/index.es.js', format: 'es' },
32+
plugins: [terser()],
3133
}),
3234
];

0 commit comments

Comments
 (0)