// rollup.config.jsimport resolve from 'rollup-plugin-node-resolve';export default { input: 'main.js', output: { file: 'bundle.js', format: 'iife', name: 'MyModule' }, plugins: [ resolve({ // the fields to scan in a package.json to determine the entry point // if this list contains "browser", overrides specified in "pkg.browser" // will be used mainFields: ['module', 'main'], // Default: ['module', 'main'] // DEPRECATED: use "mainFields" instead // use "module" field for ES6 module if possible module: true, // Default: true // DEPRECATED: use "mainFields" instead
Using with rollup-plugin-commonjs
Since most packages in your node_modules folder are probably legacy CommonJS rather than JavaScript modules, you may need to use rollup-plugin-commonjs:
This plugin won't resolve any builtins (e.g. fs). If you need to resolve builtins you can install local modules and set preferBuiltins to false, or install a plugin like rollup-plugin-node-builtins which provides stubbed versions of these methods.
If you want to silence warnings about builtins, you can add the list of builtins to the externals option; like so:
import resolve from 'rollup-plugin-node-resolve';import builtins from 'builtin-modules'export default ({ input: ..., plugins: [resolve()], externals: builtins, output: ...})