{"action":"closed","number":203,"pull_request":{"url":"https://api.github.com/repos/wix/yoshi/pulls/203","id":131303300,"html_url":"https://github.com/wix/yoshi/pull/203","diff_url":"https://github.com/wix/yoshi/pull/203.diff","patch_url":"https://github.com/wix/yoshi/pull/203.patch","issue_url":"https://api.github.com/repos/wix/yoshi/issues/203","number":203,"state":"closed","locked":false,"title":"Run babel twice if needed for ES modules","user":{"login":"yardnsm","id":11786506,"avatar_url":"https://avatars2.githubusercontent.com/u/11786506?v=4","gravatar_id":"","url":"https://api.github.com/users/yardnsm","html_url":"https://github.com/yardnsm","followers_url":"https://api.github.com/users/yardnsm/followers","following_url":"https://api.github.com/users/yardnsm/following{/other_user}","gists_url":"https://api.github.com/users/yardnsm/gists{/gist_id}","starred_url":"https://api.github.com/users/yardnsm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yardnsm/subscriptions","organizations_url":"https://api.github.com/users/yardnsm/orgs","repos_url":"https://api.github.com/users/yardnsm/repos","events_url":"https://api.github.com/users/yardnsm/events{/privacy}","received_events_url":"https://api.github.com/users/yardnsm/received_events","type":"User","site_admin":false},"body":"In order for us to support tree-shaking, we need to run babel twice: for a CommonJS version, and for a ES modules version.\r\n\r\n(This PR won't break existing projects)\r\n\r\nWhen there's a `module` field in `package.json`, `yoshi-babel` will run babel twice:\r\n- According to user's `.babelrc`. Output goes to `./dist/es`.\r\n- According to user's `.babelrc` with [`transform-es2015-modules-commonjs`](https://babeljs.io/docs/plugins/transform-es2015-modules-commonjs/) plugin.\r\n\r\nThis requires users to add a `module` field to their `package.json` and modify their `.babelrc` to **not** transpile ES `import/export` to CommonJS `require`:\r\n\r\n```diff\r\n{\r\n  \"presets\": [\r\n-    \"es2015\",\r\n+    [\"es2015\", { \r\n+      \"modules\": false\r\n+    ],\r\n    \"react\",\r\n    \"stage-2\"\r\n  ]\r\n}\r\n```\r\n\r\n```diff\r\n{\r\n   \"main\": \"./dist/src/index.js\",\r\n+   \"module\": \"./dist/es/src/index.js\",\r\n}\r\n```\r\n\r\nThe same goes to `babel-preset-env` and the `transform-es2015-modules-commonjs` plugin.\r\n\r\nWhen in watch mode or when running tests, the `transform-es2015-modules-commonjs` plugin applies.\r\n\r\n**EDIT:** since `yoshi-jest` does not use the require hook, when setting `modules: false` in `.babelrc`,  the tests are failing. In `wix-style-react`, the solution was as follows:\r\n\r\n1. Install the `transform-es2015-modules-commonjs` plugin.\r\n2. Install to latest version of `babel-jest`.\r\n3. Add a `test` env to babel:\r\n```json\r\n\"env\": {\r\n  \"test\": {\r\n    \"plugins\": [\r\n      \"transform-es2015-modules-commonjs\"\r\n    ]\r\n  }\r\n}\r\n```\r\n```","created_at":"2017-07-19T11:57:36Z","updated_at":"2017-07-23T07:19:53Z","closed_at":"2017-07-23T07:19:53Z","merged_at":"2017-07-23T07:19:53Z","merge_commit_sha":"15e30cf2956e631031b4181d1f6319eac8ceb20b","assignee":{"login":"roymiloh","id":4408911,"avatar_url":"https://avatars0.githubusercontent.com/u/4408911?v=4","gravatar_id":"","url":"https://api.github.com/users/roymiloh","html_url":"https://github.com/roymiloh","followers_url":"https://api.github.com/users/roymiloh/followers","following_url":"https://api.github.com/users/roymiloh/following{/other_user}","gists_url":"https://api.github.com/users/roymiloh/gists{/gist_id}","starred_url":"https://api.github.com/users/roymiloh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roymiloh/subscriptions","organizations_url":"https://api.github.com/users/roymiloh/orgs","repos_url":"https://api.github.com/users/roymiloh/repos","events_url":"https://api.github.com/users/roymiloh/events{/privacy}","received_events_url":"https://api.github.com/users/roymiloh/received_events","type":"User","site_admin":false},"assignees":[{"login":"roymiloh","id":4408911,"avatar_url":"https://avatars0.githubusercontent.com/u/4408911?v=4","gravatar_id":"","url":"https://api.github.com/users/roymiloh","html_url":"https://github.com/roymiloh","followers_url":"https://api.github.com/users/roymiloh/followers","following_url":"https://api.github.com/users/roymiloh/following{/other_user}","gists_url":"https://api.github.com/users/roymiloh/gists{/gist_id}","starred_url":"https://api.github.com/users/roymiloh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roymiloh/subscriptions","organizations_url":"https://api.github.com/users/roymiloh/orgs","repos_url":"https://api.github.com/users/roymiloh/repos","events_url":"https://api.github.com/users/roymiloh/events{/privacy}","received_events_url":"https://api.github.com/users/roymiloh/received_events","type":"User","site_admin":false}],"requested_reviewers":[{"login":"shahata","id":1764161,"avatar_url":"https://avatars3.githubusercontent.com/u/1764161?v=4","gravatar_id":"","url":"https://api.github.com/users/shahata","html_url":"https://github.com/shahata","followers_url":"https://api.github.com/users/shahata/followers","following_url":"https://api.github.com/users/shahata/following{/other_user}","gists_url":"https://api.github.com/users/shahata/gists{/gist_id}","starred_url":"https://api.github.com/users/shahata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shahata/subscriptions","organizations_url":"https://api.github.com/users/shahata/orgs","repos_url":"https://api.github.com/users/shahata/repos","events_url":"https://api.github.com/users/shahata/events{/privacy}","received_events_url":"https://api.github.com/users/shahata/received_events","type":"User","site_admin":false},{"login":"roymiloh","id":4408911,"avatar_url":"https://avatars0.githubusercontent.com/u/4408911?v=4","gravatar_id":"","url":"https://api.github.com/users/roymiloh","html_url":"https://github.com/roymiloh","followers_url":"https://api.github.com/users/roymiloh/followers","following_url":"https://api.github.com/users/roymiloh/following{/other_user}","gists_url":"https://api.github.com/users/roymiloh/gists{/gist_id}","starred_url":"https://api.github.com/users/roymiloh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roymiloh/subscriptions","organizations_url":"https://api.github.com/users/roymiloh/orgs","repos_url":"https://api.github.com/users/roymiloh/repos","events_url":"https://api.github.com/users/roymiloh/events{/privacy}","received_events_url":"https://api.github.com/users/roymiloh/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/wix/yoshi/pulls/203/commits","review_comments_url":"https://api.github.com/repos/wix/yoshi/pulls/203/comments","review_comment_url":"https://api.github.com/repos/wix/yoshi/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wix/yoshi/issues/203/comments","statuses_url":"https://api.github.com/repos/wix/yoshi/statuses/7ff0f21979d908a0566545ba7aa5b09cfb4a52bd","head":{"label":"wix:babel-twice-esm","ref":"babel-twice-esm","sha":"7ff0f21979d908a0566545ba7aa5b09cfb4a52bd","user":{"login":"wix","id":686511,"avatar_url":"https://avatars1.githubusercontent.com/u/686511?v=4","gravatar_id":"","url":"https://api.github.com/users/wix","html_url":"https://github.com/wix","followers_url":"https://api.github.com/users/wix/followers","following_url":"https://api.github.com/users/wix/following{/other_user}","gists_url":"https://api.github.com/users/wix/gists{/gist_id}","starred_url":"https://api.github.com/users/wix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wix/subscriptions","organizations_url":"https://api.github.com/users/wix/orgs","repos_url":"https://api.github.com/users/wix/repos","events_url":"https://api.github.com/users/wix/events{/privacy}","received_events_url":"https://api.github.com/users/wix/received_events","type":"Organization","site_admin":false},"repo":{"id":83008380,"name":"yoshi","full_name":"wix/yoshi","owner":{"login":"wix","id":686511,"avatar_url":"https://avatars1.githubusercontent.com/u/686511?v=4","gravatar_id":"","url":"https://api.github.com/users/wix","html_url":"https://github.com/wix","followers_url":"https://api.github.com/users/wix/followers","following_url":"https://api.github.com/users/wix/following{/other_user}","gists_url":"https://api.github.com/users/wix/gists{/gist_id}","starred_url":"https://api.github.com/users/wix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wix/subscriptions","organizations_url":"https://api.github.com/users/wix/orgs","repos_url":"https://api.github.com/users/wix/repos","events_url":"https://api.github.com/users/wix/events{/privacy}","received_events_url":"https://api.github.com/users/wix/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wix/yoshi","description":"A tool for common tasks in Javascript projects","fork":false,"url":"https://api.github.com/repos/wix/yoshi","forks_url":"https://api.github.com/repos/wix/yoshi/forks","keys_url":"https://api.github.com/repos/wix/yoshi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wix/yoshi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wix/yoshi/teams","hooks_url":"https://api.github.com/repos/wix/yoshi/hooks","issue_events_url":"https://api.github.com/repos/wix/yoshi/issues/events{/number}","events_url":"https://api.github.com/repos/wix/yoshi/events","assignees_url":"https://api.github.com/repos/wix/yoshi/assignees{/user}","branches_url":"https://api.github.com/repos/wix/yoshi/branches{/branch}","tags_url":"https://api.github.com/repos/wix/yoshi/tags","blobs_url":"https://api.github.com/repos/wix/yoshi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wix/yoshi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wix/yoshi/git/refs{/sha}","trees_url":"https://api.github.com/repos/wix/yoshi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wix/yoshi/statuses/{sha}","languages_url":"https://api.github.com/repos/wix/yoshi/languages","stargazers_url":"https://api.github.com/repos/wix/yoshi/stargazers","contributors_url":"https://api.github.com/repos/wix/yoshi/contributors","subscribers_url":"https://api.github.com/repos/wix/yoshi/subscribers","subscription_url":"https://api.github.com/repos/wix/yoshi/subscription","commits_url":"https://api.github.com/repos/wix/yoshi/commits{/sha}","git_commits_url":"https://api.github.com/repos/wix/yoshi/git/commits{/sha}","comments_url":"https://api.github.com/repos/wix/yoshi/comments{/number}","issue_comment_url":"https://api.github.com/repos/wix/yoshi/issues/comments{/number}","contents_url":"https://api.github.com/repos/wix/yoshi/contents/{+path}","compare_url":"https://api.github.com/repos/wix/yoshi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wix/yoshi/merges","archive_url":"https://api.github.com/repos/wix/yoshi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wix/yoshi/downloads","issues_url":"https://api.github.com/repos/wix/yoshi/issues{/number}","pulls_url":"https://api.github.com/repos/wix/yoshi/pulls{/number}","milestones_url":"https://api.github.com/repos/wix/yoshi/milestones{/number}","notifications_url":"https://api.github.com/repos/wix/yoshi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wix/yoshi/labels{/name}","releases_url":"https://api.github.com/repos/wix/yoshi/releases{/id}","deployments_url":"https://api.github.com/repos/wix/yoshi/deployments","created_at":"2017-02-24T06:18:27Z","updated_at":"2017-07-15T16:35:50Z","pushed_at":"2017-07-23T07:19:53Z","git_url":"git://github.com/wix/yoshi.git","ssh_url":"git@github.com:wix/yoshi.git","clone_url":"https://github.com/wix/yoshi.git","svn_url":"https://github.com/wix/yoshi","homepage":"","size":5194,"stargazers_count":35,"watchers_count":35,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":48,"forks":8,"open_issues":48,"watchers":35,"default_branch":"master"}},"base":{"label":"wix:master","ref":"master","sha":"7006456c667c4e45de419d3d9fbd2b71a041a6c9","user":{"login":"wix","id":686511,"avatar_url":"https://avatars1.githubusercontent.com/u/686511?v=4","gravatar_id":"","url":"https://api.github.com/users/wix","html_url":"https://github.com/wix","followers_url":"https://api.github.com/users/wix/followers","following_url":"https://api.github.com/users/wix/following{/other_user}","gists_url":"https://api.github.com/users/wix/gists{/gist_id}","starred_url":"https://api.github.com/users/wix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wix/subscriptions","organizations_url":"https://api.github.com/users/wix/orgs","repos_url":"https://api.github.com/users/wix/repos","events_url":"https://api.github.com/users/wix/events{/privacy}","received_events_url":"https://api.github.com/users/wix/received_events","type":"Organization","site_admin":false},"repo":{"id":83008380,"name":"yoshi","full_name":"wix/yoshi","owner":{"login":"wix","id":686511,"avatar_url":"https://avatars1.githubusercontent.com/u/686511?v=4","gravatar_id":"","url":"https://api.github.com/users/wix","html_url":"https://github.com/wix","followers_url":"https://api.github.com/users/wix/followers","following_url":"https://api.github.com/users/wix/following{/other_user}","gists_url":"https://api.github.com/users/wix/gists{/gist_id}","starred_url":"https://api.github.com/users/wix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wix/subscriptions","organizations_url":"https://api.github.com/users/wix/orgs","repos_url":"https://api.github.com/users/wix/repos","events_url":"https://api.github.com/users/wix/events{/privacy}","received_events_url":"https://api.github.com/users/wix/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wix/yoshi","description":"A tool for common tasks in Javascript projects","fork":false,"url":"https://api.github.com/repos/wix/yoshi","forks_url":"https://api.github.com/repos/wix/yoshi/forks","keys_url":"https://api.github.com/repos/wix/yoshi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wix/yoshi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wix/yoshi/teams","hooks_url":"https://api.github.com/repos/wix/yoshi/hooks","issue_events_url":"https://api.github.com/repos/wix/yoshi/issues/events{/number}","events_url":"https://api.github.com/repos/wix/yoshi/events","assignees_url":"https://api.github.com/repos/wix/yoshi/assignees{/user}","branches_url":"https://api.github.com/repos/wix/yoshi/branches{/branch}","tags_url":"https://api.github.com/repos/wix/yoshi/tags","blobs_url":"https://api.github.com/repos/wix/yoshi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wix/yoshi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wix/yoshi/git/refs{/sha}","trees_url":"https://api.github.com/repos/wix/yoshi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wix/yoshi/statuses/{sha}","languages_url":"https://api.github.com/repos/wix/yoshi/languages","stargazers_url":"https://api.github.com/repos/wix/yoshi/stargazers","contributors_url":"https://api.github.com/repos/wix/yoshi/contributors","subscribers_url":"https://api.github.com/repos/wix/yoshi/subscribers","subscription_url":"https://api.github.com/repos/wix/yoshi/subscription","commits_url":"https://api.github.com/repos/wix/yoshi/commits{/sha}","git_commits_url":"https://api.github.com/repos/wix/yoshi/git/commits{/sha}","comments_url":"https://api.github.com/repos/wix/yoshi/comments{/number}","issue_comment_url":"https://api.github.com/repos/wix/yoshi/issues/comments{/number}","contents_url":"https://api.github.com/repos/wix/yoshi/contents/{+path}","compare_url":"https://api.github.com/repos/wix/yoshi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wix/yoshi/merges","archive_url":"https://api.github.com/repos/wix/yoshi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wix/yoshi/downloads","issues_url":"https://api.github.com/repos/wix/yoshi/issues{/number}","pulls_url":"https://api.github.com/repos/wix/yoshi/pulls{/number}","milestones_url":"https://api.github.com/repos/wix/yoshi/milestones{/number}","notifications_url":"https://api.github.com/repos/wix/yoshi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wix/yoshi/labels{/name}","releases_url":"https://api.github.com/repos/wix/yoshi/releases{/id}","deployments_url":"https://api.github.com/repos/wix/yoshi/deployments","created_at":"2017-02-24T06:18:27Z","updated_at":"2017-07-15T16:35:50Z","pushed_at":"2017-07-23T07:19:53Z","git_url":"git://github.com/wix/yoshi.git","ssh_url":"git@github.com:wix/yoshi.git","clone_url":"https://github.com/wix/yoshi.git","svn_url":"https://github.com/wix/yoshi","homepage":"","size":5194,"stargazers_count":35,"watchers_count":35,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":48,"forks":8,"open_issues":48,"watchers":35,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wix/yoshi/pulls/203"},"html":{"href":"https://github.com/wix/yoshi/pull/203"},"issue":{"href":"https://api.github.com/repos/wix/yoshi/issues/203"},"comments":{"href":"https://api.github.com/repos/wix/yoshi/issues/203/comments"},"review_comments":{"href":"https://api.github.com/repos/wix/yoshi/pulls/203/comments"},"review_comment":{"href":"https://api.github.com/repos/wix/yoshi/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wix/yoshi/pulls/203/commits"},"statuses":{"href":"https://api.github.com/repos/wix/yoshi/statuses/7ff0f21979d908a0566545ba7aa5b09cfb4a52bd"}},"merged":true,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":{"login":"yardnsm","id":11786506,"avatar_url":"https://avatars2.githubusercontent.com/u/11786506?v=4","gravatar_id":"","url":"https://api.github.com/users/yardnsm","html_url":"https://github.com/yardnsm","followers_url":"https://api.github.com/users/yardnsm/followers","following_url":"https://api.github.com/users/yardnsm/following{/other_user}","gists_url":"https://api.github.com/users/yardnsm/gists{/gist_id}","starred_url":"https://api.github.com/users/yardnsm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yardnsm/subscriptions","organizations_url":"https://api.github.com/users/yardnsm/orgs","repos_url":"https://api.github.com/users/yardnsm/repos","events_url":"https://api.github.com/users/yardnsm/events{/privacy}","received_events_url":"https://api.github.com/users/yardnsm/received_events","type":"User","site_admin":false},"comments":2,"review_comments":4,"maintainer_can_modify":false,"commits":6,"additions":133,"deletions":10,"changed_files":10}}
{"actor":{"display_login":"yardnsm"}}