package
Bundle third-party dependencies in node_modules
npm install rollup-plugin-node-resolveGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
This plugin used to be called rollup-plugin-npm
Locate modules using the Node resolution algorithm, for using third party modules in node_modules
npm install --save-dev rollup-plugin-node-resolve// rollup.config.js
import 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
Since most packages in your node_modules folder are probably legacy CommonJS rather than JavaScript modules, you may need to use rollup-plugin-commonjs:
// rollup.config.js
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
export default {
input: 'main.js',
output: {
file: 'bundle.js',
format: 'iife'
},
name: 'MyModule',
plugins: [
resolve(),
commonjs()
]
};fs)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: ...
})MIT
lukastaegert
lukas.taegert@tngtech.com
Estimated unpacked size across 13 packages.
581.0 kB
Includes dependencies.
5 direct · 2 outdated
^1.11.1
1.22.14
^1.0.0
1.0.0
0.0.8
1.20.6
^3.1.0
5.5.0
^2.8.1
2.8.2