{"action":"created","issue":{"url":"https://api.github.com/repos/babel/babel/issues/5665","repository_url":"https://api.github.com/repos/babel/babel","labels_url":"https://api.github.com/repos/babel/babel/issues/5665/labels{/name}","comments_url":"https://api.github.com/repos/babel/babel/issues/5665/comments","events_url":"https://api.github.com/repos/babel/babel/issues/5665/events","html_url":"https://github.com/babel/babel/issues/5665","id":224128142,"number":5665,"title":"babelrc.js exporting a function which accepts an environment","user":{"login":"k15a","id":20357450,"avatar_url":"https://avatars1.githubusercontent.com/u/20357450?v=3","gravatar_id":"","url":"https://api.github.com/users/k15a","html_url":"https://github.com/k15a","followers_url":"https://api.github.com/users/k15a/followers","following_url":"https://api.github.com/users/k15a/following{/other_user}","gists_url":"https://api.github.com/users/k15a/gists{/gist_id}","starred_url":"https://api.github.com/users/k15a/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/k15a/subscriptions","organizations_url":"https://api.github.com/users/k15a/orgs","repos_url":"https://api.github.com/users/k15a/repos","events_url":"https://api.github.com/users/k15a/events{/privacy}","received_events_url":"https://api.github.com/users/k15a/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-04-25T12:56:28Z","updated_at":"2017-04-25T12:56:30Z","closed_at":null,"body":"Hey,\r\n\r\nwebpack introduced a new way to change the config with version 2. You can now export a function which will be called with an [environment](https://webpack.js.org/configuration/configuration-types/#exporting-a-function-to-use-env). In regards of the [deprecation of the env option](https://github.com/babel/babel/issues/5276) and the [new  `babelrc.js` file](https://github.com/babel/babel/pull/4892) I could imagine that Babel@8 could benefit of such a feature too.\r\n\r\nBasically you can pass environments into the config with cli arguments for example:\r\n```\r\nbabel src --out-dir lib --env.node --env.modules\r\n```\r\nThe `babelrc.js` file will export a function which will be called with the environment:\r\n```js\r\nmodule.exports = function config(env) {\r\n  return {\r\n    presets: [\r\n      ['env', {\r\n        modules: env.modules,\r\n        node: env.node,\r\n      }]\r\n    ]\r\n  }\r\n}\r\n```\r\n\r\nOne thing that needs to be figured out is how to pass an environment with `babel-loader` or `rollup-plugin-babel`."},"comment":{"url":"https://api.github.com/repos/babel/babel/issues/comments/297021064","html_url":"https://github.com/babel/babel/issues/5665#issuecomment-297021064","issue_url":"https://api.github.com/repos/babel/babel/issues/5665","id":297021064,"user":{"login":"babel-bot","id":21250019,"avatar_url":"https://avatars2.githubusercontent.com/u/21250019?v=3","gravatar_id":"","url":"https://api.github.com/users/babel-bot","html_url":"https://github.com/babel-bot","followers_url":"https://api.github.com/users/babel-bot/followers","following_url":"https://api.github.com/users/babel-bot/following{/other_user}","gists_url":"https://api.github.com/users/babel-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/babel-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/babel-bot/subscriptions","organizations_url":"https://api.github.com/users/babel-bot/orgs","repos_url":"https://api.github.com/users/babel-bot/repos","events_url":"https://api.github.com/users/babel-bot/events{/privacy}","received_events_url":"https://api.github.com/users/babel-bot/received_events","type":"User","site_admin":false},"created_at":"2017-04-25T12:56:30Z","updated_at":"2017-04-25T12:56:30Z","body":"Hey @k15a! We really appreciate you taking the time to report an issue. The collaborators\non this project attempt to help as many people as possible, but we're a limited number of volunteers,\nso it's possible this won't be addressed swiftly.\n\nIf you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack\ncommunity that typically always has someone willing to help. You can sign-up [here](https://slack.babeljs.io/)\nfor an invite."}}
{"actor":{"display_login":"babel-bot"}}