dts-resolver
Advanced tools
| import * as oxc_resolver0 from "oxc-resolver"; | ||
| //#region src/index.d.ts | ||
| interface Options { | ||
| cwd?: string; | ||
| tsconfig?: string; | ||
| resolveNodeModules?: boolean; | ||
| ResolverFactory?: typeof oxc_resolver0.ResolverFactory; | ||
| } | ||
| type Resolver = (id: string, importer?: string) => string | null; | ||
| declare function createResolver({ | ||
| tsconfig, | ||
| cwd, | ||
| resolveNodeModules, | ||
| ResolverFactory | ||
| }?: Options): Resolver; | ||
| //#endregion | ||
| export { Options, Resolver, createResolver }; |
+121
| import { createRequire } from "node:module"; | ||
| import { dirname, extname } from "node:path"; | ||
| import process from "node:process"; | ||
| //#region rolldown:runtime | ||
| var __require = /* @__PURE__ */ createRequire(import.meta.url); | ||
| //#endregion | ||
| //#region src/index.ts | ||
| function createResolver({ tsconfig, cwd = process.cwd(), resolveNodeModules = false, ResolverFactory } = {}) { | ||
| ResolverFactory ||= __require("oxc-resolver").ResolverFactory; | ||
| const resolver = new ResolverFactory({ | ||
| mainFields: [ | ||
| "types", | ||
| "typings", | ||
| "module", | ||
| "main" | ||
| ], | ||
| conditionNames: [ | ||
| "types", | ||
| "typings", | ||
| "import", | ||
| "require" | ||
| ], | ||
| extensions: [ | ||
| ".d.ts", | ||
| ".d.mts", | ||
| ".d.cts", | ||
| ".ts", | ||
| ".mts", | ||
| ".cts", | ||
| ".tsx", | ||
| ".js", | ||
| ".mjs", | ||
| ".cjs", | ||
| ".jsx" | ||
| ], | ||
| extensionAlias: { | ||
| ".js": [ | ||
| ".d.ts", | ||
| ".ts", | ||
| ".tsx", | ||
| ".js", | ||
| ".jsx" | ||
| ], | ||
| ".jsx": [ | ||
| ".d.ts", | ||
| ".ts", | ||
| ".tsx", | ||
| ".jsx", | ||
| ".js" | ||
| ], | ||
| ".mjs": [ | ||
| ".d.mts", | ||
| ".mts", | ||
| ".mjs" | ||
| ], | ||
| ".cjs": [ | ||
| ".d.cts", | ||
| ".cts", | ||
| ".cjs" | ||
| ], | ||
| ".ts": [ | ||
| ".d.ts", | ||
| ".ts", | ||
| ".tsx", | ||
| ".js", | ||
| ".jsx" | ||
| ], | ||
| ".tsx": [ | ||
| ".d.ts", | ||
| ".tsx", | ||
| ".ts", | ||
| ".js", | ||
| ".jsx" | ||
| ], | ||
| ".mts": [ | ||
| ".d.mts", | ||
| ".mts", | ||
| ".mjs" | ||
| ], | ||
| ".cts": [ | ||
| ".d.cts", | ||
| ".cts", | ||
| ".cjs" | ||
| ] | ||
| }, | ||
| modules: resolveNodeModules ? ["node_modules", "node_modules/@types"] : [], | ||
| tsconfig: tsconfig ? { | ||
| configFile: tsconfig, | ||
| references: "auto" | ||
| } : void 0 | ||
| }); | ||
| return (id, importer) => { | ||
| const directory = importer ? dirname(importer) : cwd; | ||
| const resolution = resolver.sync(directory, id); | ||
| if (!resolution.path) return null; | ||
| const resolved = resolution.path; | ||
| return ensureValue(resolved); | ||
| }; | ||
| } | ||
| const ALLOW_EXTENSIONS = new Set([ | ||
| ".js", | ||
| ".cjs", | ||
| ".mjs", | ||
| ".jsx", | ||
| ".ts", | ||
| ".cts", | ||
| ".mts", | ||
| ".tsx", | ||
| ".json", | ||
| ".vue", | ||
| ".svelte", | ||
| ".astro" | ||
| ]); | ||
| function ensureValue(value) { | ||
| return value && ALLOW_EXTENSIONS.has(extname(value)) ? value.replaceAll("\\", "/") : null; | ||
| } | ||
| //#endregion | ||
| export { createResolver }; |
+26
-21
| { | ||
| "name": "dts-resolver", | ||
| "version": "2.1.2", | ||
| "version": "2.1.3", | ||
| "description": "Resolves TypeScript declaration files for dependencies.", | ||
@@ -20,7 +20,7 @@ "type": "module", | ||
| ], | ||
| "main": "./dist/index.js", | ||
| "module": "./dist/index.js", | ||
| "types": "./dist/index.d.ts", | ||
| "main": "./dist/index.mjs", | ||
| "module": "./dist/index.mjs", | ||
| "types": "./dist/index.d.mts", | ||
| "exports": { | ||
| ".": "./dist/index.js", | ||
| ".": "./dist/index.mjs", | ||
| "./package.json": "./package.json" | ||
@@ -40,26 +40,31 @@ }, | ||
| "devDependencies": { | ||
| "@babel/parser": "^7.28.3", | ||
| "@babel/types": "^7.28.2", | ||
| "@sxzz/eslint-config": "^7.1.4", | ||
| "@babel/generator": "^7.28.5", | ||
| "@babel/parser": "^7.28.5", | ||
| "@babel/types": "^7.28.5", | ||
| "@sxzz/eslint-config": "^7.2.8", | ||
| "@sxzz/prettier-config": "^2.2.4", | ||
| "@types/babel__generator": "^7.27.0", | ||
| "@types/debug": "^4.1.12", | ||
| "@types/node": "^24.3.0", | ||
| "@types/yargs": "^17.0.33", | ||
| "@vue/reactivity": "^3.5.19", | ||
| "bumpp": "^10.2.3", | ||
| "eslint": "^9.34.0", | ||
| "@types/node": "^24.10.0", | ||
| "@types/yargs": "^17.0.34", | ||
| "@vue/reactivity": "^3.5.24", | ||
| "bumpp": "^10.3.1", | ||
| "eslint": "^9.39.1", | ||
| "fast-glob": "^3.3.3", | ||
| "magic-string": "^0.30.18", | ||
| "magic-string-ast": "^1.0.2", | ||
| "oxc-resolver": "^11.6.2", | ||
| "magic-string": "^0.30.21", | ||
| "magic-string-ast": "^1.0.3", | ||
| "oxc-resolver": "^11.13.1", | ||
| "prettier": "^3.6.2", | ||
| "tsdown": "^0.14.1", | ||
| "typescript": "^5.9.2", | ||
| "vitest": "^3.2.4", | ||
| "vue": "^3.5.19" | ||
| "tsdown": "^0.16.1", | ||
| "typescript": "^5.9.3", | ||
| "vitest": "^4.0.8", | ||
| "vue": "^3.5.24" | ||
| }, | ||
| "engines": { | ||
| "node": ">=20.18.0" | ||
| "node": ">=20.19.0" | ||
| }, | ||
| "prettier": "@sxzz/prettier-config", | ||
| "tsdown": { | ||
| "exports": true | ||
| }, | ||
| "scripts": { | ||
@@ -66,0 +71,0 @@ "lint": "eslint --cache .", |
| import * as oxc_resolver0 from "oxc-resolver"; | ||
| //#region src/index.d.ts | ||
| interface Options { | ||
| cwd?: string; | ||
| tsconfig?: string; | ||
| resolveNodeModules?: boolean; | ||
| ResolverFactory?: typeof oxc_resolver0.ResolverFactory; | ||
| } | ||
| type Resolver = (id: string, importer?: string) => string | null; | ||
| declare function createResolver({ | ||
| tsconfig, | ||
| cwd, | ||
| resolveNodeModules, | ||
| ResolverFactory | ||
| }?: Options): Resolver; | ||
| //#endregion | ||
| export { Options, Resolver, createResolver }; |
-121
| import { createRequire } from "node:module"; | ||
| import { dirname, extname } from "node:path"; | ||
| import process from "node:process"; | ||
| //#region rolldown:runtime | ||
| var __require = /* @__PURE__ */ createRequire(import.meta.url); | ||
| //#endregion | ||
| //#region src/index.ts | ||
| function createResolver({ tsconfig, cwd = process.cwd(), resolveNodeModules = false, ResolverFactory } = {}) { | ||
| ResolverFactory ||= __require("oxc-resolver").ResolverFactory; | ||
| const resolver = new ResolverFactory({ | ||
| mainFields: [ | ||
| "types", | ||
| "typings", | ||
| "module", | ||
| "main" | ||
| ], | ||
| conditionNames: [ | ||
| "types", | ||
| "typings", | ||
| "import", | ||
| "require" | ||
| ], | ||
| extensions: [ | ||
| ".d.ts", | ||
| ".d.mts", | ||
| ".d.cts", | ||
| ".ts", | ||
| ".mts", | ||
| ".cts", | ||
| ".tsx", | ||
| ".js", | ||
| ".mjs", | ||
| ".cjs", | ||
| ".jsx" | ||
| ], | ||
| extensionAlias: { | ||
| ".js": [ | ||
| ".d.ts", | ||
| ".ts", | ||
| ".tsx", | ||
| ".js", | ||
| ".jsx" | ||
| ], | ||
| ".jsx": [ | ||
| ".d.ts", | ||
| ".ts", | ||
| ".tsx", | ||
| ".jsx", | ||
| ".js" | ||
| ], | ||
| ".mjs": [ | ||
| ".d.mts", | ||
| ".mts", | ||
| ".mjs" | ||
| ], | ||
| ".cjs": [ | ||
| ".d.cts", | ||
| ".cts", | ||
| ".cjs" | ||
| ], | ||
| ".ts": [ | ||
| ".d.ts", | ||
| ".ts", | ||
| ".tsx", | ||
| ".js", | ||
| ".jsx" | ||
| ], | ||
| ".tsx": [ | ||
| ".d.ts", | ||
| ".tsx", | ||
| ".ts", | ||
| ".js", | ||
| ".jsx" | ||
| ], | ||
| ".mts": [ | ||
| ".d.mts", | ||
| ".mts", | ||
| ".mjs" | ||
| ], | ||
| ".cts": [ | ||
| ".d.cts", | ||
| ".cts", | ||
| ".cjs" | ||
| ] | ||
| }, | ||
| modules: resolveNodeModules ? ["node_modules", "node_modules/@types"] : [], | ||
| tsconfig: tsconfig ? { | ||
| configFile: tsconfig, | ||
| references: "auto" | ||
| } : void 0 | ||
| }); | ||
| return (id, importer) => { | ||
| const directory = importer ? dirname(importer) : cwd; | ||
| const resolution = resolver.sync(directory, id); | ||
| if (!resolution.path) return null; | ||
| const resolved = resolution.path; | ||
| return ensureValue(resolved); | ||
| }; | ||
| } | ||
| const ALLOW_EXTENSIONS = [ | ||
| ".js", | ||
| ".cjs", | ||
| ".mjs", | ||
| ".jsx", | ||
| ".ts", | ||
| ".cts", | ||
| ".mts", | ||
| ".tsx", | ||
| ".json", | ||
| ".vue", | ||
| ".svelte", | ||
| ".astro" | ||
| ]; | ||
| function ensureValue(value) { | ||
| return value && ALLOW_EXTENSIONS.includes(extname(value)) ? value.replaceAll("\\", "/") : null; | ||
| } | ||
| //#endregion | ||
| export { createResolver }; |
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
6874
1.87%21
10.53%117
-12.03%1
Infinity%