#Typescript Training
Demonstration of how to use stealjs
to load AMD modules written in Typescript and other external library (jquery
, riotjs
and RiotControl
)
$ npm install
$ bower install
$ npm run build or npm run watch
$ npm start //will open your browser, then you have to navigate to the 'app' folder
##Why not commonjs?
I want to use the module loader on a front-end application (not a nodejs
application) so the AMD is more suitable than commonjs (see also Why AMD)
##Project structure
npm run build
will compileapp/*.ts
into thegen
folder (seetsconfig.json
)
-
The compiler is configured to produce AMD module
"compilerOptions": { "module": "amd", ... }
-
in the
index.html
, thestealjs
load themain.js
##Remark
- this example load an internal (hand-made) module (
Model.js
) and some external library (riot, RiotControl, jquery) - each module is used in several different modules but they are loaded only once.
See also: Type script module basic example