tsconfig-paths
Advanced tools
Comparing version 3.12.0 to 3.13.0
@@ -10,2 +10,8 @@ # Change Log | ||
## [3.13.0] - 2022-03-03 | ||
### Fixed | ||
- Include file extension in paths resolved from package.json "main" field. See PR [#135](https://github.com/dividab/tsconfig-paths/pull/135) and issue [#133](https://github.com/dividab/tsconfig-paths/issues/133). Thanks to [@katywings](https://github.com/katywings) for this fix! | ||
## [3.12.0] - 2021-08-24 | ||
@@ -12,0 +18,0 @@ |
@@ -1,2 +0,2 @@ | ||
import * as TsConfigLoader from "./tsconfig-loader"; | ||
import * as TsConfigLoader2 from "./tsconfig-loader"; | ||
export interface ExplicitParams { | ||
@@ -10,3 +10,3 @@ baseUrl: string; | ||
} | ||
export declare type TsConfigLoader = (params: TsConfigLoader.TsConfigLoaderParams) => TsConfigLoader.TsConfigLoaderResult; | ||
export declare type TsConfigLoader = (params: TsConfigLoader2.TsConfigLoaderParams) => TsConfigLoader2.TsConfigLoaderResult; | ||
export interface ConfigLoaderParams { | ||
@@ -13,0 +13,0 @@ cwd: string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var TsConfigLoader = require("./tsconfig-loader"); | ||
exports.configLoader = exports.loadConfig = void 0; | ||
var TsConfigLoader2 = require("./tsconfig-loader"); | ||
var path = require("path"); | ||
@@ -12,3 +13,3 @@ var options_1 = require("./options"); | ||
function configLoader(_a) { | ||
var cwd = _a.cwd, explicitParams = _a.explicitParams, _b = _a.tsConfigLoader, tsConfigLoader = _b === void 0 ? TsConfigLoader.tsConfigLoader : _b; | ||
var cwd = _a.cwd, explicitParams = _a.explicitParams, _b = _a.tsConfigLoader, tsConfigLoader = _b === void 0 ? TsConfigLoader2.tsConfigLoader : _b; | ||
if (explicitParams) { | ||
@@ -57,1 +58,2 @@ // tslint:disable-next-line:no-shadowed-variable | ||
exports.configLoader = configLoader; | ||
//# sourceMappingURL=config-loader.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.removeExtension = exports.fileExistsAsync = exports.readJsonFromDiskAsync = exports.readJsonFromDiskSync = exports.fileExistsSync = void 0; | ||
var fs = require("fs"); | ||
@@ -54,1 +55,2 @@ function fileExistsSync(path) { | ||
exports.removeExtension = removeExtension; | ||
//# sourceMappingURL=filesystem.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.loadConfig = exports.register = exports.matchFromAbsolutePathsAsync = exports.createMatchPathAsync = exports.matchFromAbsolutePaths = exports.createMatchPath = void 0; | ||
// register is used from register.js in root dir | ||
var match_path_sync_1 = require("./match-path-sync"); | ||
exports.createMatchPath = match_path_sync_1.createMatchPath; | ||
exports.matchFromAbsolutePaths = match_path_sync_1.matchFromAbsolutePaths; | ||
Object.defineProperty(exports, "createMatchPath", { enumerable: true, get: function () { return match_path_sync_1.createMatchPath; } }); | ||
Object.defineProperty(exports, "matchFromAbsolutePaths", { enumerable: true, get: function () { return match_path_sync_1.matchFromAbsolutePaths; } }); | ||
var match_path_async_1 = require("./match-path-async"); | ||
exports.createMatchPathAsync = match_path_async_1.createMatchPathAsync; | ||
exports.matchFromAbsolutePathsAsync = match_path_async_1.matchFromAbsolutePathsAsync; | ||
Object.defineProperty(exports, "createMatchPathAsync", { enumerable: true, get: function () { return match_path_async_1.createMatchPathAsync; } }); | ||
Object.defineProperty(exports, "matchFromAbsolutePathsAsync", { enumerable: true, get: function () { return match_path_async_1.matchFromAbsolutePathsAsync; } }); | ||
var register_1 = require("./register"); | ||
exports.register = register_1.register; | ||
Object.defineProperty(exports, "register", { enumerable: true, get: function () { return register_1.register; } }); | ||
var config_loader_1 = require("./config-loader"); | ||
exports.loadConfig = config_loader_1.loadConfig; | ||
Object.defineProperty(exports, "loadConfig", { enumerable: true, get: function () { return config_loader_1.loadConfig; } }); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getAbsoluteMappingEntries = void 0; | ||
var path = require("path"); | ||
@@ -33,3 +34,3 @@ /** | ||
pattern: "*", | ||
paths: [absoluteBaseUrl.replace(/\/$/, "") + "/*"], | ||
paths: ["".concat(absoluteBaseUrl.replace(/\/$/, ""), "/*")], | ||
}); | ||
@@ -53,1 +54,2 @@ } | ||
} | ||
//# sourceMappingURL=mapping-entry.js.map |
@@ -21,2 +21,2 @@ import * as MappingEntry from "./mapping-entry"; | ||
*/ | ||
export declare function matchFromAbsolutePathsAsync(absolutePathMappings: ReadonlyArray<MappingEntry.MappingEntry>, requestedModule: string, readJson: Filesystem.ReadJsonAsync | undefined, fileExists: Filesystem.FileExistsAsync | undefined, extensions: ReadonlyArray<string> | undefined, callback: MatchPathAsyncCallback, mainFields?: string[]): void; | ||
export declare function matchFromAbsolutePathsAsync(absolutePathMappings: ReadonlyArray<MappingEntry.MappingEntry>, requestedModule: string, readJson: Filesystem.ReadJsonAsync | undefined, fileExists: Filesystem.FileExistsAsync | undefined, extensions: readonly string[] | undefined, callback: MatchPathAsyncCallback, mainFields?: string[]): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.matchFromAbsolutePathsAsync = exports.createMatchPathAsync = void 0; | ||
var path = require("path"); | ||
@@ -71,3 +72,2 @@ var TryPath = require("./try-path"); | ||
if (exists) { | ||
// Not sure why we don't just return the full path? Why strip it? | ||
return doneCallback(undefined, TryPath.getStrippedPath(tryPath)); | ||
@@ -93,4 +93,3 @@ } | ||
if (mainFieldMappedFile) { | ||
// Not sure why we don't just return the full path? Why strip it? | ||
return doneCallback(undefined, Filesystem.removeExtension(mainFieldMappedFile)); | ||
return doneCallback(undefined, mainFieldMappedFile); | ||
} | ||
@@ -116,1 +115,2 @@ // No field in package json was a valid option. Continue with the next path. | ||
} | ||
//# sourceMappingURL=match-path-async.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.matchFromAbsolutePaths = exports.createMatchPath = void 0; | ||
var path = require("path"); | ||
@@ -68,3 +69,2 @@ var Filesystem = require("./filesystem"); | ||
if (fileExists(tryPath.path)) { | ||
// Not sure why we don't just return the full path? Why strip it? | ||
return TryPath.getStrippedPath(tryPath); | ||
@@ -78,4 +78,3 @@ } | ||
if (mainFieldMappedFile) { | ||
// Not sure why we don't just return the full path? Why strip it? | ||
return Filesystem.removeExtension(mainFieldMappedFile); | ||
return mainFieldMappedFile; | ||
} | ||
@@ -90,1 +89,2 @@ } | ||
} | ||
//# sourceMappingURL=match-path-sync.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.options = void 0; | ||
var minimist = require("minimist"); | ||
@@ -14,1 +15,2 @@ var argv = minimist(process.argv.slice(2), { | ||
}; | ||
//# sourceMappingURL=options.js.map |
"use strict"; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.register = void 0; | ||
var match_path_sync_1 = require("./match-path-sync"); | ||
@@ -49,3 +59,3 @@ var config_loader_1 = require("./config-loader"); | ||
function register(explicitParams) { | ||
var configLoaderResult = config_loader_1.configLoader({ | ||
var configLoaderResult = (0, config_loader_1.configLoader)({ | ||
cwd: options_1.options.cwd, | ||
@@ -55,6 +65,6 @@ explicitParams: explicitParams, | ||
if (configLoaderResult.resultType === "failed") { | ||
console.warn(configLoaderResult.message + ". tsconfig-paths will be skipped"); | ||
console.warn("".concat(configLoaderResult.message, ". tsconfig-paths will be skipped")); | ||
return noOp; | ||
} | ||
var matchPath = match_path_sync_1.createMatchPath(configLoaderResult.absoluteBaseUrl, configLoaderResult.paths, configLoaderResult.mainFields, configLoaderResult.addMatchAll); | ||
var matchPath = (0, match_path_sync_1.createMatchPath)(configLoaderResult.absoluteBaseUrl, configLoaderResult.paths, configLoaderResult.mainFields, configLoaderResult.addMatchAll); | ||
// Patch node's module loading | ||
@@ -71,3 +81,3 @@ // tslint:disable-next-line:no-require-imports variable-name | ||
if (found) { | ||
var modifiedArguments = [found].concat([].slice.call(arguments, 1)); // Passes all arguments. Even those that is not specified above. | ||
var modifiedArguments = __spreadArray([found], [].slice.call(arguments, 1), true); // Passes all arguments. Even those that is not specified above. | ||
// tslint:disable-next-line:no-invalid-this | ||
@@ -86,1 +96,2 @@ return originalResolveFilename.apply(this, modifiedArguments); | ||
exports.register = register; | ||
//# sourceMappingURL=register.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.exhaustiveTypeException = exports.getStrippedPath = exports.getPathsToTry = void 0; | ||
var path = require("path"); | ||
@@ -50,7 +51,7 @@ var path_1 = require("path"); | ||
return tryPath.type === "index" | ||
? path_1.dirname(tryPath.path) | ||
? (0, path_1.dirname)(tryPath.path) | ||
: tryPath.type === "file" | ||
? tryPath.path | ||
: tryPath.type === "extension" | ||
? filesystem_1.removeExtension(tryPath.path) | ||
? (0, filesystem_1.removeExtension)(tryPath.path) | ||
: tryPath.type === "package" | ||
@@ -62,3 +63,3 @@ ? tryPath.path | ||
function exhaustiveTypeException(check) { | ||
throw new Error("Unknown type " + check); | ||
throw new Error("Unknown type ".concat(check)); | ||
} | ||
@@ -94,1 +95,2 @@ exports.exhaustiveTypeException = exhaustiveTypeException; | ||
} | ||
//# sourceMappingURL=try-path.js.map |
"use strict"; | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.loadTsconfig = exports.walkForTsConfig = exports.tsConfigLoader = void 0; | ||
var path = require("path"); | ||
@@ -102,3 +106,3 @@ var fs = require("fs"); | ||
} | ||
return __assign({}, base, config, { compilerOptions: __assign({}, base.compilerOptions, config.compilerOptions) }); | ||
return __assign(__assign(__assign({}, base), config), { compilerOptions: __assign(__assign({}, base.compilerOptions), config.compilerOptions) }); | ||
} | ||
@@ -108,1 +112,2 @@ return config; | ||
exports.loadTsconfig = loadTsconfig; | ||
//# sourceMappingURL=tsconfig-loader.js.map |
{ | ||
"name": "tsconfig-paths", | ||
"version": "3.12.0", | ||
"version": "3.13.0", | ||
"description": "Load node modules according to tsconfig paths, in run-time or via API.", | ||
@@ -20,20 +20,16 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@types/chai": "^4.1.4", | ||
"@types/jest": "^27.0.3", | ||
"@types/minimist": "^1.2.0", | ||
"@types/mocha": "^5.2.3", | ||
"@types/node": "^6.0.54", | ||
"@types/strip-bom": "^3.0.0", | ||
"@types/strip-json-comments": "^0.0.30", | ||
"chai": "^4.1.2", | ||
"codecov": "^3.1.0", | ||
"husky": "^4.2.5", | ||
"jest": "^27.3.1", | ||
"lint-staged": "^10.2.11", | ||
"mocha": "^5.2.0", | ||
"nyc": "^11.4.1", | ||
"prettier": "^2.0.5", | ||
"rimraf": "^2.6.2", | ||
"shelljs": "^0.7.5", | ||
"ts-jest": "^27.0.7", | ||
"ts-node": "^7.0.0", | ||
"tslint": "^5.8.0", | ||
"typescript": "^2.4.1" | ||
"typescript": "^4.5.2" | ||
}, | ||
@@ -52,12 +48,7 @@ "dependencies": { | ||
"example:perf": "cd example/perf && ts-node main.ts", | ||
"test": "mocha", | ||
"build": "rimraf lib && tsc -p src", | ||
"build:test": "rimraf ./test/js_out && tsc -p test", | ||
"test": "jest", | ||
"test-coverage": "jest --coverage", | ||
"build": "rimraf lib && tsc -p .", | ||
"lint": "tslint './{src,tests}/**/*.ts{,x}'", | ||
"verify": "yarn build && yarn lint && yarn coverage", | ||
"coverage": "rimraf coverage .nyc_output && nyc yarn test", | ||
"report-coverage": "codecov -f coverage/*.json", | ||
"publish:major": "yarn build && node scripts/publish.js major", | ||
"publish:minor": "yarn build && node scripts/publish.js minor", | ||
"publish:patch": "yarn build && node scripts/publish.js patch", | ||
"verify": "yarn build && yarn lint && yarn test-coverage", | ||
"preversion": "yarn verify", | ||
@@ -64,0 +55,0 @@ "postversion": "git push --tags && yarn publish --new-version $npm_package_version && git push && echo \"Successfully released version $npm_package_version!\"" |
# tsconfig-paths | ||
[![npm version][version-image]][version-url] | ||
[![travis build][travis-image]][travis-url] | ||
[![build][build-image]][build-url] | ||
[![Coverage Status][codecov-image]][codecov-url] | ||
@@ -261,4 +261,4 @@ [![MIT license][license-image]][license-url] | ||
[version-url]: https://www.npmjs.com/package/tsconfig-paths | ||
[travis-image]: https://travis-ci.com/dividab/tsconfig-paths.svg?branch=master&style=flat | ||
[travis-url]: https://travis-ci.com/dividab/tsconfig-paths | ||
[build-image]: https://github.com/dividab/tsconfig-paths/workflows/CI/badge.svg | ||
[build-url]: https://github.com/dividab/tsconfig-paths/actions/workflows/ci.yml?query=branch%3Amaster | ||
[codecov-image]: https://codecov.io/gh/dividab/tsconfig-paths/branch/master/graph/badge.svg | ||
@@ -265,0 +265,0 @@ [codecov-url]: https://codecov.io/gh/dividab/tsconfig-paths |
@@ -1,2 +0,2 @@ | ||
import * as TsConfigLoader from "./tsconfig-loader"; | ||
import * as TsConfigLoader2 from "./tsconfig-loader"; | ||
import * as path from "path"; | ||
@@ -13,4 +13,4 @@ import { options } from "./options"; | ||
export type TsConfigLoader = ( | ||
params: TsConfigLoader.TsConfigLoaderParams | ||
) => TsConfigLoader.TsConfigLoaderResult; | ||
params: TsConfigLoader2.TsConfigLoaderParams | ||
) => TsConfigLoader2.TsConfigLoaderResult; | ||
@@ -49,3 +49,3 @@ export interface ConfigLoaderParams { | ||
explicitParams, | ||
tsConfigLoader = TsConfigLoader.tsConfigLoader, | ||
tsConfigLoader = TsConfigLoader2.tsConfigLoader, | ||
}: ConfigLoaderParams): ConfigLoaderResult { | ||
@@ -52,0 +52,0 @@ if (explicitParams) { |
@@ -151,3 +151,2 @@ import * as path from "path"; | ||
if (exists) { | ||
// Not sure why we don't just return the full path? Why strip it? | ||
return doneCallback(undefined, TryPath.getStrippedPath(tryPath)); | ||
@@ -184,7 +183,3 @@ } | ||
if (mainFieldMappedFile) { | ||
// Not sure why we don't just return the full path? Why strip it? | ||
return doneCallback( | ||
undefined, | ||
Filesystem.removeExtension(mainFieldMappedFile) | ||
); | ||
return doneCallback(undefined, mainFieldMappedFile); | ||
} | ||
@@ -191,0 +186,0 @@ |
@@ -121,3 +121,2 @@ import * as path from "path"; | ||
if (fileExists(tryPath.path)) { | ||
// Not sure why we don't just return the full path? Why strip it? | ||
return TryPath.getStrippedPath(tryPath); | ||
@@ -135,4 +134,3 @@ } | ||
if (mainFieldMappedFile) { | ||
// Not sure why we don't just return the full path? Why strip it? | ||
return Filesystem.removeExtension(mainFieldMappedFile); | ||
return mainFieldMappedFile; | ||
} | ||
@@ -139,0 +137,0 @@ } |
198683
14
78
3563