Fix generating html with script tags to ensure correct order #1403
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.
Fixes #1400.
The root cause of the issue is the order execution of script tags when the panel is open for the very first time. After the initial load, all of the scripts are cached in memory, so the next load execution order is correct.
The PR adds a fix on the
vite
source code level, as this cannot be set by the Vite configuration. We are using Vite in very specific way, where we do not bundle modules into a single file, so Vite interprets html entries, as having only one import. It tries to resolve it to the list of nested imports, but it goes deep in the tree. As a result, a long list of scripts are loaded by the script tag. It looks like Safari when loading for the first time does not respect the order of async scripts.The fix is safe, as we can load only the top level of imports - they import other files just from the
import
statements in the source code.