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 #10773
Description
We currently share the same preload helper for injecting CSS stylesheets of dynamic imports. Even when
modulePreload
is set tofalse
, we still need the preload import helper and preserve the CSS styles for the dynamically imported module.We already had a test case for
modulePreload: false
, but one of the checks was wrong.This fix isn't ideal, users that set
modulePreload
false would probably expect the import helper to be avoided. But at least the behavior is correct after this PR.Related issue:
__vitePreload
if dependency array is empty #13952#13952 one isn't easy to solve as we need
import.meta.url
in the transform hook, and populate the deps for the dynamic import ingenerateBundle
. If we don't find a good way to find if the preload helper is needed at transform time, maybe we could at least reduce the helper that is quite verbose now with no deps and then replace it back ingenerateBundle
(even if we leave some white space to avoid messing with sourcemaps).What is the purpose of this pull request?