Gathering detailed insights and metrics for unplugin-resolve-esm-ts-paths
Gathering detailed insights and metrics for unplugin-resolve-esm-ts-paths
Gathering detailed insights and metrics for unplugin-resolve-esm-ts-paths
Gathering detailed insights and metrics for unplugin-resolve-esm-ts-paths
Collection of GraphQL, Node, and TS related Unplugins.
npm install unplugin-resolve-esm-ts-paths
Typescript
Module System
Node Version
NPM Version
66.1
Supply Chain
93.5
Quality
74.8
Maintenance
100
Vulnerability
100
License
TypeScript (72.51%)
JavaScript (20.96%)
CSS (4.27%)
HTML (1.78%)
Shell (0.48%)
Total Downloads
2,832
Last Day
2
Last Week
42
Last Month
152
Last Year
1,588
MIT License
2 Stars
11 Commits
84 Watchers
2 Branches
447 Contributors
Updated on Apr 17, 2023
Minified
Minified + Gzipped
Latest Version
0.1.1
Package Id
unplugin-resolve-esm-ts-paths@0.1.1
Unpacked Size
63.01 kB
Size
9.81 kB
File Count
41
NPM Version
8.19.4
Node Version
16.20.0
Published on
Apr 14, 2023
Cumulative downloads
Total Downloads
Last Day
0%
2
Compared to previous day
Last Week
23.5%
42
Compared to previous week
Last Month
0%
152
Compared to previous month
Last Year
56.9%
1,588
Compared to previous year
4
unplugin-resolve-esm-ts-paths
Resolve import
and export
expressions using the TSConfig paths
and baseUrl
. This was made to be used on Node environments where you need to have relative imports and most transpile tools (even tsc
itself) doesn't change imports.
Powered by get-tsconfig
and es-module-lexer
.
index
files for directory imports.glob:
keyword will be parsed by the plugin and the default imports of every file matching the glob will be added to the file. The result will be a variable containing an array with all the default exports.With this TSConfig and Options:
1{ 2 "baseUrl": "src", 3 "paths": { 4 "@test/*": [ 5 "test/*" 6 ], 7 }, 8}
1{ 2 ext: '.ts', 3 resolveGlob: true, 4 resolvedExt: '.js', 5}
In:
1import foo from './foo' 2import doubleQ from "./doubleQ" 3import { build } from 'esbuild' 4import item from '@test/file' 5import glob from 'glob:./*.js'
Out:
1import foo from './foo.js' 2import doubleQ from './doubleQ.js' 3import { build } from 'esbuild' 4import item from './src/test/file.js' 5import module0 from './randomModule.js' 6import module1 from './anotherRandomModule.js' 7import module2 from './yetAnotherRandomModule.js' 8const glob = [module0, module1, module2]
ext
(default: .ts
): Which file extension should the plugin match.resolvedExt
(default: .js
): Which extension should be added to the imports.resolveGlob
(default: false
): If glob expressions should be resolved.1// vite.config.ts 2import unpluginResolveEsmTSPaths from 'unplugin-resolve-esm-ts-paths/vite' 3 4export default defineConfig({ 5 plugins: [ 6 unpluginResolveEsmTSPaths({ /* options */ }), 7 ], 8})
1// rollup.config.js 2import unpluginResolveEsmTSPaths from 'unplugin-resolve-esm-ts-paths/rollup' 3 4export default { 5 plugins: [ 6 unpluginResolveEsmTSPaths({ /* options */ }), 7 // other plugins 8 ], 9}
1// webpack.config.js 2module.exports = { 3 /* ... */ 4 plugins: [ 5 require('unplugin-resolve-esm-ts-paths/webpack')({ /* options */ }), 6 ], 7}
1// esbuild.config.js 2import unpluginResolveEsmTSPaths from 'unplugin-resolve-esm-ts-paths/esbuild' 3 4build({ 5 /* ... */ 6 plugins: [ 7 unpluginResolveEsmTSPaths({ /* options */ }), 8 ], 9})
If you want to solve the ts(2307)
issue for the glob imports, you can add this to one of your .d.ts
type definitions:
1declare module 'glob:*' { 2 const modules: unknown[]; 3 export default modules; 4}
No vulnerabilities found.
No security vulnerabilities found.