vitejs / vite

Next generation frontend tooling. It's fast!
http://vite.dev
MIT License
68.81k stars 6.22k forks source link

Vite injects __vitePreload even if the modulePreload option is disabled #18551

Open lubomirblazekcz opened 3 weeks ago

lubomirblazekcz commented 3 weeks ago

Describe the bug

Vite injects __vitePreload on each dynamic import, I would expected this not be included when modulePreload is set to false.

Eg. If I want to handle preloading manually or not at all.

Related https://github.com/vitejs/vite/issues/13952 https://github.com/vitejs/vite/pull/13973

Reproduction

https://stackblitz.com/edit/vitejs-vite-p54vgg

Steps to reproduce

Run vite build and the output is actually larger then the source.

System Info

..

Used Package Manager

npm

Logs

No response

Validations

bluwy commented 3 weeks ago

Related: https://github.com/vitejs/vite/pull/13973

vritant24 commented 3 days ago

In our scenario, preloading any file causes errors as we have a tricky way of resolving file paths (our code runs inside a vscode controlled iframe). Specifically __vitePreload injects a stylesheet link that causes our page to not load.

Following the referenced PRs and issues, I understand why it's the case, but is there a workaround to prevent the runtime injection of the preloads today?