Skip to content
This repository has been archived by the owner on Apr 9, 2020. It is now read-only.

Issue with mangling imports #37

Closed
technicallyfeasible opened this issue Oct 14, 2015 · 5 comments
Closed

Issue with mangling imports #37

technicallyfeasible opened this issue Oct 14, 2015 · 5 comments
Labels

Comments

@technicallyfeasible
Copy link

I have a problem with imports when using react-transform and am not quite sure if this is created by react-transform or babel itself or even something I am doing wrong in my config.

In my source file, I am importing a file like this:

import widgetGroups from '../widgetGroups';

Without react-transform, babel translates it to:

var _widgetGroups2 = __webpack_require__(1153);
var _widgetGroups3 = _interopRequireDefault(_widgetGroups2);

Whereas with react-transform, I get:

var _widgetGroups = __webpack_require__(1153);
var _widgetGroups2 = _interopRequireDefault(_widgetGroups2['default']);

This obviously cannot work and throws an error.

@technicallyfeasible
Copy link
Author

To possibly answer my own question. This issue was caused by the module importing widgetGroups. There was a naming conflict which did not throw a compiler error but silently changed variable names to non-conflicting ones. Here's a skeleton of the class:

import widgetGroups from '../widgetGroups';

export default class WidgetGroup extends Component {
  render() {
    return (
      <div>
        {this.widgetGroups()}
      </div>
    );
  }

  widgetGroups() {
    return widgetGroups;
  }
}

Renaming the function widgetGroups to getWidgetGroups solved it.

@gaearon
Copy link
Owner

gaearon commented Oct 15, 2015

Do you think you can whip up a failing test from this?

@BenoitZugmeyer
Copy link

Trying to migrate from react-hot-loader to this stuff, I have the same issue. I wrote a fixture to reproduce: BenoitZugmeyer@6ec563b

@gaearon
Copy link
Owner

gaearon commented Oct 20, 2015

Thanks. If you can take time to try to fix it I'd appreciate. :-)

@gaearon gaearon added the bug label Oct 20, 2015
@gaearon
Copy link
Owner

gaearon commented Mar 5, 2016

I can’t reproduce this in 2.x.
Most probably this has been fixed as part of the rewrite.
Please let me know if you still have this issue!

@gaearon gaearon closed this as completed Mar 5, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants