{"action":"created","issue":{"url":"https://api.github.com/repos/babel/babel/issues/1337","labels_url":"https://api.github.com/repos/babel/babel/issues/1337/labels{/name}","comments_url":"https://api.github.com/repos/babel/babel/issues/1337/comments","events_url":"https://api.github.com/repos/babel/babel/issues/1337/events","html_url":"https://github.com/babel/babel/issues/1337","id":70585233,"number":1337,"title":"Babel > 5 's es6 module syntax output breaks rewire-webpack","user":{"login":"sairion","id":484290,"avatar_url":"https://avatars.githubusercontent.com/u/484290?v=3","gravatar_id":"","url":"https://api.github.com/users/sairion","html_url":"https://github.com/sairion","followers_url":"https://api.github.com/users/sairion/followers","following_url":"https://api.github.com/users/sairion/following{/other_user}","gists_url":"https://api.github.com/users/sairion/gists{/gist_id}","starred_url":"https://api.github.com/users/sairion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sairion/subscriptions","organizations_url":"https://api.github.com/users/sairion/orgs","repos_url":"https://api.github.com/users/sairion/repos","events_url":"https://api.github.com/users/sairion/events{/privacy}","received_events_url":"https://api.github.com/users/sairion/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":46,"created_at":"2015-04-24T04:40:38Z","updated_at":"2015-05-13T11:49:22Z","closed_at":"2015-04-24T09:15:16Z","body":"Please see my comment over their issuetracker -> https://github.com/jhnns/rewire-webpack/issues/12#issuecomment-95797024\r\n\r\n(Actually I'm not sure its Babel > 5 's own problem since I was not using Babel for a bit of time)"},"comment":{"url":"https://api.github.com/repos/babel/babel/issues/comments/101637381","html_url":"https://github.com/babel/babel/issues/1337#issuecomment-101637381","issue_url":"https://api.github.com/repos/babel/babel/issues/1337","id":101637381,"user":{"login":"speedskater","id":1639779,"avatar_url":"https://avatars.githubusercontent.com/u/1639779?v=3","gravatar_id":"","url":"https://api.github.com/users/speedskater","html_url":"https://github.com/speedskater","followers_url":"https://api.github.com/users/speedskater/followers","following_url":"https://api.github.com/users/speedskater/following{/other_user}","gists_url":"https://api.github.com/users/speedskater/gists{/gist_id}","starred_url":"https://api.github.com/users/speedskater/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/speedskater/subscriptions","organizations_url":"https://api.github.com/users/speedskater/orgs","repos_url":"https://api.github.com/users/speedskater/repos","events_url":"https://api.github.com/users/speedskater/events{/privacy}","received_events_url":"https://api.github.com/users/speedskater/received_events","type":"User","site_admin":false},"created_at":"2015-05-13T11:49:22Z","updated_at":"2015-05-13T11:49:22Z","body":"@jhnns The code generates the methods __Rewire__, __GetDependency__ and __ResetDependency__ and internally dispatches them to the corresponding getters and setters, which allow to modify the respective imported models.\r\n\r\ne.g.:\r\n\r\n```js\r\nimport MyModule from 'path/to/MyModule.js';\r\n\r\nexport default \"\";\r\n```\r\nwill be transformed to:\r\n```js\r\n\"use strict\";\r\n\r\nexport { __GetDependency__ };\r\nexport { __Rewire__ };\r\nexport { __ResetDependency__ };\r\nimport _MyModuleTemp from \"path/to/MyModule.js\";\r\n\r\nvar __$Getters__ = [];\r\nvar __$Setters__ = [];\r\nvar __$Resetters__ = [];\r\n\r\nfunction __GetDependency__(name) {\r\n  return __$Getters__[name]();\r\n}\r\n\r\nfunction __Rewire__(name, value) {\r\n  __$Setters__[name](value);\r\n}\r\n\r\nfunction __ResetDependency__(name) {\r\n  __$Resetters__[name]();\r\n}\r\n\r\nvar MyModule = _MyModuleTemp;\r\n\r\nfunction __setMyModule__(value) {\r\n  MyModule = value;\r\n}\r\n\r\nfunction __getMyModule__() {\r\n  return MyModule;\r\n}\r\n\r\nfunction __resetMyModule__() {\r\n  MyModule = _MyModuleTemp;\r\n}\r\n\r\n__$Getters__[\"MyModule\"] = __getMyModule__;\r\n__$Setters__[\"MyModule\"] = __setMyModule__;\r\n__$Resetters__[\"MyModule\"] = __resetMyModule__;\r\nexport default Object.assign(\"\", {\r\n  \"__Rewire__\": __Rewire__,\r\n  \"__set__\": __Rewire__,\r\n  \"__ResetDependency__\": __ResetDependency__,\r\n  \"__GetDependency__\": __GetDependency__,\r\n  \"__get__\": __GetDependency__\r\n});\r\n```\r\n\r\nRegarding the compatibility to rewire.js you are right. It was a mistake from my side. I just added the respective methods \\_\\_set\\_\\_ and \\_\\_get\\_\\_ for compatibility reasons.  \r\n\r\nRegarding the \\_\\_with\\_\\_ method, it would imho make more sense to move the respective code into a small library which can work with rewire.js as well as babel-plugin-rewire. In case of BDD style tests I would propose the following API for it (automatically adds afterEach) and could publish it into a new project (e.g. named use-require) the day after tomorrow. @jhns what do you think?\r\n\r\n```js\r\nimport useRewire from 'use-rewire';\r\nimport ComponentToTest from 'my-fancy-wrapper-component-module';\r\n\r\nComponentToTest.__Rewire__('ChildComponent', React.createClass({\r\n    render: function() { return <div {...this.props}></div>; }\r\n}));\r\n\r\ndescribe('Tests my fancy wrapper module', function() {\r\n\tvar rewire = useRewire();\r\n\r\n\tit('renderTest', function() {\r\n\t\trewire(ComponentToTest, 'ChildComponent', React.createClass({\r\n    \t\t\trender: function() { return <div {...this.props}></div>; }\r\n\t\t}));\r\n\r\n                 ..... test component ....\r\n\t});\r\n});\r\n\r\n```"}}