Ember support?
See original GitHub issueHow can I use this with Ember? Given a new Ember project (ember new ember-new
), I have this file in app/models/test.js
:
import { alias } from "@ember/object/computed";
import { computed } from "@ember/object";
import { inject as service } from "@ember/service";
import DS from "ember-data";
const { attr, Model } = DS;
export default Model.extend({
store: service(),
name: attr(),
alternateName: computed.alias("name"),
anotherAlias: alias("name")
});
(contrived, but you get the idea)
All of the dependencies seem to be in devDependencies
, so I added importDevDependencies: true
to the config file.
Removing 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.
If 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:
{
namedExports: {
"@ember/object/computed": ["alias"], // etc
"@ember/object": ["computed", "observer"],
}
}
I 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?
Thanks in advance!
Issue Analytics
- State:
- Created 6 years ago
- Comments:12
Until we get support for plugins and eventually an Ember plugin, I wrote an
.importjs.js
config file for our ember-cli project which includes all the@ember
modules. You can find in this gist.To extract the modules, I used the data from https://github.com/ember-cli/ember-rfc176-data and the scripts used can be found here: https://github.com/monovertex/ember-rfc176-data/tree/master/scripts (
generate-import-js-aliases.js
,generate-import-js-core-modules.js
,generate-import-js-named-exports.js
).Thank you @justincampbell for the
ember-concurrency
andember-qunit
named exports 👍.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
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