Skip to content

Vite Automatically Appends Extensions to Imports – How Does It Work? #18166

Answered by hi-ogawa
centraldogma99 asked this question in Q&A
Discussion options

You must be logged in to vote

Technically it's not only "Automatically Appends Extensions", but that's what normally called "resolution", which includes looking up node_modules, handling # alias, etc..

What you seeing in the diff is showing this plugin's transform, so you can follow this:

name: 'vite:import-analysis',
async transform(source, importer) {

The basic steps can be probably summarized in these three steps, 1: parse imports, 2: resolve imports, 3: replace imports

;[imports, exports] = parseImports(source)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by centraldogma99
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants