vite-tsconfig-paths
Advanced tools
Comparing version 3.3.1 to 3.3.2
@@ -116,3 +116,5 @@ "use strict"; | ||
} | ||
var resolveId; | ||
var resolveId = function (id, importer) { | ||
return viteResolve(path_1.join(config.absoluteBaseUrl, id), importer); | ||
}; | ||
if (config.paths) { | ||
@@ -126,3 +128,4 @@ var matchPath_1 = tsconfig_paths_1.createMatchPathAsync(config.absoluteBaseUrl, config.paths, config.mainFields || [ | ||
], config.addMatchAll); | ||
resolveId = function (id, importer) { | ||
var resolveWithBaseUrl_1 = resolveId; | ||
var resolveWithPaths_1 = function (id, importer) { | ||
return new Promise(function (done) { | ||
@@ -141,6 +144,4 @@ matchPath_1(id, void 0, void 0, extensions, function (error, path) { | ||
}; | ||
} | ||
else { | ||
resolveId = function (id, importer) { | ||
return viteResolve(path_1.join(config.absoluteBaseUrl, id), importer); | ||
return resolveWithPaths_1(id, importer).then(function (resolved) { return resolved || resolveWithBaseUrl_1(id, importer); }); | ||
}; | ||
@@ -147,0 +148,0 @@ } |
{ | ||
"name": "vite-tsconfig-paths", | ||
"version": "3.3.1", | ||
"version": "3.3.2", | ||
"description": "Vite resolver for TypeScript compilerOptions.paths", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -43,3 +43,3 @@ # vite-tsconfig-paths | ||
File extensions to search for. | ||
Defaults to `.ts | .tsx | .js | .jsx | .json` | ||
Defaults to `.ts | .tsx | .js | .jsx | .mjs` | ||
@@ -58,5 +58,5 @@ - `loose: boolean` | ||
### baseUrl only | ||
### baseUrl | ||
If the `baseUrl` is defined but not `paths`, the `baseUrl` will be prepended to all bare imports, and its resolution will take precedence over node_modules. This is also how TypeScript does it. | ||
If the `baseUrl` is defined, it gets prepended to all bare imports, and its resolution will take precedence over node_modules. This is also how TypeScript does it. | ||
@@ -63,0 +63,0 @@ Say the `baseUrl` is `../root` and you import `react`. This plugin will use `../root/react` if it exists. If not found, then `react` is resolved normally. The `baseUrl` is relative to the project root (where `tsconfig.json` lives). |
@@ -84,3 +84,5 @@ import { dirname, join, resolve, isAbsolute } from 'path' | ||
let resolveId: Resolver | ||
let resolveId: Resolver = (id, importer) => | ||
viteResolve(join(config.absoluteBaseUrl, id), importer) | ||
if (config.paths) { | ||
@@ -99,3 +101,5 @@ const matchPath = createMatchPathAsync( | ||
) | ||
resolveId = (id, importer) => | ||
const resolveWithBaseUrl = resolveId | ||
const resolveWithPaths: Resolver = (id, importer) => | ||
new Promise((done) => { | ||
@@ -112,5 +116,7 @@ matchPath(id, void 0, void 0, extensions, (error, path) => { | ||
}) | ||
} else { | ||
resolveId = (id, importer) => | ||
viteResolve(join(config.absoluteBaseUrl, id), importer) | ||
resolveWithPaths(id, importer).then( | ||
(resolved) => resolved || resolveWithBaseUrl(id, importer) | ||
) | ||
} | ||
@@ -117,0 +123,0 @@ |
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
29197
433