How to embed all dependencies into one fat target bundle with rollup.js?
10,759
Use rollup-plugin-node-resolve (and rollup-plugin-commonjs if you have CommonJS dependencies).
![Natasha](https://lh4.googleusercontent.com/-sVcuBiNqwlw/AAAAAAAAAAI/AAAAAAAAAAA/AAnnY7peTwGjfxuD2_NsuOBeIH4REZlYYQ/mo/photo.jpg?sz=256)
Author by
Natasha
Updated on June 08, 2022Comments
-
Natasha about 2 years
How do I have to configure rollup.js (=> config file "rollup.config.js") if all dependencies should be embedded into the (fat) result bundle (especially: how to configure the rollup parameters "globals", "external", "plugins.babel.exclude")?
Let's say I have done something like:
> npm install dependency1 --save-dev > npm install dependency2 --save-dev
And the index file (index.js) looks like:
import D1 from 'dependency1' import D2 from 'dependency2' [...] export default SomethingThatUsesD1AndD2
=> The resulting bundle shall be one fat single file that contains everything
-
Natasha almost 6 yearsIt's working now: One of the dependencies (a projects of mine) has been built with webpack ... I've switched the packer on that dependency project to "rollup" and it works fine with my other project's "rollup" build scripts ... think there was a problem with my webpack configuration of that dependency project.
-
Ran Yitzhaki over 4 yearsGreat answer! The links are outdated, those are up to date: rollup-plugin-node-resolve rollup-plugin-commonjs