Comparing version 3.0.0-beta.4 to 4.0.0-beta.0
@@ -1,19 +0,7 @@ | ||
import * as tsc from 'typescript'; | ||
export interface LoadOptions { | ||
compilerOptions: tsc.CompilerOptions; | ||
} | ||
export declare let defaultLoadOptions: { | ||
compilerOptions: { | ||
outDir: string; | ||
downlevelIteration: boolean; | ||
emitDecoratorMetadata: boolean; | ||
experimentalDecorators: boolean; | ||
module: tsc.ModuleKind; | ||
resolveJsonModule: boolean; | ||
rootDir: string; | ||
skipLibCheck: boolean; | ||
target: tsc.ScriptTarget; | ||
}; | ||
import { LoadMode, LoadOptions } from './load.interfaces'; | ||
export declare const defaultLoadOptions: { | ||
mode: LoadMode; | ||
}; | ||
export declare const load: (tsRelativePath: string, options?: Partial<LoadOptions>) => Promise<any>; | ||
export declare const loadSync: (tsRelativePath: string, options?: Partial<LoadOptions>) => any; | ||
export * from './load.interfaces'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.loadSync = exports.load = exports.defaultLoadOptions = void 0; | ||
const compiler = require("./modules/compiler"); | ||
const tslib_1 = require("tslib"); | ||
const crossPlatform = require("./modules/cross-platform"); | ||
const path = require("path"); | ||
const tsc = require("typescript"); | ||
const utils = require("./utils"); | ||
const load_interfaces_1 = require("./load.interfaces"); | ||
const options_defaults_1 = require("options-defaults"); | ||
const providers_1 = require("./providers/providers"); | ||
exports.defaultLoadOptions = { | ||
compilerOptions: { | ||
outDir: path.resolve(__dirname, `..`, `cache`), | ||
downlevelIteration: true, | ||
emitDecoratorMetadata: true, | ||
experimentalDecorators: true, | ||
module: tsc.ModuleKind.CommonJS, | ||
resolveJsonModule: true, | ||
rootDir: `/`, | ||
skipLibCheck: true, | ||
target: tsc.ScriptTarget.ES2015, | ||
}, | ||
mode: load_interfaces_1.LoadMode.Transpile, | ||
}; | ||
const load = async (tsRelativePath, options) => { | ||
const config = (0, options_defaults_1.defaults)(exports.defaultLoadOptions, options); | ||
const loadConfig = (0, options_defaults_1.defaults)(exports.defaultLoadOptions, options); | ||
const providers = providers_1.providersMap[loadConfig.mode]; | ||
const config = providers.getConfig(loadConfig); | ||
const cwd = process.cwd(); | ||
const cacheDir = config.compilerOptions.outDir; | ||
const cacheDir = providers.getCacheDir(config); | ||
const tsPath = path.resolve(cwd, tsRelativePath); | ||
@@ -39,6 +32,4 @@ let jsAfterCachePath = crossPlatform.getJsAfterCachePath(tsPath); | ||
} | ||
compiler.compile({ | ||
tsPath, | ||
compilerOptions: config.compilerOptions, | ||
}); | ||
await providers.load(Object.assign({ tsPath, | ||
jsPath }, config)); | ||
const loaded = await Promise.resolve().then(() => require(jsPath)); | ||
@@ -49,5 +40,7 @@ return loaded; | ||
const loadSync = (tsRelativePath, options) => { | ||
const config = (0, options_defaults_1.defaults)(exports.defaultLoadOptions, options); | ||
const loadConfig = (0, options_defaults_1.defaults)(exports.defaultLoadOptions, options); | ||
const providers = providers_1.providersMap[loadConfig.mode]; | ||
const config = providers.getConfig(loadConfig); | ||
const cwd = process.cwd(); | ||
const cacheDir = config.compilerOptions.outDir; | ||
const cacheDir = providers.getCacheDir(config); | ||
const tsPath = path.resolve(cwd, tsRelativePath); | ||
@@ -67,6 +60,4 @@ let jsAfterCachePath = crossPlatform.getJsAfterCachePath(tsPath); | ||
} | ||
compiler.compile({ | ||
tsPath, | ||
compilerOptions: config.compilerOptions, | ||
}); | ||
providers.loadSync(Object.assign({ tsPath, | ||
jsPath }, config)); | ||
const loaded = require(jsPath); | ||
@@ -76,2 +67,3 @@ return loaded; | ||
exports.loadSync = loadSync; | ||
tslib_1.__exportStar(require("./load.interfaces"), exports); | ||
//# sourceMappingURL=main.js.map |
export * from './compile'; | ||
export * from './transpile'; |
@@ -5,2 +5,3 @@ "use strict"; | ||
tslib_1.__exportStar(require("./compile"), exports); | ||
tslib_1.__exportStar(require("./transpile"), exports); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "ts-import", | ||
"version": "3.0.0-beta.4", | ||
"version": "4.0.0-beta.0", | ||
"description": "Import (compile and cache on the fly) TypeScript files dynamically with ease.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
56241
72
365
7
1