From f90b9798def35636e7a413d475b850bbfcc6a3cc Mon Sep 17 00:00:00 2001 From: Samuel Cochran Date: Sat, 9 Jun 2018 16:40:01 +1000 Subject: [PATCH] Fix babel config in package.json Babel seems to mutate the passed-in config, so if we pass in the package.babel directly it will mutate the package config, then the next time it compiles the same file it will have duplicate plugins, etc. Instead, if loading config from a packageKey, clone the config before returning so it can't be mutated. --- package.json | 1 + src/Asset.js | 3 ++- yarn.lock | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 5110b02abdc..a01f058aa08 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "babylon-walk": "^1.0.2", "browserslist": "^3.2.6", "chalk": "^2.1.0", + "clone": "^2.1.1", "command-exists": "^1.2.6", "commander": "^2.11.0", "cross-spawn": "^6.0.4", diff --git a/src/Asset.js b/src/Asset.js index 9854f193cbd..0931a4fffe5 100644 --- a/src/Asset.js +++ b/src/Asset.js @@ -1,5 +1,6 @@ const URL = require('url'); const path = require('path'); +const clone = require('clone'); const fs = require('./utils/fs'); const objectHash = require('./utils/objectHash'); const md5 = require('./utils/md5'); @@ -136,7 +137,7 @@ class Asset { if (opts.packageKey) { let pkg = await this.getPackage(); if (pkg && pkg[opts.packageKey]) { - return pkg[opts.packageKey]; + return clone(pkg[opts.packageKey]); } } diff --git a/yarn.lock b/yarn.lock index 11c90012106..202ca80dd7b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1328,6 +1328,10 @@ clone@^1.0.2: version "1.0.4" resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e" +clone@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/clone/-/clone-2.1.1.tgz#d217d1e961118e3ac9a4b8bba3285553bf647cdb" + clones@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/clones/-/clones-1.1.0.tgz#87e904132d6140c5c0b72006c08c0d05bd7b63b3"