{"action":"created","issue":{"url":"https://api.github.com/repos/babel/babel/issues/6954","repository_url":"https://api.github.com/repos/babel/babel","labels_url":"https://api.github.com/repos/babel/babel/issues/6954/labels{/name}","comments_url":"https://api.github.com/repos/babel/babel/issues/6954/comments","events_url":"https://api.github.com/repos/babel/babel/issues/6954/events","html_url":"https://github.com/babel/babel/issues/6954","id":278633930,"number":6954,"title":"Bug: @babel/transform-modules-commonjs: loose does not work","user":{"login":"michael-brade","id":8768950,"avatar_url":"https://avatars0.githubusercontent.com/u/8768950?v=4","gravatar_id":"","url":"https://api.github.com/users/michael-brade","html_url":"https://github.com/michael-brade","followers_url":"https://api.github.com/users/michael-brade/followers","following_url":"https://api.github.com/users/michael-brade/following{/other_user}","gists_url":"https://api.github.com/users/michael-brade/gists{/gist_id}","starred_url":"https://api.github.com/users/michael-brade/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michael-brade/subscriptions","organizations_url":"https://api.github.com/users/michael-brade/orgs","repos_url":"https://api.github.com/users/michael-brade/repos","events_url":"https://api.github.com/users/michael-brade/events{/privacy}","received_events_url":"https://api.github.com/users/michael-brade/received_events","type":"User","site_admin":false},"labels":[{"id":438612746,"url":"https://api.github.com/repos/babel/babel/labels/good%20first%20issue","name":"good first issue","color":"bfdadc","default":true},{"id":441915610,"url":"https://api.github.com/repos/babel/babel/labels/help%20wanted","name":"help wanted","color":"bfdadc","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":21,"created_at":"2017-12-02T00:15:14Z","updated_at":"2017-12-16T18:49:35Z","closed_at":null,"author_association":"NONE","body":"[This](https://babeljs.io/docs/plugins/transform-es2015-modules-commonjs/) and [this](https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-modules-commonjs) claims that:\r\n\r\n> As per the spec, import and export are only allowed to be used at the top level. When in loose mode these are allowed to be used anywhere.\r\n\r\nHowever, not with babel 6 or babel 7 will it work.\r\n\r\n### Input Code\r\n\r\n```js\r\nfunction test() {\r\n\timport 'which'\r\n}\r\n```\r\n\r\n### Babel/Babylon Configuration (.babelrc, package.json, cli command)\r\n\r\n```js\r\n{\r\n    \"presets\": [\"@babel/es2015\"],\r\n    \"plugins\": [\r\n      [\"@babel/transform-modules-commonjs\",  { \"loose\": true }],\r\n      \"@babel/syntax-object-rest-spread\"\r\n    ]\r\n}\r\n```\r\n\r\n### Expected Behavior\r\n\r\nIt should compile.\r\n\r\n### Current Behavior\r\n\r\nSyntaxError: 'import' and 'export' may only appear at the top level\r\n\r\n### Your Environment\r\n<!--- Include as many relevant details about the environment you experienced the bug in -->\r\n\r\n| software         | version(s)\r\n| ---------------- | -------\r\n| Babel            |  7.0.0-beta.33\r\n| node             |  8.6.0\r\n| Operating System | linux\r\n"},"comment":{"url":"https://api.github.com/repos/babel/babel/issues/comments/352203124","html_url":"https://github.com/babel/babel/issues/6954#issuecomment-352203124","issue_url":"https://api.github.com/repos/babel/babel/issues/6954","id":352203124,"user":{"login":"perinikhil","id":8386739,"avatar_url":"https://avatars3.githubusercontent.com/u/8386739?v=4","gravatar_id":"","url":"https://api.github.com/users/perinikhil","html_url":"https://github.com/perinikhil","followers_url":"https://api.github.com/users/perinikhil/followers","following_url":"https://api.github.com/users/perinikhil/following{/other_user}","gists_url":"https://api.github.com/users/perinikhil/gists{/gist_id}","starred_url":"https://api.github.com/users/perinikhil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/perinikhil/subscriptions","organizations_url":"https://api.github.com/users/perinikhil/orgs","repos_url":"https://api.github.com/users/perinikhil/repos","events_url":"https://api.github.com/users/perinikhil/events{/privacy}","received_events_url":"https://api.github.com/users/perinikhil/received_events","type":"User","site_admin":false},"created_at":"2017-12-16T18:49:35Z","updated_at":"2017-12-16T18:49:35Z","author_association":"CONTRIBUTOR","body":"@abianco3 \r\nI'm the one who should apologise as i jumped the gun and raised a PR while you were still working on it... 😅 \r\nI'd be happy to see a `contributor` badge next on your name as penance 😌 \r\nso do raise a PR 😇 "}}
{"actor":{"display_login":"perinikhil"}}