Skip to content

Commit

Permalink
Fix babel config in package.json (#1515)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sj26 authored and Jasper De Moor committed Jun 9, 2018
1 parent 40fb76f commit eda41e1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion 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');
Expand Down Expand Up @@ -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]);
}
}

Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Expand Up @@ -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"
Expand Down

0 comments on commit eda41e1

Please sign in to comment.