Gathering detailed insights and metrics for vite-resolve-tsconfig-paths
Gathering detailed insights and metrics for vite-resolve-tsconfig-paths
Gathering detailed insights and metrics for vite-resolve-tsconfig-paths
Gathering detailed insights and metrics for vite-resolve-tsconfig-paths
npm install vite-resolve-tsconfig-paths
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
36 Commits
1 Forks
1 Watching
15 Branches
1 Contributors
Updated on 03 Nov 2024
Minified
Minified + Gzipped
TypeScript (50.55%)
Shell (39.8%)
JavaScript (9.65%)
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
-80.8%
5
Compared to previous week
Last month
87.7%
137
Compared to previous month
Last year
0%
689
Compared to previous year
2
1
Resolve Typescript paths (tsconfig paths) in your Vite project.
Install
1npm install -D vite-resolve-tsconfig-paths
Add to vite.config.js
1// vite.config.js 2import { defineConfig } from "vite"; 3import { tsConfigPaths } from "vite-resolve-tsconfig-paths"; 4 5export default defineConfig({ 6 plugins: [tsConfigPaths()], 7});
Currently none. Some coming soon.
Why use this plugin when there are several alternatives (I know, I struggled to find an available npm package name), and some are far more used, more mature? Great question. You don't have to!
I created this plugin to solve a problem I had; the main existing option doesn't support extends
or references
in a sub-directory. I did actually draft a fix for that library, but in my travels I decided that there was probably a "better" approach to solving the problem.
So this library was born.
Yes. That was the main reason I created it.
${configDir}
?In theory yes. I haven't tested it yet. Test it, let me know.
When the Vite plugin hook configResolved
is run, the plugin (using tsconfck
) looks for all tsconfig.json
project files within the project root.
The plugin will then process all these tsconfig.json
files (including references
), and parse the config.
Parsing the config file gives the final compilerOptions
, including values from extended configs.
The parsing uses tsconfck
's parseNative
, so the result should be as comparable with the expected result as that library is capable of.
For each parsed result with paths
in compilerOptions
, the plugin will create a "resolver" function. This resolver function takes a Vite request id and attempts to resolve it relative to the baseUrl
using tsconfig-paths
.
In the Vite resolveId
hook, the plugin checks each request, to see if the resolvers should be applied.
If there is an importer, the request id is not relative, and the request is not a file system absolute path (i.e. it is an alias import), the plugin applies all the resolvers created earlier until one matches.
This plugin was inspired by, and borrows some logic (checking request ids to see if resolvers should be applied) from https://github.com/aleclarson/vite-tsconfig-paths, however we've taken a significantly different approach to solving the problem.
Contributions are super welcome.
Clone the repo
1git clone https://github.com/sebtoombs/vite-resolve-tsconfig-paths.git
Install dependencies
1npm install
Write some code!
Build
1npm run build
Don't forget, to pass CI, your code will need to pass npm run lint
, npm run format:check
& npm run build
To make a contribution;
main
branch of this repo
No vulnerabilities found.
No security vulnerabilities found.