angular2-aspnet v0.0.6
If you just want to use this package, then you don't have to build it. Instead, just grab the prebuilt package from NPM:
npm install angular2-aspnetThe rest of this file is notes for anyone contributing to this package itself.
## How to build
Run the following:
npm install
npm run prepublishRequirements:
- Node, NPM
tscinstalled globally (vianpm install -g typescript)
Project structure
This package is intended to be consumable both on the server in Node.js, and on the client. Also, it's written in TypeScript, which neither of those environments knows natively, but the TypeScript type definitions need to get delivered with the package so that developers get a good IDE experience when consuming it.
The build process is therefore:
Compile the TypeScript to produce the development-time (.d.ts) and server-side (.js) artifacts
tscreadstsconfig.jsonand is instructed to compile all the.tsfiles insrc/. It produces a corresponding structure of.jsand.d.tsfiles indist/.When a developer consumes the resulting package (via
npm install angular2-aspnet),- No additional copy of
angular2will be installed, because this package's dependency on it is declared as apeerDependency. This means it will work with whatever (compatible) version ofangular2is already installed. - At runtime inside Node.js, the
mainconfiguration inpackage.jsonmeans the developer can use a standardimportstatement to consume this package (i.e.,import * from 'angular2-aspnet';in either JS or TS files). - At development time inside an IDE such as Visual Studio Code, the
typingsconfiguration inpackage.jsonmeans the IDE will use the corresponding.d.tsfile as type metadata for the variable imported that way.
- No additional copy of
Use the SystemJS builder to produce the client-side artifacts
build.jsuses the SystemJS Builder API to combine files indist/into.jsfiles ready for use in client-side SystemJS environments, and puts them inbundles/. The bundle files containSystem.registercalls so that any other part of your client-side code that tries to importangular2-aspnetvia SystemJS will get that module at runtime.To make it work in an application:
- Set up some build step that copies your chosen bundle file from
bundles/to some location where it will be served to the client - Below your
<script>tag that loads SystemJS itself, and above the<script>tag that makes the first call toSystem.import, have a<script>tag that loads the desiredangular2-aspnet.jsbundle file
For an example, see https://github.com/aspnet/NodeServices/tree/master/samples/angular/MusicStore
Of course, you can also bundle the
angular2-aspnet.jsfile into a larger SystemJS bundle if you want to combine it with the rest of the code in your application.- Set up some build step that copies your chosen bundle file from
Currently, this build system does not attempt to send sourcemaps of the original TypeScript to the client. This could be added if a strong need emerges.