Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle relative path glob raw import, fix #7307 #7371

Merged
merged 2 commits into from Mar 27, 2022

Conversation

toshify
Copy link
Contributor

@toshify toshify commented Mar 18, 2022

Description

import.meta.glob("../index.html", { as: "raw" }) fails to resolve the correct path during a readFile operation.

This fix will add a test for the failing use case of glob-importing with both a relative parent folder path and a raw import,
and fix this by using the unmanipulated file path as reference when reading the file. file is manipulated to add the ../-parts from the glob pattern, while files[i] is the bare path relative to base.

Closes #7307


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

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

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

packages/playground/glob-import/index.html Outdated Show resolved Hide resolved
packages/playground/glob-import/index.html Outdated Show resolved Hide resolved
@bluwy bluwy added the p3-minor-bug An edge case that only affects very specific usage (priority) label Mar 18, 2022
Contain test within `glob-import`-folder
Remove comments referencing issue number
@patak-dev patak-dev merged commit 7f8dc58 into vitejs:main Mar 27, 2022
@toshify toshify deleted the fix/relative-glob-raw-import branch March 27, 2022 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

import.meta.glob with {as: "raw"} doesn't handle relative paths
3 participants