feat(examples): improve browser usage example
This commit is contained in:
@@ -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": {
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
<html><body>
|
||||
<script src="test.js" />
|
||||
</body></html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<script src="test.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
@@ -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) )
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
"extends": "../../tsconfig",
|
||||
"compilerOptions": {
|
||||
"outDir": "build",
|
||||
"module": "ES6",
|
||||
"module": "es6",
|
||||
"declaration": false,
|
||||
"removeComments": true
|
||||
"removeComments": true,
|
||||
"lib": [
|
||||
"dom"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"src/*.ts"
|
||||
|
||||
Reference in New Issue
Block a user