Installations
npm install @yelo/rollup-node-external
Releases
Unable to fetch releases
Developer
imyelo
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
No
Node Version
7.10.1
NPM Version
5.4.2
Statistics
9 Stars
66 Commits
3 Watching
1 Branches
1 Contributors
Updated on 20 Oct 2022
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
420,210
Last day
-33.8%
624
Compared to previous day
Last week
-19.4%
4,160
Compared to previous week
Last month
29.4%
18,238
Compared to previous month
Last year
29.6%
151,472
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
rollup node modules external
Easily exclude node modules in rollup, forked from webpack-node-externals
rollup allows you to define external - modules that should not be bundled.
When bundling with rollup for the backend - you usually don't want to bundle its node_modules
dependencies.
This library creates an external function that ignores node_modules
when bundling in rollup.
Forked from liady/webpack-node-externals
Quick usage
1npm install @yelo/rollup-node-external --save-dev
In your rollup.config.js
:
1var external = require('@yelo/rollup-node-external'); 2... 3module.exports = { 4 ... 5 external: external(), // in order to ignore all modules in node_modules folder 6 plugins: [ 7 ... 8 // import node-resolve plugin 9 require('rollup-plugin-node-resovle')(), 10 ... 11 ], 12 ... 13};
And that's it. All node modules will no longer be bundled but will be left as require('module')
.
Detailed overview
Description
This library scans the node_modules
folder for all node_modules names, and builds an external function that tells rollup not to bundle those modules, or any sub-modules of theirs.
Configuration
This library accepts an options
object.
options.whitelist (=[])
An array for the external
to whitelist, so they will be included in the bundle. Can accept exact strings ('module_name'
), regex patterns (/^module_name/
), or a function that accepts the module name and returns whether it should be included.
Important - if you have set aliases in your rollup config with the exact same names as modules in node_modules, you need to whitelist them so rollup will know they should be bundled.
options.importType (='commonjs')
The method in which unbundled modules will be required in the code. Best to leave as commonjs
for node modules.
options.modulesDir (='node_modules')
The folder in which to search for the node modules.
options.modulesFromFile (=false)
Read the modules from the package.json
file instead of the node_modules
folder.
Example
1var external = require('@yelo/rollup-node-external'); 2... 3module.exports = { 4 ... 5 external: external({ 6 // this WILL include `jquery` in the bundle, as well as `lodash/*` 7 whitelist: ['jquery', /^lodash/] 8 }), 9 plugins: [ 10 ... 11 require('rollup-plugin-node-resovle')(), 12 ... 13 ], 14 ... 15};
For most use cases, the defaults of importType
and modulesDir
should be used.
Test
1npm run test
License
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Score
3
/10
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More