sajad torkamani

Native ES imports don’t support module imports like the following:

import { someMethod } from 'some-npm-dependency'

Serving a file with the above code directly in the browser will result in an error because the browser doesn’t know how to import packages from NPM – it needs the path to the file on the server’s filesystem.

Vite detects such bare module imports in all served source files and rewrites the imports to valid URLs like /node_modules/.vite/deps/some-npm-dependency.js?v=123456 so that the browser can import them.

Tagged: Vite