Comparing version 4.0.0-beta.5 to 4.0.0-beta.6
@@ -7,3 +7,3 @@ import { LoadMode, LoadOptions } from './load.interfaces'; | ||
export declare const load: (tsRelativePath: string, options?: LoadOptions) => Promise<any>; | ||
export declare const loadSync: (tsRelativePath: string, options?: LoadOptions) => Promise<any>; | ||
export declare const loadSync: (tsRelativePath: string, options?: LoadOptions) => any; | ||
export * from './load.interfaces'; |
@@ -44,5 +44,5 @@ "use strict"; | ||
exports.load = load; | ||
const loadSync = async (tsRelativePath, options) => { | ||
const loadSync = (tsRelativePath, options) => { | ||
if (options === null || options === void 0 ? void 0 : options.allowConfigurationWithComments) { | ||
const commentConfig = await commentParser.getTsImportCommentConfig(tsRelativePath); | ||
const commentConfig = commentParser.getTsImportCommentConfigSync(tsRelativePath); | ||
options = (0, options_defaults_1.defaults)(options, commentConfig); | ||
@@ -49,0 +49,0 @@ } |
{ | ||
"name": "ts-import", | ||
"version": "4.0.0-beta.5", | ||
"version": "4.0.0-beta.6", | ||
"description": "Import (compile and cache on the fly) TypeScript files dynamically with ease.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -25,3 +25,5 @@ <p align="center"> | ||
const filePath = `/home/user/file.ts`; | ||
const asyncResult = await tsImport.load(filePath); | ||
const asyncResult = await tsImport.load(filePath, { | ||
// allowConfigurationWithComments: false, | ||
}); | ||
const syncResult = tsImport.loadSync(filePath); | ||
@@ -33,2 +35,20 @@ }; | ||
### allowConfigurationWithComments | ||
You can define if file should be imported in the default `transpile` mode or `compile` mode by placing a comment on top of the specific file. | ||
Compile mode is slower, but allows the specified file to be part of a complex program - it can import other files etc. | ||
```ts | ||
/** | ||
* @tsImport | ||
* { "mode": "compile" } | ||
*/ | ||
import { getOtherVariable } from './get-other-variable'; | ||
const result = getOtherVariable(); | ||
export { result }; | ||
``` | ||
## Features | ||
@@ -35,0 +55,0 @@ |
@@ -6,3 +6,5 @@ ```ts | ||
const filePath = `/home/user/file.ts`; | ||
const asyncResult = await tsImport.load(filePath); | ||
const asyncResult = await tsImport.load(filePath, { | ||
// allowConfigurationWithComments: false, | ||
}); | ||
const syncResult = tsImport.loadSync(filePath); | ||
@@ -13,1 +15,19 @@ }; | ||
``` | ||
### allowConfigurationWithComments | ||
You can define if file should be imported in the default `transpile` mode or `compile` mode by placing a comment on top of the specific file. | ||
Compile mode is slower, but allows the specified file to be part of a complex program - it can import other files etc. | ||
```ts | ||
/** | ||
* @tsImport | ||
* { "mode": "compile" } | ||
*/ | ||
import { getOtherVariable } from './get-other-variable'; | ||
const result = getOtherVariable(); | ||
export { result }; | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
66363
60