{"action":"opened","issue":{"url":"https://api.github.com/repos/babel/babel/issues/2017","labels_url":"https://api.github.com/repos/babel/babel/issues/2017/labels{/name}","comments_url":"https://api.github.com/repos/babel/babel/issues/2017/comments","events_url":"https://api.github.com/repos/babel/babel/issues/2017/events","html_url":"https://github.com/babel/babel/issues/2017","id":95384662,"number":2017,"title":"transformFileSync is undefined in compiled code","user":{"login":"Globegitter","id":2580254,"avatar_url":"https://avatars.githubusercontent.com/u/2580254?v=3","gravatar_id":"","url":"https://api.github.com/users/Globegitter","html_url":"https://github.com/Globegitter","followers_url":"https://api.github.com/users/Globegitter/followers","following_url":"https://api.github.com/users/Globegitter/following{/other_user}","gists_url":"https://api.github.com/users/Globegitter/gists{/gist_id}","starred_url":"https://api.github.com/users/Globegitter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Globegitter/subscriptions","organizations_url":"https://api.github.com/users/Globegitter/orgs","repos_url":"https://api.github.com/users/Globegitter/repos","events_url":"https://api.github.com/users/Globegitter/events{/privacy}","received_events_url":"https://api.github.com/users/Globegitter/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-16T08:57:21Z","updated_at":"2015-07-16T08:57:21Z","closed_at":null,"body":"I am on node.js (v0.10.25) / io.js (v2.3.4) and have code as follows:\r\n\r\n```js\r\nimport babel from 'babel';\r\n\r\nlet {code} = babel.transformFileSync(filename, {\r\n  'stage'   : 0,\r\n  'loose'   : true,\r\n  'optional': 'runtime',\r\n  'modules' : 'common'\r\n});\r\n```\r\n\r\nThen I compile this code using `babel src --out-dir lib` and the same babel settings as above.\r\n\r\nThis yields roughly to following code:\r\n\r\n```js\r\nvar _interopRequireDefault = require('babel-runtime/helpers/interop-require-default')['default'];\r\n\r\nvar _babel = require('babel');\r\n\r\nvar _babel2 = _interopRequireDefault(_babel);\r\n\r\nvar _babel$transformFileSync = _babel2['default'].transformFileSync(filename, {\r\n      'stage': 0,\r\n      'loose': true,\r\n      'optional': 'runtime',\r\n      'modules': 'common'\r\n    });\r\n\r\n    var code = _babel$transformFileSync.code;\r\n```\r\nWhen I then set filename to something and run the code it throws the following error:\r\n```js\r\n/home/mpadourek/Projects/experiments/Nord.js/lib/Server.js:84\r\n    var _babel$transformFileSync = _babel2['default'].transformFileSync(filena\r\n                                                      ^\r\nTypeError: Cannot call method 'transformFileSync' of undefined\r\n    at NordServer.transformAppCode (/Projects/experiments/Nord.js/lib/Server.js:84:55)\r\n    at Object.<anonymous> (/Projects/experiments/Nord.js/lib/Server.js:120:9)\r\n    at Module._compile (module.js:456:26)\r\n    at Object.Module._extensions..js (module.js:474:10)\r\n    at Module.load (module.js:356:32)\r\n    at Function.Module._load (module.js:312:12)\r\n    at Function.Module.runMain (module.js:497:10)\r\n    at startup (node.js:119:16)\r\n    at node.js:902:3\r\n```\r\n\r\nThere seem to be two simple fixes which make the above code work. Either change `_babel2['default']` to `_babel2` in the compiled code or change the `babel-runtime/helpers/interop-require-default` file to following:\r\n\r\n```js\r\n\"use strict\";\r\n\r\nexports[\"default\"] = function (obj) {\r\n  return {\r\n    \"default\": obj\r\n  };\r\n};\r\n\r\nexports.__esModule = true;\r\n```\r\n\r\nNot sure if either of these are proper solutions but there we go. Let me know if you need any other information."}}