Comparing version 2.0.29 to 2.0.30
@@ -47,2 +47,8 @@ "use strict"; | ||
function Compiler(options) { | ||
// Support setting rootDir and outDir on windows from different drives based process.cwd(). | ||
if (process.platform === "win32") { | ||
var driveLetter = process.cwd().charAt(0); | ||
Compiler.defaults.compilerOptions.outDir = path.resolve(Compiler.defaults.compilerOptions.outDir, driveLetter); | ||
Compiler.defaults.compilerOptions.rootDir = driveLetter + ":/"; | ||
} | ||
this.options = options_defaults_1.defaults(Compiler.defaults, options); | ||
@@ -63,3 +69,3 @@ } | ||
} | ||
tsDir = path.dirname(tsPath).replace(/^(?<driveLetter>[a-zA-Z]):/u, "$<driveLetter>"); | ||
tsDir = path.dirname(tsPath); | ||
ctx = { | ||
@@ -77,3 +83,3 @@ cwd: cwd, | ||
return __awaiter(this, void 0, void 0, function () { | ||
var logger, tsPath, tsDir, cwd, tsFileName, jsFileName, cacheDir, jsPath, tsWasModified, buildError; | ||
var logger, tsPath, tsDir, cwd, tsFileName, jsFileName, tsDirWithoutDriveLetter, cacheDir, jsPath, tsWasModified, buildError; | ||
return __generator(this, function (_h) { | ||
@@ -86,3 +92,4 @@ switch (_h.label) { | ||
jsFileName = tsFileName.replace(/\.[^/.]+$/u, ".js"); | ||
cacheDir = path.resolve(this.options.compilerOptions.outDir, "." + tsDir); | ||
tsDirWithoutDriveLetter = tsDir.replace(/^(?<driveLetter>[a-zA-Z]):/u, ""); | ||
cacheDir = path.resolve(this.options.compilerOptions.outDir, "." + tsDirWithoutDriveLetter); | ||
jsPath = path.resolve(cacheDir, jsFileName); | ||
@@ -141,3 +148,3 @@ (_a = logger === null || logger === void 0 ? void 0 : logger.verbose) === null || _a === void 0 ? void 0 : _a.call(logger, "Looking for cached file at " + jsPath); | ||
logger = this.options.logger; | ||
tmpTsConfigPath = path.join(this.options.compilerOptions.outDir, path.dirname(absoluteTsPath), "tsconfig-" + path.basename(absoluteTsPath) + ".tmp.json"); | ||
tmpTsConfigPath = path.join(this.options.compilerOptions.outDir, path.dirname(absoluteTsPath).replace(/^(?<driveLetter>[a-zA-Z]):/u, ""), "tsconfig-" + path.basename(absoluteTsPath) + ".tmp.json"); | ||
return [4 /*yield*/, fs.promises.writeFile(tmpTsConfigPath, JSON.stringify({ | ||
@@ -152,3 +159,3 @@ compilerOptions: this.options.compilerOptions, | ||
var _a, _b; | ||
var compileCommand = "npx -p typescript tsc --project '" + tmpTsConfigPath + "'"; | ||
var compileCommand = "npx -p typescript tsc --project \"" + tmpTsConfigPath + "\""; | ||
(_a = logger === null || logger === void 0 ? void 0 : logger.info) === null || _a === void 0 ? void 0 : _a.call(logger, "Compiling " + absoluteTsPath); | ||
@@ -155,0 +162,0 @@ (_b = logger === null || logger === void 0 ? void 0 : logger.debug) === null || _b === void 0 ? void 0 : _b.call(logger, "Command: " + compileCommand); |
{ | ||
"name": "ts-import", | ||
"version": "2.0.29", | ||
"version": "2.0.30", | ||
"description": "Import (compile and cache on the fly) TypeScript files dynamically with ease.", | ||
@@ -21,6 +21,6 @@ "license": "MIT", | ||
"dependencies": { | ||
"options-defaults": "^2.0.29" | ||
"options-defaults": "^2.0.30" | ||
}, | ||
"devDependencies": { | ||
"@radrat-node/logger": "^2.0.29", | ||
"@radrat-node/logger": "^2.0.30", | ||
"@types/jest": "^26.0.20", | ||
@@ -36,3 +36,3 @@ "@types/node": "^14.14.35", | ||
}, | ||
"gitHead": "f2c0a184d77ce278e7ba3753c34321b95e69974f" | ||
"gitHead": "fa6a80ce57ce1ea71bfb9a352ed9c648fc8dce5c" | ||
} |
29267
407
Updatedoptions-defaults@^2.0.30