80bower
80bower

Reputation: 1161

How can I reference a shared TypeScript module in Angular and a node.js?

I have created a TypeScript module named My.Models that contains several models and I have two applications that need to use this module, neither currently use TypeScript.

The applications are a client-side Angular application and a server-side node.js application.

What is an approach that would enable me to make changes to the My.Models module, and then easily have those changes passed on to the consuming applications?

Upvotes: 0

Views: 404

Answers (1)

Ryan
Ryan

Reputation: 5973

The easiest way is to publish your module to npm. This may require a couple of changes to your angular setup if you aren't already using npm modules in your angular app. We use webpack with Angular which allows you to write and require common js modules(NPM). Browserify is another option for using common js modules. If you don't want to do 100% commonjs/npm then you'd need to publish to npm for your node app and bower for your angular app.

Then you just publish a new release of your shared module after you make your changes and then you can update your Angular app and Node app.

You can use private npm modules or just publish your module to git(How to install a private NPM module without my own registry?)

Upvotes: 1

Related Questions