-
-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Open
Labels
Description
Describe the bug
In production builds Vite moves scripts tags, breaking order of execution with <script vite-ignore type="module">.
Reproduction
https://stackblitz.com/edit/vitejs-vite-i5gjryer?file=index.html
Steps to reproduce
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>script execution order</title>
</head>
<body>
<script vite-ignore type="module">
window.leet = 1337;
</script>
<script type="module">
document.body.append(`Should be leet: ${window.leet}`);
</script>
</body>
</html>vite dev-> “Should be leet: 1337”vite build && vite preview-> “Should be leet: undefined”
System Info
System:
OS: macOS 26.2
CPU: (14) arm64 Apple M4 Pro
Memory: 5.69 GB / 48.00 GB
Shell: 4.3.3 - /opt/homebrew/bin/fish
Binaries:
Node: 24.12.0 - /Users/simon.lydell/.local/share/nvm/v24.12.0/bin/node
npm: 11.6.2 - /Users/simon.lydell/.local/share/nvm/v24.12.0/bin/npm
Browsers:
Chrome: 144.0.7559.132
Firefox Developer Edition: 148.0
Safari: 26.2
npmPackages:
vite: ^7.2.4 => 7.3.1Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Reactions are currently unavailable