-
-
Notifications
You must be signed in to change notification settings - Fork 227
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
Bundle UMD with rollup #159
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"dist/index.umd.js": { | ||
"bundled": 140771, | ||
"minified": 38655, | ||
"gzipped": 12382 | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import nodeResolve from 'rollup-plugin-node-resolve'; | ||
import commonjs from 'rollup-plugin-commonjs'; | ||
import babel from 'rollup-plugin-babel'; | ||
import uglify from 'rollup-plugin-uglify'; | ||
import { sizeSnapshot } from 'rollup-plugin-size-snapshot'; | ||
|
||
const input = './src/index.js'; | ||
|
||
const umdGlobals = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Popper.js should be marked as external as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it matter? Do you think somebody will use popper.js and react-popper in one script? For react-popper consumer there will be another action to add popper dependency. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't want to get every week a new issue with someone that asks me to release a new UMD bundle with the new Popper.js version. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay. |
||
react: 'React', | ||
'react-dom': 'ReactDOM', | ||
}; | ||
|
||
const getBabelOptions = () => ({ | ||
babelrc: false, | ||
exclude: '**/node_modules/**', | ||
presets: [['env', { modules: false }], 'stage-1', 'react'], | ||
plugins: ['external-helpers'], | ||
}); | ||
|
||
export default [ | ||
{ | ||
input, | ||
output: { | ||
file: 'dist/index.umd.js', | ||
format: 'umd', | ||
name: 'ReactPopper', | ||
globals: umdGlobals, | ||
}, | ||
external: Object.keys(umdGlobals), | ||
plugins: [ | ||
nodeResolve(), | ||
commonjs({ include: '**/node_modules/**' }), | ||
babel(getBabelOptions()), | ||
sizeSnapshot(), | ||
], | ||
}, | ||
|
||
{ | ||
input, | ||
output: { | ||
file: 'dist/index.min.js', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should probably be |
||
format: 'umd', | ||
name: 'ReactPopper', | ||
globals: umdGlobals, | ||
}, | ||
external: Object.keys(umdGlobals), | ||
plugins: [ | ||
nodeResolve(), | ||
commonjs({ include: '**/node_modules/**' }), | ||
babel(getBabelOptions()), | ||
uglify(), | ||
], | ||
}, | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May we use
rollup-plugin-babel-minify
instead? I got better outputs with it in Popper.jsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uglify 37.75 kb
babel-minify 38.15 kb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may need to tweak the default config a bit:
https://github.com/FezVrasta/popper.js/blob/master/packages/bundle/index.js#L18
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did it. Nothing is changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool thanks!