You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
git clone https://github.com/maxpatiiuk/vite-externalize-inject-bug
cd vite-externalize-inject-bug
Install dependencies:
npm install
Build the project:
npx vite build
Open dist/index.html in text editor and see the following:
<scripttype="importmap">{"imports": {"@arcgis/core/": "https://jsdev.arcgis.com/4.32/@arcgis/core/"}}</script><!-- The @arcgis/core/Map.js script tag is not supposed to be here: --><!-- And it is not valid as import map does not apply to script[src] --><scripttype="module" crossoriginsrc="@arcgis/core/Map.js"></script><scripttype="module" crossoriginsrc="/assets/main-By8reOiR.js"></script><!-- And not sure why it gets added twice: --><scripttype="module" crossoriginsrc="@arcgis/core/Map.js"></script>
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.
maxpatiiuk
changed the title
Externalized module is inlined to index.html, leading to runtime error
Externalized module is inlined in index.html, leading to runtime error
May 16, 2025
Describe the bug
Vite is adding script tags like the following to index.html, which are not valid specifiers in the browser and lead to runtime error:
Reproduction
https://github.com/maxpatiiuk/vite-externalize-inject-bug
Steps to reproduce
Clone the repository:
git clone https://github.com/maxpatiiuk/vite-externalize-inject-bug cd vite-externalize-inject-bug
Install dependencies:
Build the project:
Open dist/index.html in text editor and see the following:
Expected to see the following:
To the best of my knowledge, the bug occurs here:
vite/packages/vite/src/node/plugins/html.ts
Lines 916 to 919 in 0d18fc1
The code below it is handling this correctly:
vite/packages/vite/src/node/plugins/html.ts
Lines 927 to 928 in 0d18fc1
Related changes:
rollup.external
scripts correctly #18618System Info
Used Package Manager
pnpm
Logs
Click to expand!
Validations
The text was updated successfully, but these errors were encountered: