From d64c2c0c45799148b666de507629cb9b0c18e743 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Fri, 3 Apr 2015 23:10:09 +1100 Subject: [PATCH] turn internalRemap into a null inherited object, fixes a nasty bug where module import live bindings would return a function if they referenced a method on Object.prototype (eg. toString) --- src/babel/transformation/modules/_default.js | 2 +- .../misc/regression-lodash-tostring-import/actual.js | 2 ++ .../misc/regression-lodash-tostring-import/expected.js | 9 +++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 test/core/fixtures/transformation/misc/regression-lodash-tostring-import/actual.js create mode 100644 test/core/fixtures/transformation/misc/regression-lodash-tostring-import/expected.js diff --git a/src/babel/transformation/modules/_default.js b/src/babel/transformation/modules/_default.js index 592890887c..2d36ccb78f 100644 --- a/src/babel/transformation/modules/_default.js +++ b/src/babel/transformation/modules/_default.js @@ -106,12 +106,12 @@ var exportsVisitor = traverse.explode({ export default class DefaultFormatter { constructor(file) { - this.internalRemap = {}; this.defaultIds = object(); this.scope = file.scope; this.file = file; this.ids = object(); + this.internalRemap = object(); this.hasNonDefaultExports = false; diff --git a/test/core/fixtures/transformation/misc/regression-lodash-tostring-import/actual.js b/test/core/fixtures/transformation/misc/regression-lodash-tostring-import/actual.js new file mode 100644 index 0000000000..9fa4842a8e --- /dev/null +++ b/test/core/fixtures/transformation/misc/regression-lodash-tostring-import/actual.js @@ -0,0 +1,2 @@ +import toString from "foo"; +toString; diff --git a/test/core/fixtures/transformation/misc/regression-lodash-tostring-import/expected.js b/test/core/fixtures/transformation/misc/regression-lodash-tostring-import/expected.js new file mode 100644 index 0000000000..935f40aa45 --- /dev/null +++ b/test/core/fixtures/transformation/misc/regression-lodash-tostring-import/expected.js @@ -0,0 +1,9 @@ +"use strict"; + +var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; }; + +var _toString = require("foo"); + +var toString = _interopRequire(_toString); + +toString;