Search code examples
javascriptnode.jsnpmpackageaurelia

Publish Aurelia component on NPM?


We have built a small-ish application using Aurelia, and would like to be able to integrate the app into a larger codebase. For example, it may be desirable to publish the Aurelia app on NPM, so other projects could integrate our code.

How can we build/publish the Aurelia app, so that it can be instantiated in a larger JavaScript application?


Solution

  • Typically, you wouldn't publish an entire Aurelia application to NPM, rather you would push plugins to NPM.

    The simplest way to learn how to do this is to follow the example of the various Aurelia repos. We build the code in to multiple formats, but the most important are AMD and CommonJS (which is more important for your company is dependent on what tooling your company is using). Once you've built the code, the next step is to make sure your package.json file is set up correctly. It's best to copy the example of what we're doing in our own repos.

    I would start by looking at either the dialog plugin or the templating-resources plugin. Both of these show good examples of how to publish your Aurelia plugin to NPM, whether it is a public or private npm feed.

    https://github.com/aurelia/dialog/blob/master/package.json https://github.com/aurelia/templating-resources/blob/master/package.json

    Both of these plugins are set up to support Webpack, JSPM/SystemJS, and the Aurelia CLI out of the box.