{"action":"created","issue":{"url":"https://api.github.com/repos/Galooshi/import-js/issues/483","repository_url":"https://api.github.com/repos/Galooshi/import-js","labels_url":"https://api.github.com/repos/Galooshi/import-js/issues/483/labels{/name}","comments_url":"https://api.github.com/repos/Galooshi/import-js/issues/483/comments","events_url":"https://api.github.com/repos/Galooshi/import-js/issues/483/events","html_url":"https://github.com/Galooshi/import-js/issues/483","id":301158562,"number":483,"title":"Ember support?","user":{"login":"justincampbell","id":246978,"avatar_url":"https://avatars3.githubusercontent.com/u/246978?v=4","gravatar_id":"","url":"https://api.github.com/users/justincampbell","html_url":"https://github.com/justincampbell","followers_url":"https://api.github.com/users/justincampbell/followers","following_url":"https://api.github.com/users/justincampbell/following{/other_user}","gists_url":"https://api.github.com/users/justincampbell/gists{/gist_id}","starred_url":"https://api.github.com/users/justincampbell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justincampbell/subscriptions","organizations_url":"https://api.github.com/users/justincampbell/orgs","repos_url":"https://api.github.com/users/justincampbell/repos","events_url":"https://api.github.com/users/justincampbell/events{/privacy}","received_events_url":"https://api.github.com/users/justincampbell/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2018-02-28T19:48:56Z","updated_at":"2018-02-28T22:21:04Z","closed_at":null,"author_association":"NONE","body":"How can I use this with Ember? Given a new Ember project (`ember new ember-new`), I have this file in `app/models/test.js`:\r\n\r\n```js\r\nimport { alias } from \"@ember/object/computed\";\r\nimport { computed } from \"@ember/object\";\r\nimport { inject as service } from \"@ember/service\";\r\nimport DS from \"ember-data\";\r\n\r\nconst { attr, Model } = DS;\r\n\r\nexport default Model.extend({\r\n  store: service(),\r\n\r\n  name: attr(),\r\n\r\n  alternateName: computed.alias(\"name\"),\r\n  anotherAlias: alias(\"name\")\r\n});\r\n```\r\n\r\n(contrived, but you get the idea)\r\n\r\nAll of the dependencies seem to be in `devDependencies`, so I added `importDevDependencies: true` to the config file.\r\n\r\nRemoving the imports at the top of this example, none of them are added back in by `importjs fix app/models/test.js`. Should this be working? I dug around node_modules and noticed most of `@ember/...` is defined in an `ember-source` package.\r\n\r\nIf I add `namedExports` to the config file, such as below, these specific imports work perfectly, but I noticed it's deprecated since 2.1.0, and this also doesn't seem to solve non-named imports:\r\n\r\n```js\r\n{\r\n  namedExports: {\r\n    \"@ember/object/computed\": [\"alias\"], // etc\r\n    \"@ember/object\": [\"computed\", \"observer\"],\r\n  }\r\n}\r\n```\r\n\r\nI don't mind manually creating a config file which would make this work for Ember (there's only ~10-20 things I need to import day-to-day), but I can't figure out how to write the config file to achieve that. Do I need something special in `aliases` for this to work?\r\n\r\nThanks in advance!"},"comment":{"url":"https://api.github.com/repos/Galooshi/import-js/issues/comments/369403771","html_url":"https://github.com/Galooshi/import-js/issues/483#issuecomment-369403771","issue_url":"https://api.github.com/repos/Galooshi/import-js/issues/483","id":369403771,"user":{"login":"trotzig","id":578277,"avatar_url":"https://avatars2.githubusercontent.com/u/578277?v=4","gravatar_id":"","url":"https://api.github.com/users/trotzig","html_url":"https://github.com/trotzig","followers_url":"https://api.github.com/users/trotzig/followers","following_url":"https://api.github.com/users/trotzig/following{/other_user}","gists_url":"https://api.github.com/users/trotzig/gists{/gist_id}","starred_url":"https://api.github.com/users/trotzig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trotzig/subscriptions","organizations_url":"https://api.github.com/users/trotzig/orgs","repos_url":"https://api.github.com/users/trotzig/repos","events_url":"https://api.github.com/users/trotzig/events{/privacy}","received_events_url":"https://api.github.com/users/trotzig/received_events","type":"User","site_admin":false},"created_at":"2018-02-28T22:21:04Z","updated_at":"2018-02-28T22:21:04Z","author_association":"COLLABORATOR","body":"Okay, it's getting late here and I'm not having much success with my attempt at finding ember exports automatically. The idea I had was to use the [`findExports`](https://github.com/Galooshi/import-js/blob/master/lib/findExports.js) function from import-js to automatically create the lists you had in your gist. As long as we know the paths to the files exporting those variables, we can theoretically auto-find them inside .importjs.js. Something like \r\n\r\n```js\r\nconst fs = require('fs');\r\nconst findExports = require('import-js/build/findExports');\r\n\r\nconst path = require.resolve('@ember/object');\r\nconst exports = findExports(fs.readFileSync(path), path);\r\n\r\n// do something with exports\r\n```"}}
{"actor":{"display_login":"trotzig"}}