0

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?

Brylie Christopher Oxley
  • 1,684
  • 1
  • 17
  • 34

2 Answers2

0

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.

Ashley Grant
  • 10,879
  • 24
  • 36
0

I totally agree with @Ashley in not publishing larger applications to the global NPM registry. The big advantage of it is the simplicity of all that small packages which can be used to build large applications.

If you feel you got some reusable code, put in an own package and publish it.

Anyway, to give you an answer which does not require you to publish your complete app: you can include a complete repository (which is probobly what you are lookig for) in a different application via NPM.

npm install git://github.com/somegit/hubrepo.git

Or directly via the package.json:

"dependencies": {
    "private-repo": "git+ssh://git@github.com:somegit/hubrepo.git#v1.0.0",
}

You can also do something similiar e.g. using JSPM. This would be simply:

jspm install your-app=github:OrgOrUser/your-app@your-branch

If you are facing long relative paths in your imports now, depending on your tooling, you may be interested in something like e.g. Resolving require paths with webpack which shows how to alias relative paths.

Sources/Links:

How to install a private NPM module without my own registry?

npm install private github repositories by dependency in package.json

Marc Scheib
  • 1,963
  • 1
  • 24
  • 29