I am testdriving rollupjs to package a node app into a bundle.js
and am confused.
Does rollup support bundling a full node app (including
node_modules
), or just the js files that are part of your project?
I have a standard node project (1 index.js
, thousands of files in node_modules
) and would like just one bundle.js
. I tried:
rollup.config.js:
import commonjs from 'rollup-plugin-commonjs';
import nodeResolve from 'rollup-plugin-node-resolve';
export default {
entry: 'index.js',
dest: 'bundle.js',
format: 'iife',
plugins: [
commonjs({
// non-CommonJS modules will be ignored, but you can also
// specifically include/exclude files
include: 'node_modules/**', // Default: undefined
// if true then uses of `global` won't be dealt with by this plugin
ignoreGlobal: false, // Default: false
// if false then skip sourceMap generation for CommonJS modules
sourceMap: false, // Default: true
}),
nodeResolve({
jsnext: true,
main: false
})
]
};
Whatever I try rollup
turns this index.js
:
module.exports = require('dat-node') // 88 MB node_modules
with this command:
rollup index.js --format iife --output dist/bundle.js -c
to this bundle.js
without adding anything from node_modules
:
(function () {
'use strict';
module.exports = require('dat-node');
}());
And I have tried:
- swapping plugin sequence
- all different command line options
- different formats
- different config file settings
Now I am thinking, maybe I understand rollup incorrectly and it does not support what I want. Help much appreciated!