rollup-pluginutils
Advanced tools
Comparing version 1.5.2 to 2.0.0
# rollup-pluginutils changelog | ||
## 2.0.0 | ||
* Use `micromatch` instead of `minimatch` ([#19](https://github.com/rollup/rollup-pluginutils/issues/19)) | ||
* Allow `createFilter` to take regexes ([#5](https://github.com/rollup/rollup-pluginutils/issues/5)) | ||
## 1.5.2 | ||
@@ -4,0 +9,0 @@ |
@@ -5,13 +5,15 @@ 'use strict'; | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var estreeWalker = require('estree-walker'); | ||
var path = require('path'); | ||
var minimatch = require('minimatch'); | ||
var mm = _interopDefault(require('micromatch')); | ||
function basename ( path ) { | ||
return path.split( /(\/|\\)/ ).pop(); | ||
function basename ( path$$1 ) { | ||
return path$$1.split( /(\/|\\)/ ).pop(); | ||
} | ||
function extname ( path ) { | ||
var match = /\.[^\.]+$/.exec( basename( path ) ); | ||
if ( !match ) return ''; | ||
function extname ( path$$1 ) { | ||
var match = /\.[^\.]+$/.exec( basename( path$$1 ) ); | ||
if ( !match ) { return ''; } | ||
return match[0]; | ||
@@ -23,3 +25,3 @@ } | ||
if ( !extname( filename ) ) filename += ext; | ||
if ( !extname( filename ) ) { filename += ext; } | ||
return filename; | ||
@@ -46,3 +48,3 @@ } | ||
param.elements.forEach( function (element) { | ||
if ( element ) extractors[ element.type ]( names, element ); | ||
if ( element ) { extractors[ element.type ]( names, element ); } | ||
}); | ||
@@ -172,3 +174,3 @@ }, | ||
leave: function leave ( node ) { | ||
if ( node[ propertyName ] ) scope = scope.parent; | ||
if ( node[ propertyName ] ) { scope = scope.parent; } | ||
} | ||
@@ -181,4 +183,4 @@ }); | ||
function ensureArray ( thing ) { | ||
if ( Array.isArray( thing ) ) return thing; | ||
if ( thing == undefined ) return []; | ||
if ( Array.isArray( thing ) ) { return thing; } | ||
if ( thing == undefined ) { return []; } | ||
return [ thing ]; | ||
@@ -188,24 +190,31 @@ } | ||
function createFilter ( include, exclude ) { | ||
include = ensureArray( include ).map( function (id) { return path.resolve( id ); } ).map( function (id) { return new minimatch.Minimatch(id); } ); | ||
exclude = ensureArray( exclude ).map( function (id) { return path.resolve( id ); } ).map( function (id) { return new minimatch.Minimatch(id); } ); | ||
var getMatcher = function (id) { return ( isRegexp( id ) ? id : { test: mm.matcher( path.resolve( id ) ) } ); }; | ||
include = ensureArray( include ).map( getMatcher ); | ||
exclude = ensureArray( exclude ).map( getMatcher ); | ||
return function ( id ) { | ||
if ( typeof id !== 'string' ) return false; | ||
if ( /\0/.test( id ) ) return false; | ||
var included = !include.length; | ||
id = id.split(path.sep).join('/'); | ||
if ( typeof id !== 'string' ) { return false; } | ||
if ( /\0/.test( id ) ) { return false; } | ||
include.forEach( function (minimatch) { | ||
if ( minimatch.match( id ) ) included = true; | ||
}); | ||
id = id.split( path.sep ).join( '/' ); | ||
exclude.forEach( function (minimatch) { | ||
if ( minimatch.match( id ) ) included = false; | ||
}); | ||
for ( var i = 0; i < exclude.length; ++i ) { | ||
var matcher = exclude[i]; | ||
if ( matcher.test( id ) ) { return false; } | ||
} | ||
return included; | ||
for ( var i$1 = 0; i$1 < include.length; ++i$1 ) { | ||
var matcher$1 = include[i$1]; | ||
if ( matcher$1.test( id ) ) { return true; } | ||
} | ||
return !include.length; | ||
}; | ||
} | ||
function isRegexp ( val ) { | ||
return val instanceof RegExp; | ||
} | ||
var reservedWords = 'break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public'.split( ' ' ); | ||
@@ -222,3 +231,3 @@ var builtins = 'arguments Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl'.split( ' ' ); | ||
if ( /\d/.test( str[0] ) || blacklisted[ str ] ) str = "_" + str; | ||
if ( /\d/.test( str[0] ) || blacklisted[ str ] ) { str = "_" + str; } | ||
@@ -231,2 +240,2 @@ return str; | ||
exports.createFilter = createFilter; | ||
exports.makeLegalIdentifier = makeLegalIdentifier; | ||
exports.makeLegalIdentifier = makeLegalIdentifier; |
{ | ||
"name": "rollup-pluginutils", | ||
"description": "Functionality commonly needed by Rollup plugins", | ||
"version": "1.5.2", | ||
"version": "2.0.0", | ||
"main": "dist/pluginutils.cjs.js", | ||
"jsnext:main": "dist/pluginutils.es6.js", | ||
"module": "dist/pluginutils.es.js", | ||
"jsnext:main": "dist/pluginutils.es.js", | ||
"files": [ | ||
"src", | ||
"dist", | ||
"README.md" | ||
], | ||
"devDependencies": { | ||
"eslint": "^2.13.1", | ||
"mocha": "^2.5.3", | ||
"rollup": "^0.33.0", | ||
"rollup-plugin-buble": "^0.12.1" | ||
"eslint": "^3.12.2", | ||
"mocha": "^3.2.0", | ||
"rollup": "^0.40.0", | ||
"rollup-plugin-buble": "^0.15.0" | ||
}, | ||
"scripts": { | ||
"test": "mocha", | ||
"build": "rollup -c -f cjs -o dist/pluginutils.cjs.js && rollup -c -f es6 -o dist/pluginutils.es6.js", | ||
"build": "rollup -c", | ||
"pretest": "npm run build", | ||
@@ -20,14 +26,6 @@ "prepublish": "npm test" | ||
"dependencies": { | ||
"estree-walker": "^0.2.1", | ||
"minimatch": "^3.0.2" | ||
"estree-walker": "^0.3.0", | ||
"micromatch": "^2.3.11" | ||
}, | ||
"files": [ | ||
"src", | ||
"dist", | ||
"README.md" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/rollup/rollup-pluginutils.git" | ||
}, | ||
"repository": "rollup/rollup-pluginutils", | ||
"keywords": [ | ||
@@ -34,0 +32,0 @@ "rollup", |
import { resolve, sep } from 'path'; | ||
import { Minimatch } from 'minimatch'; | ||
import mm from 'micromatch'; | ||
import ensureArray from './utils/ensureArray'; | ||
export default function createFilter ( include, exclude ) { | ||
include = ensureArray( include ).map( id => resolve( id ) ).map( id => new Minimatch(id) ); | ||
exclude = ensureArray( exclude ).map( id => resolve( id ) ).map( id => new Minimatch(id) ); | ||
const getMatcher = id => ( isRegexp( id ) ? id : { test: mm.matcher( resolve( id ) ) } ); | ||
include = ensureArray( include ).map( getMatcher ); | ||
exclude = ensureArray( exclude ).map( getMatcher ); | ||
return function ( id ) { | ||
if ( typeof id !== 'string' ) return false; | ||
if ( /\0/.test( id ) ) return false; | ||
let included = !include.length; | ||
id = id.split(sep).join('/'); | ||
id = id.split( sep ).join( '/' ); | ||
include.forEach( minimatch => { | ||
if ( minimatch.match( id ) ) included = true; | ||
}); | ||
for ( let i = 0; i < exclude.length; ++i ) { | ||
const matcher = exclude[i]; | ||
if ( matcher.test( id ) ) return false; | ||
} | ||
exclude.forEach( minimatch => { | ||
if ( minimatch.match( id ) ) included = false; | ||
}); | ||
for ( let i = 0; i < include.length; ++i ) { | ||
const matcher = include[i]; | ||
if ( matcher.test( id ) ) return true; | ||
} | ||
return included; | ||
return !include.length; | ||
}; | ||
} | ||
function isRegexp ( val ) { | ||
return val instanceof RegExp; | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29772
12
711
1
+ Addedmicromatch@^2.3.11
+ Addedarr-diff@2.0.0(transitive)
+ Addedarr-flatten@1.1.0(transitive)
+ Addedarray-unique@0.2.1(transitive)
+ Addedbraces@1.8.5(transitive)
+ Addedestree-walker@0.3.1(transitive)
+ Addedexpand-brackets@0.1.5(transitive)
+ Addedexpand-range@1.8.2(transitive)
+ Addedextglob@0.3.2(transitive)
+ Addedfilename-regex@2.0.1(transitive)
+ Addedfill-range@2.2.4(transitive)
+ Addedfor-in@1.0.2(transitive)
+ Addedfor-own@0.1.5(transitive)
+ Addedglob-base@0.3.0(transitive)
+ Addedglob-parent@2.0.0(transitive)
+ Addedis-buffer@1.1.6(transitive)
+ Addedis-dotfile@1.0.3(transitive)
+ Addedis-equal-shallow@0.1.3(transitive)
+ Addedis-extendable@0.1.1(transitive)
+ Addedis-extglob@1.0.0(transitive)
+ Addedis-glob@2.0.1(transitive)
+ Addedis-number@2.1.04.0.0(transitive)
+ Addedis-posix-bracket@0.1.1(transitive)
+ Addedis-primitive@2.0.0(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedisobject@2.1.0(transitive)
+ Addedkind-of@3.2.26.0.3(transitive)
+ Addedmath-random@1.0.4(transitive)
+ Addedmicromatch@2.3.11(transitive)
+ Addednormalize-path@2.1.1(transitive)
+ Addedobject.omit@2.0.1(transitive)
+ Addedparse-glob@3.0.4(transitive)
+ Addedpreserve@0.2.0(transitive)
+ Addedrandomatic@3.1.1(transitive)
+ Addedregex-cache@0.4.4(transitive)
+ Addedremove-trailing-separator@1.1.0(transitive)
+ Addedrepeat-element@1.1.4(transitive)
+ Addedrepeat-string@1.6.1(transitive)
- Removedminimatch@^3.0.2
- Removedbalanced-match@1.0.2(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removedestree-walker@0.2.1(transitive)
- Removedminimatch@3.1.2(transitive)
Updatedestree-walker@^0.3.0