Comparing version 2.0.22 to 2.0.23
@@ -8,3 +8,3 @@ import type { Logger } from '@radrat-node/logger'; | ||
/** | ||
* Flags that should be used during compilation. Default: --downlevelIteration --emitDecoratorMetadata --experimentalDecorators --module commonjs --resolveJsonModule --skipLibCheck --target es2015 | ||
* Flags that should be used during compilation. --rootDir / and --outDir are required. | ||
*/ | ||
@@ -11,0 +11,0 @@ flags?: string[]; |
@@ -49,6 +49,6 @@ "use strict"; | ||
if (!this.getFlag("rootDir")) { | ||
throw new Error("Flag --rootDir is required."); | ||
this.options.flags.push("--rootDir /"); | ||
} | ||
if (!this.getFlag("outDir")) { | ||
throw new Error("Flag --outDir is required."); | ||
this.options.flags.push("--outDir '" + path.resolve(__dirname, "../cache") + "'"); | ||
} | ||
@@ -185,4 +185,2 @@ } | ||
flags: [ | ||
"--rootDir /", | ||
"--outDir '" + path.resolve(__dirname, "../cache") + "'", | ||
"--downlevelIteration", | ||
@@ -189,0 +187,0 @@ "--emitDecoratorMetadata", |
{ | ||
"name": "ts-import", | ||
"version": "2.0.22", | ||
"version": "2.0.23", | ||
"description": "Import (compile and cache on the fly) TypeScript files dynamically with ease.", | ||
@@ -31,3 +31,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "ac8a232860623ba0b5866150adfaf50c33733407" | ||
"gitHead": "1ca2979e97621b965ba32f2d3454721e5f02338e" | ||
} |
@@ -20,6 +20,8 @@ <p align="center"> | ||
### Simple | ||
```ts | ||
import { tsImport } from 'ts-import'; | ||
const bootstrap = async () => { | ||
const main = async () => { | ||
const filePath = `/home/user/file.ts`; | ||
@@ -29,5 +31,43 @@ const compiled = await tsImport.compile(filePath); | ||
bootstrap(); | ||
void main(); | ||
``` | ||
### Advanced | ||
```ts | ||
import { Compiler } from 'ts-import'; | ||
const main = async () => { | ||
const filePath = `/home/user/workspace/project/src/file.ts`; | ||
const compiler = new Compiler({ | ||
// Below are default values that compiler works with. | ||
/** | ||
* Flags that should be used during compilation. ts-import will add rootDir and outDir if they are not specified. If you use --project tsconfig.json flag, your rootDir and outDir flags will be overriden by ts-import unless you specify them here. | ||
*/ | ||
flags: [ | ||
`--downlevelIteration`, | ||
`--emitDecoratorMetadata`, | ||
`--experimentalDecorators`, | ||
`--module commonjs`, | ||
`--resolveJsonModule`, | ||
`--skipLibCheck`, | ||
`--target es2015`, | ||
], | ||
/** | ||
* If TypeScript compilation fails but there is cached file, should it be loaded? Default: false | ||
*/ | ||
fallback: false, | ||
/** | ||
* Logger that will be used by compiler. Requires error, warn, info and debug functions. Default: undefined | ||
*/ | ||
logger: undefined, | ||
}); | ||
}; | ||
void main(); | ||
``` | ||
## Features | ||
@@ -34,0 +74,0 @@ |
24231
79
373