Skip to content

Commit

Permalink
docs: improve documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
TylorS committed Sep 11, 2017
1 parent d0429ca commit ae0df89
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ import * as fs from 'fs'

const filePath = './src/bootstrap.ts'

fs.writeFileSync(filePath, compile(filePath))
const { code, sourceMap } = compile(filePath)

fs.writeFileSync(filePath, code)
fs.wrtieFileSync(`${filePath}.map`, sourceMap)
```

</details>
11 changes: 8 additions & 3 deletions src/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ const { options } = ts.convertCompilerOptionsFromJson(
)

/**
* Takes the entry file to your Motorcycle run function away using
* type information from the TypeScript compiler.
* Takes the entry file to your Motorcycle application and compiles the
* dynamic `run` function call into an imperative equivalent to improve
* performance and ensure certain classes of bugs do not occur using type
* information from the TypeScript compiler.
*
* @name compile(filePath: string): string
* @example
Expand All @@ -37,7 +39,10 @@ const { options } = ts.convertCompilerOptionsFromJson(
*
* const filePath = './src/bootstrap.ts'
*
* fs.writeFileSync(filePath, compile(filePath))
* const { code, sourceMap } = compile(filePath)
*
* fs.writeFileSync(filePath, code)
* fs.wrtieFileSync(`${filePath}.map`, sourceMap)
*/
export function compile(filePath: string): { code: string; sourceMap: string } {
const program = ts.createProgram([filePath], options)
Expand Down

0 comments on commit ae0df89

Please sign in to comment.