vite-tsconfig-paths
Advanced tools
Comparing version 3.0.0 to 3.0.1
@@ -39,6 +39,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var path_1 = require("path"); | ||
var vite_1 = require("vite"); | ||
var tsconfig_paths_1 = require("tsconfig-paths"); | ||
var tsconfig_loader_1 = require("tsconfig-paths/lib/tsconfig-loader"); | ||
var path_1 = require("path"); | ||
var debug = require('debug')('vite-tsconfig-paths'); | ||
@@ -51,3 +51,5 @@ exports.default = (function (opts) { | ||
configResolved: function (_a) { | ||
var _b; | ||
var root = _a.root, logger = _a.logger; | ||
var extensions = ((_b = opts.extensions) === null || _b === void 0 ? void 0 : _b.concat(implicitExtensions)) || implicitExtensions; | ||
var resolvers = (opts.projects || [root]) | ||
@@ -63,3 +65,3 @@ .map(createResolver) | ||
case 0: | ||
if (!importer) return [3 /*break*/, 4]; | ||
if (!(importer && !relativeImportRE.test(id) && !path_1.isAbsolute(id))) return [3 /*break*/, 4]; | ||
viteResolve = function (id) { return __awaiter(_this, void 0, void 0, function () { var _a; return __generator(this, function (_b) { | ||
@@ -122,5 +124,4 @@ switch (_b.label) { | ||
var path; | ||
var _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
@@ -130,3 +131,3 @@ if (!importerExtRE.test(importer)) return [3 /*break*/, 3]; | ||
if (!(!path && isLocalDescendant(importer, configRoot))) return [3 /*break*/, 2]; | ||
path = matchPath(id, undefined, undefined, ((_a = opts.extensions) === null || _a === void 0 ? void 0 : _a.concat(implicitExtensions)) || implicitExtensions); | ||
path = matchPath(id, undefined, undefined, extensions); | ||
if (!path) return [3 /*break*/, 2]; | ||
@@ -136,3 +137,3 @@ path = vite_1.normalizePath(path); | ||
case 1: | ||
path = _b.sent(); | ||
path = _a.sent(); | ||
if (path) { | ||
@@ -142,3 +143,3 @@ resolved.set(id, path); | ||
} | ||
_b.label = 2; | ||
_a.label = 2; | ||
case 2: return [2 /*return*/, path]; | ||
@@ -154,2 +155,3 @@ case 3: return [2 /*return*/]; | ||
var nodeModulesRE = /\/node_modules\//; | ||
var relativeImportRE = /^\.\.?(\/|$)/; | ||
/** Returns true when `path` is within `root` and not an installed dependency. */ | ||
@@ -156,0 +158,0 @@ function isLocalDescendant(path, root) { |
{ | ||
"name": "vite-tsconfig-paths", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "Vite resolver for TypeScript compilerOptions.paths", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -0,5 +1,5 @@ | ||
import { resolve, isAbsolute } from 'path' | ||
import { normalizePath, Plugin } from 'vite' | ||
import { createMatchPath, loadConfig } from 'tsconfig-paths' | ||
import { loadTsconfig } from 'tsconfig-paths/lib/tsconfig-loader' | ||
import { resolve } from 'path' | ||
@@ -36,2 +36,4 @@ const debug = require('debug')('vite-tsconfig-paths') | ||
configResolved({ root, logger }) { | ||
const extensions = | ||
opts.extensions?.concat(implicitExtensions) || implicitExtensions | ||
const resolvers = (opts.projects || [root]) | ||
@@ -42,3 +44,3 @@ .map(createResolver) | ||
this.resolveId = async function (id, importer) { | ||
if (importer) { | ||
if (importer && !relativeImportRE.test(id) && !isAbsolute(id)) { | ||
const viteResolve = async (id: string) => | ||
@@ -105,8 +107,3 @@ (await this.resolve(id, importer, { skipSelf: true }))?.id | ||
if (!path && isLocalDescendant(importer, configRoot)) { | ||
path = matchPath( | ||
id, | ||
undefined, | ||
undefined, | ||
opts.extensions?.concat(implicitExtensions) || implicitExtensions | ||
) | ||
path = matchPath(id, undefined, undefined, extensions) | ||
if (path) { | ||
@@ -129,2 +126,3 @@ path = normalizePath(path) | ||
const nodeModulesRE = /\/node_modules\// | ||
const relativeImportRE = /^\.\.?(\/|$)/ | ||
@@ -131,0 +129,0 @@ /** Returns true when `path` is within `root` and not an installed dependency. */ |
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
20344