-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Closed
Copy link
Labels
invalidThis doesn't seem rightThis doesn't seem right
Description
Describe the bug
In my index.html file, I have a script element in the <head>. Inside of that, I have a string literal that includes "</script>". This throws the following error:
[vite] (client) Pre-transform error: Failed to parse source for import analysis because the content contains invalid JS syntax. You may need to install appropriate plugins to handle the .js file format, or if it's an asset, add "**/*.js" to `assetsInclude` in your configuration.
Plugin: vite:import-analysis
Reproduction
https://stackblitz.com/edit/vitejs-vite-u2lf5z82?file=index.html
Steps to reproduce
Open the Stackblitz.
The only change from the boilerplate is the addition of this in the index.html file-
<script type="module">
// This line breaks
const string = `</script>`;
</script>
System Info
System:
OS: macOS 26.1
CPU: (11) arm64 Apple M3 Pro
Memory: 95.52 MB / 36.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.19.5 - /Users/jamessw/.nvm/versions/node/v20.19.5/bin/node
Yarn: 1.22.22 - /Users/jamessw/.yarn/bin/yarn
npm: 10.8.2 - /Users/jamessw/.nvm/versions/node/v20.19.5/bin/npm
Deno: 1.44.1 - /Users/jamessw/.deno/bin/deno
Watchman: 2025.07.14.00 - /opt/homebrew/bin/watchman
Browsers:
Chrome: 142.0.7444.176
Chrome Canary: 144.0.7543.0
Edge: 142.0.3595.94
Firefox Nightly: 147.0a1
Safari: 26.1
Safari Technology Preview: 26.0
npmPackages:
vite: ^7.1.12 => 7.1.12Used 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.
Metadata
Metadata
Assignees
Labels
invalidThis doesn't seem rightThis doesn't seem right