Skip to content

Commit

Permalink
Addresses strange behavior found investigating avajs#674
Browse files Browse the repository at this point in the history
Since `babelConfig` in the CachingPrecompiler.prototype._factory method was a JavaScript object coming from an external source, the .push was altering the array in place. objectAssign is shallow so the plugins were being mutated, ensuring that AVA's required plugins were continually apending for each file loaded and parsed.

Using .concat ensures the original plugins array is not mutated and thus doesn't collect plugins like a hoarder.
  • Loading branch information
dcousineau committed Mar 22, 2016
1 parent 92e034b commit 0733ff0
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/caching-precompiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ CachingPrecompiler.prototype._factory = function (babelConfig, cacheDir) {
ast: false
});

options.plugins = options.plugins || [];
options.plugins.push(powerAssert, transformRuntime, rewriteRuntime);
options.plugins = (options.plugins || []).concat([powerAssert, transformRuntime, rewriteRuntime]);

return options;
}
Expand Down

0 comments on commit 0733ff0

Please sign in to comment.