nl_tokens: Check to see if we should transpile certain files in node_modules @param { String } filepath the path of the file to check @returns { Boolean } True if we should transpile it false if not
pl_tokens: function shouldTranspileDependency ( filepath ) { // find the last index of node_modules and check from there // we want <working>/node_modules/a-package/node_modules/foo/index.js to only match foo, not a-package const marker = '/node_modules/' ; const lastIndex = filepath . lastIndexOf ( marker ) ; if ( lastIndex === - 1 ) { // we're not in node_modules return <mask> ; } const checkFrom = lastIndex + marker . length ; return _ . some ( nodeModulesToTranspile , modulePart => filepath . substring ( checkFrom , checkFrom + modulePart . length ) === modulePart ) ; }