Skip to content

Commit b1dc18c

Browse files
authored
Merge pull request #41 from FezVrasta/fix-esm
fix ESM dist target
2 parents 8946b72 + 3af6514 commit b1dc18c

File tree

2 files changed

+51
-30
lines changed

2 files changed

+51
-30
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"scripts": {
1515
"prebuild": "npm run fix",
16-
"build": "rollup ./src/index.js -c",
16+
"build": "rm -rf dist && rollup ./src/index.js -c",
1717
"prepare": "npm run build",
1818
"test": "npm run test:lint && npm run test:build",
1919
"test:build": "npm run build",

rollup.config.js

Lines changed: 50 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,42 @@
1-
import { nodeResolve } from '@rollup/plugin-node-resolve';
21
import commonjs from '@rollup/plugin-commonjs';
32
import { babel } from '@rollup/plugin-babel';
43
import eslint from '@rollup/plugin-eslint';
5-
import { terser } from "rollup-plugin-terser";
6-
import analyze from 'rollup-plugin-analyzer'
4+
import { terser } from 'rollup-plugin-terser';
5+
import analyze from 'rollup-plugin-analyzer';
6+
import { nodeResolve } from '@rollup/plugin-node-resolve';
7+
8+
const plugins = [
9+
!process.env.NOLINT &&
10+
eslint({
11+
include: 'src/**/*.js',
12+
exclude: 'node_modules/**',
13+
}),
14+
babel({
15+
include: 'src/**',
16+
exclude: 'node_modules/**',
17+
extensions: ['.js'],
18+
babelHelpers: 'runtime',
19+
presets: ['@babel/env', '@babel/preset-react'],
20+
plugins: ['@babel/plugin-transform-runtime'],
21+
}),
22+
commonjs(),
23+
terser(),
24+
analyze({
25+
stdout: true,
26+
summaryOnly: true,
27+
}),
28+
];
729

8-
export default {
30+
const external = [
31+
'@babel/runtime',
32+
'@kitware/vtk.js',
33+
'prop-types',
34+
'react',
35+
'regenerator-runtime',
36+
];
37+
38+
export default [
39+
{
940
input: 'src/index.js',
1041
output: [
1142
{
@@ -14,43 +45,33 @@ export default {
1445
preserveModules: true,
1546
preserveModulesRoot: 'src',
1647
},
48+
{
49+
file: 'dist/cjs/react-vtk.js',
50+
format: 'cjs',
51+
},
52+
],
53+
external,
54+
plugins,
55+
},
56+
{
57+
input: 'src/index.js',
58+
output: [
1759
{
1860
file: 'dist/umd/react-vtk.js',
1961
format: 'umd',
2062
exports: 'named',
2163
name: 'ReactVtkJS',
2264
},
23-
{
24-
file: 'dist/cjs/react-vtk.js',
25-
format: 'cjs',
26-
},
2765
],
28-
external: ['react', 'prop-types'],
66+
external,
2967
plugins: [
3068
nodeResolve({
3169
// include: 'node_modules/**',
3270
// don't rely on node builtins for web
3371
preferBuiltins: false,
3472
browser: true,
3573
}),
36-
!process.env.NOLINT &&
37-
eslint({
38-
include: 'src/**/*.js',
39-
exclude: 'node_modules/**',
40-
}),
41-
babel({
42-
include: 'src/**',
43-
exclude: 'node_modules/**',
44-
extensions: ['.js'],
45-
babelHelpers: 'runtime',
46-
presets: ['@babel/env', '@babel/preset-react'],
47-
plugins:['@babel/plugin-transform-runtime'],
48-
}),
49-
commonjs(),
50-
terser(),
51-
analyze({
52-
stdout: true,
53-
summaryOnly: true,
54-
}),
74+
...plugins,
5575
],
56-
};
76+
},
77+
];

0 commit comments

Comments
 (0)