-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
68 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,60 @@ | ||
This will bundle a simple typescript app with third party dependencies into a single javascript library for browsers (ie, can be consumed by a script tag). | ||
## README | ||
|
||
This is an example of a typescript app that is compiled down to a single js file for consumption in a browser. | ||
|
||
## Technologies used | ||
* typescript | ||
* karma | ||
* jasmine | ||
* rollup (for bundling) | ||
|
||
|
||
## How to use | ||
|
||
`npm install` | ||
`npm install` // installs | ||
|
||
`npm run build` | ||
`npm run build` // bundles | ||
|
||
Output will be created in `dist/bundle.js` | ||
|
||
Load `test/index.html` in browser and check console logs. | ||
Load `test/index.html` in browser. | ||
|
||
All exported classes are available under the namespace specified in | ||
rollup.config.js -> output.name value (MyNamespace here) | ||
|
||
## Unit testing | ||
|
||
### Prerequisit | ||
|
||
Chrome installed on machine | ||
|
||
### Running | ||
|
||
`./node_modules/karma/bin/karma start` | ||
|
||
Runs tests without debugging. | ||
Uses ChromeHeadless (ie, no browser will open). | ||
|
||
### Debugging | ||
|
||
Step 1 | ||
`./node_modules/karma/bin/karma start --no-single-run --browser=Chrome` | ||
|
||
Step 2 | ||
Click "Debug" button | ||
|
||
Step 3 | ||
Inspect page, go to sources, open up base/src and find ts files of interest (greeter.spec.ts and greeter.ts). | ||
|
||
Step 4 | ||
Set breakpoints in browser and refresh page | ||
|
||
|
||
## Helpful Hints | ||
|
||
May wish to install karma and karma-cli globally: | ||
|
||
`npm install karma karma-cli -g` | ||
|
||
Then you can run using: | ||
`karma start` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
import { Greeter } from "./greeter"; | ||
|
||
let greeter = new Greeter(); | ||
export class Test { | ||
greeter: Greeter; | ||
|
||
greeter.greet(); | ||
constructor() { | ||
this.greeter = new Greeter(); | ||
|
||
this.greeter.greet(); | ||
} | ||
|
||
callme() { | ||
console.log(this.greeter.returnSomething(1.2)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="../dist/bundle.js"></script> | ||
|