Skip to content

Commit eda41e1

Browse files
sj26Jasper De Moor
authored andcommitted
Fix babel config in package.json (#1515)
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.
1 parent 40fb76f commit eda41e1

3 files changed

Lines changed: 7 additions & 1 deletion

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"babylon-walk": "^1.0.2",
2929
"browserslist": "^3.2.6",
3030
"chalk": "^2.1.0",
31+
"clone": "^2.1.1",
3132
"command-exists": "^1.2.6",
3233
"commander": "^2.11.0",
3334
"cross-spawn": "^6.0.4",

src/Asset.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const URL = require('url');
22
const path = require('path');
3+
const clone = require('clone');
34
const fs = require('./utils/fs');
45
const objectHash = require('./utils/objectHash');
56
const md5 = require('./utils/md5');
@@ -136,7 +137,7 @@ class Asset {
136137
if (opts.packageKey) {
137138
let pkg = await this.getPackage();
138139
if (pkg && pkg[opts.packageKey]) {
139-
return pkg[opts.packageKey];
140+
return clone(pkg[opts.packageKey]);
140141
}
141142
}
142143

yarn.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,6 +1328,10 @@ clone@^1.0.2:
13281328
version "1.0.4"
13291329
resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e"
13301330

1331+
clone@^2.1.1:
1332+
version "2.1.1"
1333+
resolved "https://registry.yarnpkg.com/clone/-/clone-2.1.1.tgz#d217d1e961118e3ac9a4b8bba3285553bf647cdb"
1334+
13311335
clones@^1.1.0:
13321336
version "1.1.0"
13331337
resolved "https://registry.yarnpkg.com/clones/-/clones-1.1.0.tgz#87e904132d6140c5c0b72006c08c0d05bd7b63b3"

0 commit comments

Comments
 (0)