vite icon indicating copy to clipboard operation
vite copied to clipboard

fix: `build.modulePreload.resolveDependencies` is optimizable

Open sapphi-red opened this issue 3 months ago • 1 comments

Description

The document of build.modulePreload.resolveDependencies had

Returning a relative path to the hostId for hostType === 'js' is allowed, in which case new URL(dep, import.meta.url) is used to get an absolute path when injecting this module preload in the HTML head.

, but actually this wasn't true. build.modulePreload.resolveDependencies does not expect a relative path to the hostId. It expects a relative path to build.outDir. The result of build.modulePreload.resolveDependencies is passed to toOutputFilePathWithoutRuntime or toOutputFilePathInJS.

close #13169 (indirectly)

Additional context


What is the purpose of this pull request?

  • [x] Bug fix
  • [ ] New Feature
  • [ ] Documentation update
  • [ ] Other

Before submitting the PR, please make sure you do the following

  • [x] Read the Contributing Guidelines, especially the Pull Request Guidelines.
  • [x] Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • [x] Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • [x] Update the corresponding documentation if needed.
  • [ ] Ideally, include relevant tests that fail without this PR but pass with it.

sapphi-red avatar Mar 03 '24 14:03 sapphi-red