refactor(legacy): remove unneeded dynamic import var init code #7759
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Currently plugin-legacy outputs html like below. (extracted the relevant part)
The first script tag is unused.
The reason is that a top level variable inside
type="module"
is not exposed to global.It could be fixed by removing
type="module"
or changing towindow.__vite_is_dynamic_import_support = false
.But since it is a falsy value, the declaration is not needed.
So I dropped this script tag.
This will simply the code a bit and also reduce file size of html (and csp header) a bit.
I tested this with https://github.com/yoyo930021/vite-legacy-csp-bug in Chrome 102, Chrome 62, Edge 18, Firefox 66, Safari 10.1.
refs #6535
Additional context
https://discord.com/channels/804011606160703521/804439875226173480/964612065337696307
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).