Skip to content

Commit

Permalink
Merge pull request #41 from FezVrasta/fix-esm
Browse files Browse the repository at this point in the history
fix ESM dist target
  • Loading branch information
jourdain authored Oct 11, 2021
2 parents 8946b72 + 3af6514 commit b1dc18c
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 30 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"scripts": {
"prebuild": "npm run fix",
"build": "rollup ./src/index.js -c",
"build": "rm -rf dist && rollup ./src/index.js -c",
"prepare": "npm run build",
"test": "npm run test:lint && npm run test:build",
"test:build": "npm run build",
Expand Down
79 changes: 50 additions & 29 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,42 @@
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import { babel } from '@rollup/plugin-babel';
import eslint from '@rollup/plugin-eslint';
import { terser } from "rollup-plugin-terser";
import analyze from 'rollup-plugin-analyzer'
import { terser } from 'rollup-plugin-terser';
import analyze from 'rollup-plugin-analyzer';
import { nodeResolve } from '@rollup/plugin-node-resolve';

const plugins = [
!process.env.NOLINT &&
eslint({
include: 'src/**/*.js',
exclude: 'node_modules/**',
}),
babel({
include: 'src/**',
exclude: 'node_modules/**',
extensions: ['.js'],
babelHelpers: 'runtime',
presets: ['@babel/env', '@babel/preset-react'],
plugins: ['@babel/plugin-transform-runtime'],
}),
commonjs(),
terser(),
analyze({
stdout: true,
summaryOnly: true,
}),
];

export default {
const external = [
'@babel/runtime',
'@kitware/vtk.js',
'prop-types',
'react',
'regenerator-runtime',
];

export default [
{
input: 'src/index.js',
output: [
{
Expand All @@ -14,43 +45,33 @@ export default {
preserveModules: true,
preserveModulesRoot: 'src',
},
{
file: 'dist/cjs/react-vtk.js',
format: 'cjs',
},
],
external,
plugins,
},
{
input: 'src/index.js',
output: [
{
file: 'dist/umd/react-vtk.js',
format: 'umd',
exports: 'named',
name: 'ReactVtkJS',
},
{
file: 'dist/cjs/react-vtk.js',
format: 'cjs',
},
],
external: ['react', 'prop-types'],
external,
plugins: [
nodeResolve({
// include: 'node_modules/**',
// don't rely on node builtins for web
preferBuiltins: false,
browser: true,
}),
!process.env.NOLINT &&
eslint({
include: 'src/**/*.js',
exclude: 'node_modules/**',
}),
babel({
include: 'src/**',
exclude: 'node_modules/**',
extensions: ['.js'],
babelHelpers: 'runtime',
presets: ['@babel/env', '@babel/preset-react'],
plugins:['@babel/plugin-transform-runtime'],
}),
commonjs(),
terser(),
analyze({
stdout: true,
summaryOnly: true,
}),
...plugins,
],
};
},
];

0 comments on commit b1dc18c

Please sign in to comment.