Skip to content

Commit 5b3c27a

Browse files
novemberbornsindresorhus
authored andcommitted
don't modify configured babel plugins array
1 parent c4ec8e7 commit 5b3c27a

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/caching-precompiler.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ CachingPrecompiler.prototype._buildOptions = function (filePath, code) {
109109
ast: false
110110
});
111111

112-
options.plugins = options.plugins || [];
113-
options.plugins.push.apply(options.plugins, this.defaultPlugins);
112+
options.plugins = (options.plugins || []).concat(this.defaultPlugins);
114113

115114
return options;
116115
};

test/caching-precompiler.js

+11
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,14 @@ test('uses babelConfig for babel options when babelConfig is an object', functio
148148
t.same(options.plugins, [customPlugin, powerAssert, rewrite, transformRuntime]);
149149
t.end();
150150
});
151+
152+
test('does not modify plugins array in babelConfig', function (t) {
153+
var plugins = [];
154+
var precompiler = new CachingPrecompiler(uniqueTempDir(), {
155+
plugins: plugins
156+
});
157+
158+
precompiler.precompileFile(fixture('es2015.js'));
159+
t.same(plugins, []);
160+
t.end();
161+
});

0 commit comments

Comments
 (0)