Demo of using Angular ^1.5.8, Typescript ^2.0.0 and JSPM
- Angular Components
- Modular component-based architecture
- Predicatable one-way data flow
- 100% of the time, Angular
component's simpler API compared to Angulardirectives, covers your use case 80% of the time
- Typescript
- Use types only when you want to
- Type checking on your own code leads to better scalability in development process for large apps/large teams
- Not just for your code: type checking on 3rd party libraries with
typings
- JSPM
- Automated build process
- Automated dependency management
- Use es2015 modules today
- JSPM
- SystemJs
- Typescript
- Tslint
- Typings
- Definitely Typed: Old typings repository
- Angular 1.5 Component
- Component Lifecycle Hooks
- Node and npm (go download it from the web or using your favorite package manager)
- VS Code (to get development experience outlined in this README)
- Tooling (from command line)
- jspm CLI (
npm i -g jspm) - TypeScript CLI (
npm i -g typescript) - Typings CLI (
npm i -g typings) - TSLint (
npm i -g tslint) jspm registry config github- use Github personal access tokens (read docs on registry configuration here)
- jspm CLI (
- clone repository (
git clone https://github.com/sgwatgit/angular15-typescript-jspm.git) cd angular15-typescript-jspm- Run
npm installafterward to restore all the neccessary dependencies.- This will also run
jspm installandtypings installwhich will add client site dependencies and non-typescript library type support
- This will also run
- TSLint VSCode extension
/.vscode/contains VS Code project configuration (hides/node_modules/and/jspm_packages/)
/jspm_packages/client site application module dependencies (hidden in VS Code)
/node_modules/development cycle module dependencies (hidden in VS Code)
/app/main application files including entrypoint (main.ts) and angular component files (user-form.component.ts)
/typings/Typescript definition files for non-Typescript libraries
config.jsSystemJs module loading configuration file managed byJSPM(contains dependencies at exact versions in the app)
index.htmlpage in which the application runs
package.jsonNode module dependency list, project configuration (also includesJSPMpackage dependencies and defines valid Semver range)
tsconfig.jsonTypescript compilation configuration for project
tslint.jsonTslint configuration for project Typescript linting
typings.jsonReferences to locations and versions of Typescript typings files
npm run unbundle(if previously bundled)npm start- This will launch the application running on a local server with
browser-syncsupport
- This will launch the application running on a local server with
npm run bundleornpm run bundle:prod- NOTE: Once bundled is created and injected, the app will be served from the generated
build.jsand therefore will break live-reloading while in development mode. To re-enable live-reloading for script, runnpm run unbundleornpm startto remove the bundling and rebundle again once you are ready for deployment.
- NOTE: Once bundled is created and injected, the app will be served from the generated
- Copy
build.jsto server and add script tag. Ensure<user-list></user-list>tag exists on page to give angular component a hook.
- Update
package.jsonscriptsnpm run bundleandnpm run bundle:prodtojspm bundleinstead ofjspm bundle-sfx. This will produce a bundle which is not self-executing and will need to be imported into your page manually. It also does not include the module dependencies or the module loader so they will need to be added. - Copy
config.js,build.jsandjspm_packages/system.jsto your server and add the following script tags- Note: If you need to support IE11 you will also need to deploy
jspm_packages/system-polyfills.jsbut it does not need a<script>tag sincesystem.jswill pull it in automatically if needed.
- Note: If you need to support IE11 you will also need to deploy
<script src="/system.js"></script>
<script src="/config.js"></script>
<script src="/build.js"></script>
<script>
System.import("app")
.catch(function(err) {
console.error(err);
});
</script>MIT