When comparing stealjs vs rollup.js, the Slant community recommends stealjs for most people. In the question“What are the best RequireJS alternatives?” stealjs is ranked 2nd while rollup.js is ranked 3rd. The most important reason people chose stealjs is:
StealJS has support for AMD, CJS and ES6 module types.
Ranked in these QuestionsQuestion Ranking
Pros
Pro Supports several modules types
StealJS has support for AMD, CJS and ES6 module types.
Pro Support for LESS and CSS
StealJS can also load CSS and LESS files in addition to JavaScript modules.
Pro Mix ES6 AMD and CommonJS
StealJS supports using all three module types, even in the same file.
Pro ES6 module support
StealJs supports ES6 modules and their import
and export
methods without having to compile them to CommonJS require
.
Pro Support for ES6
StealJS supports transpiling of ES6 code to ES5
Pro Supports all systemjs based plugins
Pro Supports source maps for easier debugging
Source maps allow for easier debugging, because they allow you to find the problems within the origin files instead of the output file.
Pro Share the same modules client-side and server-side
Because StealJS allows you to use the same require()
function as node.js, you can easily share modules between the client-side and server-side.
Pro Tap into npm's huge module ecosystem
Using StelaJS opens you up to npm, that has over 80k modules of which a great amount work both client-side and server-side. And the list is growing rapidly.
Pro Provides tree shaking
Tree shaking can significantly reduce the size of your bundle by getting rid of unused code from the libraries you are using.
Pro Reactjs droped Webpack and is now using rollup
Pro Outputs almost any module format
AMD, CommonJS, ES2015, Globals and UMD are all supported.
Pro Easy to configure
Rollup is very easy ton configure through a JSON file.
Pro Supports plugins
Rollup can be expanded just like webpack and browserify through the use of plugins. Plugins can do things such as transpilation (e.g. with Babel), import data from non JS places (like JSON files), etc.
Cons
Con Changing the order of require statements causes unexpected behavior
Sometimes changing the order of the require
statements in a JavaScript file loaded with stealjs may cause unexpected problems or even breaking the code altogether.
Con Relatively new
Rollup is still relatively new so it may be a bit harder to find information on how to do some things with it. In addition, that means that plugins can be a little scarce and it may be subject to minor changes as it matures.