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).

Share:
10,759
Natasha
Author by

Natasha

Updated on June 08, 2022

Comments

  • Natasha
    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
    Natasha almost 6 years
    It'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
    Ran Yitzhaki over 4 years
    Great answer! The links are outdated, those are up to date: rollup-plugin-node-resolve rollup-plugin-commonjs