{"action":"created","issue":{"url":"https://api.github.com/repos/tleunen/babel-plugin-module-resolver/issues/352","repository_url":"https://api.github.com/repos/tleunen/babel-plugin-module-resolver","labels_url":"https://api.github.com/repos/tleunen/babel-plugin-module-resolver/issues/352/labels{/name}","comments_url":"https://api.github.com/repos/tleunen/babel-plugin-module-resolver/issues/352/comments","events_url":"https://api.github.com/repos/tleunen/babel-plugin-module-resolver/issues/352/events","html_url":"https://github.com/tleunen/babel-plugin-module-resolver/issues/352","id":408404833,"node_id":"MDU6SXNzdWU0MDg0MDQ4MzM=","number":352,"title":"[Babel 7] Issues picking up .babelrc config in separate project","user":{"login":"kybishop","id":679465,"node_id":"MDQ6VXNlcjY3OTQ2NQ==","avatar_url":"https://avatars0.githubusercontent.com/u/679465?v=4","gravatar_id":"","url":"https://api.github.com/users/kybishop","html_url":"https://github.com/kybishop","followers_url":"https://api.github.com/users/kybishop/followers","following_url":"https://api.github.com/users/kybishop/following{/other_user}","gists_url":"https://api.github.com/users/kybishop/gists{/gist_id}","starred_url":"https://api.github.com/users/kybishop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kybishop/subscriptions","organizations_url":"https://api.github.com/users/kybishop/orgs","repos_url":"https://api.github.com/users/kybishop/repos","events_url":"https://api.github.com/users/kybishop/events{/privacy}","received_events_url":"https://api.github.com/users/kybishop/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2019-02-09T06:38:55Z","updated_at":"2019-02-15T20:52:14Z","closed_at":"2019-02-15T20:52:14Z","author_association":"NONE","body":"We have an API client that automatically generates via code in our API repo. This used to work great with babel 6, but something about how babel 7 limits the scope of transpilation is preventing our module-resolver config from being picked up.\r\n\r\nWe attempt to run our generator code from the client codebase, which has a `babel.config.js` with:\r\n\r\n```\r\n[\"module-resolver\",\r\n{\r\n  \"root\": [\r\n    \".\"\r\n  ],\r\n  \"alias\": {\r\n    \"lib\": \"./src/lib\",\r\n    \"generated\": \"./src/generated\",\r\n    \"models\": \"./src/generated/models\",\r\n    \"server-api\": \"../server-api\"\r\n  },\r\n  \"cwd\": \"babelrc\"\r\n}]\r\n```\r\n\r\nThis works ok until it tries to import a file from the server-api which contains its own alias:\r\n`Error: Cannot find module 'server/lib/api_action'`\r\n\r\nHere is the relevant part of .babelrc in server-api:\r\n\r\n```\r\n[\"module-resolver\",\r\n{\r\n  \"root\": [\r\n    \".\"\r\n  ],\r\n  \"alias\": {\r\n    \"server\": \"./\"\r\n  },\r\n  \"cwd\": \"babelrc\"\r\n}]\r\n```\r\n\r\nNOTE: I've tried adding an alias in the client repo, but then it just hits a snag where the `server-api/lib` directory conflicts with the `lib` alias in the client repo. So it's as if babel and/or babel-plugin-module-resolver is thinking all imports are relative to the original repo only."},"comment":{"url":"https://api.github.com/repos/tleunen/babel-plugin-module-resolver/issues/comments/464194924","html_url":"https://github.com/tleunen/babel-plugin-module-resolver/issues/352#issuecomment-464194924","issue_url":"https://api.github.com/repos/tleunen/babel-plugin-module-resolver/issues/352","id":464194924,"node_id":"MDEyOklzc3VlQ29tbWVudDQ2NDE5NDkyNA==","user":{"login":"kybishop","id":679465,"node_id":"MDQ6VXNlcjY3OTQ2NQ==","avatar_url":"https://avatars0.githubusercontent.com/u/679465?v=4","gravatar_id":"","url":"https://api.github.com/users/kybishop","html_url":"https://github.com/kybishop","followers_url":"https://api.github.com/users/kybishop/followers","following_url":"https://api.github.com/users/kybishop/following{/other_user}","gists_url":"https://api.github.com/users/kybishop/gists{/gist_id}","starred_url":"https://api.github.com/users/kybishop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kybishop/subscriptions","organizations_url":"https://api.github.com/users/kybishop/orgs","repos_url":"https://api.github.com/users/kybishop/repos","events_url":"https://api.github.com/users/kybishop/events{/privacy}","received_events_url":"https://api.github.com/users/kybishop/received_events","type":"User","site_admin":false},"created_at":"2019-02-15T20:52:14Z","updated_at":"2019-02-15T20:52:14Z","author_association":"NONE","body":"This turned out to be a babel 7 issue. Babel 7 no longer automatically uses a different project's .babelrc unless you explicitly tell it to do so.\r\n\r\nTo fix this, add `babelrcRoots: [ '.', 'relative/path/to/your/other/project']` to your babel.config.js in the project where you are executing babel. Note that `babelrcRoots` does _not_ work in a `.babelrc` file, so you'll need to convert it to a babel.config.js file."}}
{"actor":{"display_login":"kybishop"}}