Creating helpers packages for core functionality - best practices?


Is there a best practice for creating helper modules for shared code between packages, when this code directly uses atom’s api?

Such a module should be an npm package instead of an atom package, since it provides no user interface and atom packages lack dependens-on-other-atom-package support (?).
The easiest way to develop such a module I can think of, is to be to create an atom package which requires it. Which seems rather hacky to me. Also, how would one set up the unit tests? Wrapping it in an atom package for running the specs would - again - be hacky.

As a concrete example, imagine a module providing helper functions for opening files and maintaining a connection to another file, e.g. a source file and the compiled version. This helper could be used by all the preview packages available for different file types.


Check out the documentation on providing and consuming services. This is how Atom allows packages to depend on other packages.


I think you should definitely use a npm module. For the moment there’s no mechanism to install another Atom package from an other one so you will have to warn your user about manually installing the dependencies.

If you want to test your helpers library just follow the Atom convention (a spec folder) and you’ll be able to run your library specs with apm test and within Atom. And to enable CI builds you can just do the same as for an Atom package (see my own helpers library if you want a working example).