4.3.2 • Published 15 days ago

vite-tsconfig-paths v4.3.2

Weekly downloads
3,300
License
MIT
Repository
github
Last release
15 days ago

👋 Do you like Postgres 🐘? I'm making a 100% type-safe query builder (not an ORM), and I want your help fleshing it out.
Btw, it generates the types and client from your database schema, so it's never out-of-date and you have access to every native Postgres function!
I want to add a powerful plugin system soon, and eventually all functionality will be pluggable.

Learn more


vite-tsconfig-paths

npm codecov Code style: Prettier Donate

Give vite the ability to resolve imports using TypeScript's path mapping.

Usage

  1. Install as dev dependency

  2. Inject vite-tsconfig-paths using the vite.config.ts module

    import { defineConfig } from 'vite'
    import tsconfigPaths from 'vite-tsconfig-paths'
    
    export default defineConfig({
      plugins: [tsconfigPaths()],
    })

Note: You need to restart Vite when you update your paths mappings.

Options

  • root: string
    The directory to search for tsconfig.json files.

    The default value of this option depends on whether projects is defined. If it is, then the Vite project root is used. Otherwise, Vite's searchForWorkspaceRoot function is used.

  • projects: string[]
    If you have an esoteric setup, you might need this option to specify where your tsconfig files are located. The paths within are relative to the root option.

    If defined, the root directory won't be searched for tsconfig files. You should always try using just the root option first, because this option is more brittle.

  • loose: boolean
    Disable strictness that limits path resolution to TypeScript and JavaScript importers.

    Useful if you want imports in Vue templates to be resolved, but don't want to use allowJs in your tsconfig, for example.

    In other words, when loose: true is used, any file that gets transpiled into JavaScript will have its imports resolved by this plugin.

  • parseNative: boolean
    Enable use of the tsconfck.parseNative function, which delegates the loading of tsconfig files to the TypeScript compiler. You'll probably never need this, but I added it just in case.

    ⚠️ This option can slow down Vite's startup time by as much as 600ms, due to the size of the TypeScript compiler. Only use it when necessary.

  • ignoreConfigErrors: boolean
    When true, parsing errors encountered while loading tsconfig files will be ignored. This is useful if you have a monorepo with multiple tsconfig files, and you don't want to see errors for the ones that aren't relevant to the current project.

 

allowJs

If your tsconfig file has "allowJs": true in it, path resolution will be expanded beyond TypeScript importers. The following extensions will have their imports resolved by this plugin: .vue, .svelte, .mdx, .mjs, .js, .jsx

 

baseUrl

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.

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).

 

include/exclude

The include and exclude tsconfig options are respected.

Internally, globrex is used for glob matching.

 

Troubleshooting

The DEBUG environment variable can be used to figure out why this plugin isn't working as you may have expected.

DEBUG=vite-tsconfig-paths yarn vite

Also, check out the Troubleshooting wiki page for more guidance.

@triplex/client@noxickon/componentsalif-ui-kit-react@ithinkdt-cloud/vite-ithinkdt-vuem4l_graphics@ladle/react-test@infinitebrahmanuniverse/nolb-vite-tbutton-star0button-star2hjchoi-uistrapionclasor-file-managementclasor-file-testmulti-doughnut-chartreact-tw-compnerox-componentswidget-aw-btnreact-basic-elementsplop-dms@everything-registry/sub-chunk-3062@beardeddudes-dev/vite@beardeddudes-dev/vite-config@aryaemami59/vitest-config@gecut/iconsliving-app-testexperiences-configllopis-lib-testhelpdesk-widget-chathikigo-libhyperverge-intern-ui-library-2kdpa-components2kumo-uikui-kevinimjmediaies-dynamic-inputite-cms-packagejenesei-react-uilunar-persian-calendarmainstack-design-systemmarc-custom-component-librarymirrorfuljsx-emailinvestec-auth-libraryjsprobeneat-form-buildernetflix-clone-using-react-typescript-muimaiieul-mdx-js-qwikmelodiy-component-librarymani-react-vite-librarymf-core-uinopeless-configluu-tru-van-banmcf-ui-librarymilas-uidrs-componentsdynamic-components-test-cs3dummy-ui-library-rajfeedbacky-module-systemfemsa-dsfind-tournamentsfile-management-testfauzi-uiprojectevoltis-vuefully-reactexample-publish-with-storybook-and-viteqwik-components-qwikqortal-app-utilsqgppoletto-bookstorereact-cardflee-animreact-canvas-enginereact-lib-scaffoldreact-form-query.eaareact-form-components.eaareact-group-provideronroadlibraryonroaduioveny2pets-backend-v2phenomenon-uipluzchat-support-uirazor-shared-librarypgv-libpgv-uirutas_dinamicassemente-jszsans-ui@duotone/react@happylogue/vitest-presets@essex/vite-config@elliemae/pui-cli@eramis/atex@entropik/decode-insights-charts@gtplan/react-components@equinor/fusion-framework-cli@footron/controls-cli@fracture-designs/web@hush-mirzo/ui-kit-react@iiwin/miniapp@hyperloop-upv/common-front@jefersonvinicius/components
4.3.2

15 days ago

4.3.1

2 months ago

4.3.0

2 months ago

4.2.3

3 months ago

4.2.2

4 months ago

4.2.1

7 months ago

4.0.5

1 year ago

4.0.4

1 year ago

4.0.7

1 year ago

4.0.6

1 year ago

4.2.0

12 months ago

4.0.9

12 months ago

4.0.8

12 months ago

4.1.0

12 months ago

4.0.0-alpha.5

1 year ago

4.0.0-alpha.6

1 year ago

4.0.0-alpha.3

1 year ago

4.0.0-alpha.4

1 year ago

4.0.0-alpha.1

1 year ago

4.0.0-alpha.2

1 year ago

3.6.0

1 year ago

4.0.1

1 year ago

4.0.0

1 year ago

4.0.3

1 year ago

4.0.2

1 year ago

3.5.2

1 year ago

3.5.1

2 years ago

3.5.0

2 years ago

3.4.0

2 years ago

3.4.1

2 years ago

3.3.15

2 years ago

3.3.16

2 years ago

3.3.17

2 years ago

3.3.14

3 years ago

3.3.13

3 years ago

3.3.10

3 years ago

3.3.11

3 years ago

3.3.12

3 years ago

3.3.9

3 years ago

3.3.8

3 years ago

3.3.7

3 years ago

3.3.6

3 years ago

3.3.5

3 years ago

3.3.4

3 years ago

3.3.3

3 years ago

3.3.2

3 years ago

3.3.1

3 years ago

3.3.0

3 years ago

3.2.1

3 years ago

3.2.0

3 years ago

3.1.0

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.5.1

3 years ago

2.5.0

3 years ago

2.4.0

3 years ago

2.3.0

3 years ago

2.2.0

3 years ago

2.1.0

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

2.0.0-alpha.4

3 years ago

2.0.0-alpha.3

3 years ago

2.0.0-alpha.2

3 years ago

2.0.0-alpha.1

3 years ago

1.1.0

4 years ago

1.0.0

4 years ago