1
0
mirror of synced 2025-11-08 12:57:47 +00:00

feat(examples): improve browser usage example

This commit is contained in:
Jason Dreyzehner
2017-02-12 16:15:08 -05:00
parent 5f18048ab7
commit c8199e72ce
6 changed files with 70 additions and 18 deletions

View File

@@ -3,7 +3,7 @@
"version": "1.0.0",
"license": "MIT",
"scripts": {
"start": "http-server ./build/ -o",
"start": "http-server -c-1 ./build/ -o",
"build": "rollup -c && cpy src/index.html build/"
},
"devDependencies": {

View File

@@ -1,3 +1,10 @@
<html><body>
<script src="test.js" />
</body></html>
<html>
<head>
<script src="test.js"></script>
</head>
<body>
</body>
</html>

View File

@@ -1,10 +1,24 @@
// Note: we're not using the double method, so it should be excluded from the bundle
import { power, asyncABC } from '../../../'
if (power(3,4) === 81) {
console.log('✔ power(3,4) === 81')
} else {
console.error('The "power" method seems to be broken.')
let output = ''
function log(str: string) {
console.log(str)
output += str + '\n'
}
asyncABC().then( abc => console.log('✔ asyncABC returned:', abc) )
function logAndAlert(data: string[]) {
log('✔ asyncABC returned: ' + data)
window.alert(output)
}
log('Output:')
if (power(3,4) === 81) {
log('✔ power(3,4) === 81')
} else {
log('The "power" method seems to be broken.')
}
asyncABC().then( abc => logAndAlert(abc) )

View File

@@ -2,9 +2,12 @@
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "build",
"module": "ES6",
"module": "es6",
"declaration": false,
"removeComments": true
"removeComments": true,
"lib": [
"dom"
]
},
"include": [
"src/*.ts"