-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure overridden babel config plugins array is immutable #675
Conversation
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.
By analyzing the blame information on this pull request, we identified @spudly to be a potential reviewer |
Nice catch @dcousineau! Could you perhaps add a test as well? Thanks. |
@novemberborn Yeah, I was going to copy the last test in the caching-precompiler test file but am hitting the end of my day. I'll circle back in a little bit and do so. Also IRT the build failures: it looks like npm install failed on travis? |
No worries. It's late here too ;-)
Wow all tests red! I guess we'll try again when you push the test. |
@novemberborn FYI my timing was impeccable:
https://medium.com/@azerbike/i-ve-just-liberated-my-modules-9045c06be67c#.bmwp4a3le |
Yeah... I've restarted the builds. |
@sindresorhus what a time to be alive~ |
Nice catch, dcousineau! Sorry you had to waste so much of your own time fixing a bug I introduced. |
@spudly to be fair my issue wasn't a bug it was a misunderstanding on my part, I just happened to find this digging in and trying to understand AVA's behavior :) |
@dcousineau Could you please add a test to ensure this won't happen in future? Would like to merge it asap ;) Thanks! |
Hey @dcousineau, I've taken your fix here and added a test, see #717. Hope you don't mind, we just want to try get a fix out soon :) Thanks for digging through the code and finding the bug! |
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 appending 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.
Does not solve #674 however it was noticed during an attempt to address that issue.