

This means Vite won't be able to discover the import on the initial scan - it can only discover it after the file is requested by the browser and transformed.

For example, maybe the import is created as a result of a plugin transform. In cases where you want to explicitly include/exclude dependencies from the list, use the optimizeDeps config options.Ī typical use case for optimizeDeps.include or optimizeDeps.exclude is when you have an import that is not directly discoverable in the source code. The default dependency discovery heuristics may not always be desirable. If you stumble on this issue, use npm pack on the linked dependency to fix it. If not, you can add the dependency to optimizeDeps.include and in your config.ĭue to differences in linked dependency resolution, transitive dependencies can deduplicate incorrectly, causing issues when used in runtime. However, this requires the linked dep to be exported as ESM. It will not attempt to bundle the linked dep, and will analyze the linked dep's dependency list instead. Vite automatically detects dependencies that are not resolved from node_modules and treats the linked dep as source code. In a monorepo setup, a dependency may be a linked package from the same repo. The pre-bundling is performed with esbuild so it's typically very fast.Īfter the server has already started, if a new dependency import is encountered that isn't already in the cache, Vite will re-run the dep bundling process and reload the page if needed. "bare imports" that expect to be resolved from node_modules) and use these found imports as entry points for the pre-bundle.
#504 GATEWAY TIME OUT QUE SIGNIFICA CODE#
If an existing cache is not found, Vite will crawl your source code and automatically discover dependency imports (i.e. Dependency pre-bundling only applies in development mode, and uses esbuild to convert dependencies to ESM.
