Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add esm build fixes #2008 #2009

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "4.3.0",
"description": "Datatables for React using Material-UI",
"main": "dist/index.js",
"module": "dist/esm/index.js",
"files": [
"dist"
],
Expand All @@ -18,7 +19,7 @@
"coverage:html": "cross-env NODE_ENV=test nyc check-coverage --lines 55 --reporter=html --reporter=text mocha --require @babel/register test/*.js && nyc report --reporter=html",
"prettier": "find src/ docs/ test/ -type f -name \"*.js\" ! -path \"*/.next/*\" | xargs prettier --write",
"lint": "eslint src",
"build": "cross-env NODE_ENV=production npm run prettier && rollup -c",
"build": "cross-env NODE_ENV=production npm run prettier && rollup -c && rollup -c rollup.esm.config.js",
"prepare": "npm run build"
},
"repository": {
Expand Down Expand Up @@ -122,8 +123,7 @@
"react-dnd": "^11.1.3",
"react-dnd-html5-backend": "^11.1.3",
"react-sortable-tree-patch-react-17": "^2.9.0",
"react-to-print": "^2.8.0",
"tss-react": "^3.6.0"
"react-to-print": "^2.8.0"
},
"side-effects": false,
"nyc": {
Expand Down
41 changes: 41 additions & 0 deletions rollup.esm.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import babel from '@rollup/plugin-babel';
import commonjs from '@rollup/plugin-commonjs';
import replace from '@rollup/plugin-replace';
import uglify from '@lopatnov/rollup-plugin-uglify';

export default {
input: 'src/index.js',
plugins: [
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
commonjs({
include: ['node_modules/**'],
}),
babel({
babelHelpers: 'runtime',
babelrc: true,
}),
uglify({
compress: {
conditionals: true,
unused: true,
comparisons: true,
sequences: true,
dead_code: true,
evaluate: true,
if_return: true,
join_vars: true,
},
output: {
comments: false,
},
}),
],
output: {
file: 'dist/esm/index.js',
format: 'esm',
exports: 'named',
sourcemap: true,
},
};