diff --git a/CHANGELOG.md b/CHANGELOG.md index cc07dc19d1..10bd6539eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,11 @@ _Note: Gaps between patch versions are faulty/broken releases._ See [CHANGELOG - 6to5](CHANGELOG-6to5.md) for the pre-4.0.0 version changelog. +## 5.2.1 + + * **Bug Fix** + * Fix regression in `node/register` that caused `node_modules` to not be ignored. + ## 5.2.0 * **Bug Fix** @@ -26,6 +31,7 @@ See [CHANGELOG - 6to5](CHANGELOG-6to5.md) for the pre-4.0.0 version changelog. * When inferring function names that collide with upper bindings, instead of doing the wrapper, instead rename them. * Consider constant-like variable declaration functions to always refer to themselves so TOC can be performed. * Process globs manually when using `$ babel` as some shells such as Windows don't explode them. Thanks [@jden](https://github.com/jden)! + * Add alternative way to execute plugins via a closure that's called with the current Babel instance. * **Internal** * Remove multiple internal transformers in favor of directly doing things when we need to. Previously, declarations such as `_ref` that we needed to create in specific scopes were done at the very end via the `_declarations` transformer. Now, they're done and added to the scope **right** when they're needed. This gets rid of the crappy `_declarations` property on scope nodes and fixes the crappy regenerator bug where it was creating a new `BlockStatement` so the declarations were being lost. * Rework transformer traversal optimisation. Turns out that calling a `check` function for **every single node** in the AST is ridiculously expensive. 300,000 nodes timesed by ~30 transformers meant that it took tens of seconds to perform while it's quicker to just do the unnecessary traversal. Seems obvious in hindsight. diff --git a/src/babel/api/register/node.js b/src/babel/api/register/node.js index 9db48f13d8..3f375c5a93 100644 --- a/src/babel/api/register/node.js +++ b/src/babel/api/register/node.js @@ -31,8 +31,10 @@ var cache = registerCache.get(); // var transformOpts = {}; -var ignoreRegex = /node_modules/; -var onlyRegex; + +var ignore; +var only; + var oldHandlers = {}; var maps = {}; @@ -76,7 +78,11 @@ var compile = function (filename) { }; var shouldIgnore = function (filename) { - return util.shouldIgnore(filename, ignoreRegex || [], onlyRegex || []); + if (!ignore && !only) { + return /node_modules/.test(filename); + } else { + return util.shouldIgnore(filename, ignore || [], only || []); + } }; var istanbulMonkey = {}; @@ -142,8 +148,8 @@ var hookExtensions = function (_exts) { hookExtensions(util.canCompile.EXTENSIONS); export default function (opts = {}) { - if (opts.only != null) onlyRegex = util.arrayify(opts.only, util.regexify); - if (opts.ignore != null) ignoreRegex = util.arrayify(opts.ignore, util.regexify); + if (opts.only != null) only = util.arrayify(opts.only, util.regexify); + if (opts.ignore != null) ignore = util.arrayify(opts.ignore, util.regexify); if (opts.extensions) hookExtensions(util.arrayify(opts.extensions));