2
votes

I am working on an Ember application and would like to create an ember addon for it. The use case for the addon would be to create an ontology tree for the consuming application. The repository for the module I would like to make into an addon is inspire tree and I am needing to wrap this module.

Here is the Inspire Tree Repository.

I am aware of the general structure of Ember addons and an idea on how to make one, but if anyone can give advice on best practices & how to wrap npm modules as addons in general would be very helpful.

2
Why do you want to wrap it at all? Why not use it directly? And IMHO you should never use a third party JS-tree if you're using ember. Its so easy to make a tree with ember itself! Why would you consider to use other JS? The code you write for integration is probably more then you need in ember to do it all.Lux
There are a lot of features of inspire-tree that are appealing to the app we are creating. Would it be better in your opinion to re-create them with just ember vs. incorporating inspire-tree?Alex Virdee
I cant think of a single reason why you would need an external JS library to build a tree with ember. so yeah, you probably don't need it.Lux
There is a blog post about wrapping jsTree as an Ember addon and an emberjs.com discussion about it. You could take a look at the ember-cli-jstree GitHub repo.Thomas Taylor

2 Answers

3
votes

Instead of wrapping the npm module, give https://github.com/ef4/ember-auto-import a try in your app and use via import InspireTree from 'inspire-tree'; once you've installed that module via npm.

2
votes

I think the steps to creating a good addon that wraps an external library follows these steps (I’ll use ember-moment as a good use case):*

  1. Do you need more than just the methods/objects from the underlying library? If not, just import the library.

  2. Does the library provide relatively stateless Ui components? If so, start making ember components! A good example of this is something like ember moment {{moment-format date}}. No matter what you’re doing, you’re always going to get the same result out. Other examples: number formats, link sharing, font-awesome.

  3. Does this library depend on a bunch of application specific business logic? If so, if you make it an addon, it may not be worth the overhead in maintence.

Take what I say with a grain of salt, because I maintain 0 addons.

*note: I have no idea whatsoever what this library you’re referencing is, nor did I look it up, but these are the best practices.