Skip to content

fix(bundled-dev): refresh after editing inline scripts in html entries - #23194

Open
btea wants to merge 4 commits into
vitejs:mainfrom
btea:fix/bundled-dev-html-inline-script-refresh
Open

btea wants to merge 4 commits into
vitejs:mainfrom
btea:fix/bundled-dev-html-inline-script-refresh

Conversation

@btea

@btea btea commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

fix #23179
Editing an inline script in an html entry was invisible to the dev engine, so no reload happened and even a manual reload served stale content until the server was restarted.

For classic inline scripts the updated html itself only reaches the dev output once rolldown includes re-emitted assets with changed content in rebuild output (rolldown/rolldown#10637). The e2e test for that case is skipped under bundledDev until the fix is released.

js += `\nimport "${id}?html-proxy&index=${inlineModuleIndex}.js"`
// include a content hash in the proxy id so that editing the
// inline script is detected as a change by the bundler
js += `\nimport "${id}?html-proxy&index=${inlineModuleIndex}&h=${getHash(contents)}.js"`

@h-a-n-a h-a-n-a Aug 18, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like the right fix for that is, instead of adding a hash here, on the Rolldown side. A changed file should invalidate every module whose id contains the same file. For example, in vue, foo.vue?vue&type=script and foo.vue?vue&type=template should both has file dependencies of foo.vue. A change to foo.vue will invalidate these modules with queries all together. This is the same counterpart as webpack's fileDependencies and Vite unbundled-dev's fileToModulesMap.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, agreed — the &h= hash is a workaround, not a root fix. Do you plan to fix this scenario on the rolldown side, or is it already supported/fixed there?

@h-a-n-a h-a-n-a Aug 18, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks fine for a workaround 👍. I haven't fixed this. Let me handle this in Rolldown since it might be also related to #22956.

@h-a-n-a h-a-n-a Aug 19, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread packages/vite/src/node/server/bundledDev.ts Outdated
Comment thread packages/vite/src/node/server/bundledDev.ts Outdated
@h-a-n-a
h-a-n-a requested a review from sapphi-red August 18, 2026 10:15
Co-authored-by: andrew <andywangsy@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stale refresh when editing script in html file with bundledDev

2 participants