Gathering detailed insights and metrics for @jamesernator/rollup-pluginutils
The total size of the npm registry is estimated to be over 4 terabytes. This includes all the packages, versions, and metadata stored in the registry.
Gathering detailed insights and metrics for @jamesernator/rollup-pluginutils
The total size of the npm registry is estimated to be over 4 terabytes. This includes all the packages, versions, and metadata stored in the registry.
npm install @jamesernator/rollup-pluginutils
69.6
Supply Chain
94.7
Quality
71.5
Maintenance
50
Vulnerability
100
License
45 Stars
138 Commits
17 Forks
16 Watching
4 Branches
23 Contributors
Updated on 28 Feb 2024
TypeScript (85.33%)
JavaScript (14.67%)
Cumulative downloads
Total Downloads
Last day
-75%
1
Compared to previous day
Last week
-40%
6
Compared to previous week
Last month
122.2%
20
Compared to previous month
Last year
-32.1%
260
Compared to previous year
2
6
This package has moved and is now available at @rollup/pluginutils. Please update your dependencies. This repository is no longer maintained.
A set of functions commonly used by Rollup plugins.
1npm install --save rollup-pluginutils
1import { addExtension } from 'rollup-pluginutils'; 2 3export default function myPlugin ( options = {} ) { 4 return { 5 resolveId ( code, id ) { 6 // only adds an extension if there isn't one already 7 id = addExtension( id ); // `foo` -> `foo.js`, `foo.js -> foo.js` 8 id = addExtension( id, '.myext' ); // `foo` -> `foo.myext`, `foo.js -> `foo.js` 9 } 10 }; 11}
This function attaches Scope
objects to the relevant nodes of an AST. Each Scope
object has a scope.contains(name)
method that returns true
if a given name is defined in the current scope or a parent scope.
See rollup-plugin-inject or rollup-plugin-commonjs for an example of usage.
1import { attachScopes } from 'rollup-pluginutils'; 2import { walk } from 'estree-walker'; 3 4export default function myPlugin ( options = {} ) { 5 return { 6 transform ( code ) { 7 const ast = this.parse( code ); 8 9 let scope = attachScopes( ast, 'scope' ); 10 11 walk( ast, { 12 enter ( node ) { 13 if ( node.scope ) scope = node.scope; 14 15 if ( !scope.contains( 'foo' ) ) { 16 // `foo` is not defined, so if we encounter it, 17 // we assume it's a global 18 } 19 }, 20 leave ( node ) { 21 if ( node.scope ) scope = scope.parent; 22 } 23 }); 24 } 25 }; 26}
1import { createFilter } from 'rollup-pluginutils'; 2 3export default function myPlugin ( options = {} ) { 4 // `options.include` and `options.exclude` can each be a minimatch 5 // pattern, or an array of minimatch patterns, relative to process.cwd() 6 var filter = createFilter( options.include, options.exclude ); 7 8 return { 9 transform ( code, id ) { 10 // if `options.include` is omitted or has zero length, filter 11 // will return `true` by default. Otherwise, an ID must match 12 // one or more of the minimatch patterns, and must not match 13 // any of the `options.exclude` patterns. 14 if ( !filter( id ) ) return; 15 16 // proceed with the transformation... 17 } 18 }; 19}
If you want to resolve the patterns against a directory other than
process.cwd()
, you can additionally pass a resolve
option:
1var filter = createFilter( options.include, options.exclude, {resolve: '/my/base/dir'} )
If resolve
is a string, then this value will be used as the base directory.
Relative paths will be resolved against process.cwd()
first. If resolve
is
false
, then the patterns will not be resolved against any directory. This can
be useful if you want to create a filter for virtual module names.
1import { makeLegalIdentifier } from 'rollup-pluginutils'; 2 3makeLegalIdentifier( 'foo-bar' ); // 'foo_bar' 4makeLegalIdentifier( 'typeof' ); // '_typeof'
Helper for treeshakable data imports
1import { dataToEsm } from 'rollup-pluginutils'; 2 3const esModuleSource = dataToEsm({ 4 custom: 'data', 5 to: ['treeshake'] 6}, { 7 compact: false, 8 indent: '\t', 9 preferConst: false, 10 objectShorthand: false, 11 namedExports: true 12}); 13/* 14Outputs the string ES module source: 15 export const custom = 'data'; 16 export const to = ['treeshake']; 17 export default { custom, to }; 18*/
Extract the names of all assignment targets from patterns.
1import { extractAssignedNames } from 'rollup-pluginutils'; 2import { walk } from 'estree-walker'; 3 4export default function myPlugin ( options = {} ) { 5 return { 6 transform ( code ) { 7 const ast = this.parse( code ); 8 9 walk( ast, { 10 enter ( node ) { 11 if ( node.type === 'VariableDeclarator' ) { 12 const declaredNames = extractAssignedNames(node.id); 13 // do something with the declared names 14 // e.g. for `const {x, y: z} = ... => declaredNames = ['x', 'z'] 15 } 16 } 17 }); 18 } 19 }; 20}
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
Found 4/25 approved changesets -- score normalized to 1
Reason
project is archived
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
51 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
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