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

feat(importMetaGlob): support sub imports pattern #12467

Merged
merged 5 commits into from
Jun 6, 2023

Conversation

sun0day
Copy link
Member

@sun0day sun0day commented Mar 17, 2023

Description

fix #12465

Additional context


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 PR Title 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.

@stackblitz
Copy link

stackblitz bot commented Mar 17, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@sun0day
Copy link
Member Author

sun0day commented Mar 17, 2023

I think we can consider supporting read modules via sub imports path like #12221. There will be 3 glob patterns: normal pattern, alias pattern and sub imports pattern. Each pattern's module entry key has its own style.

Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. In the future maybe we can improve the custom glob resolver to handle aliases only, but I think this is good enough for now.

EDIT: That might be what you mean in #12467 (comment), but I have no context of that PR and issue yet 😬

@patak-dev
Copy link
Member

/ecosystem-ci run

@vite-ecosystem-ci

This comment was marked as outdated.

@patak-dev
Copy link
Member

/ecosystem-ci run astro

@vite-ecosystem-ci

This comment was marked as outdated.

@sun0day
Copy link
Member Author

sun0day commented Mar 20, 2023

I am not familiar with astro. Can you help check out why this fails @bluwy Thanks.

@patak-dev patak-dev added this to the 4.3 milestone Mar 20, 2023
@patak-dev patak-dev added the p2-nice-to-have Not breaking anything but nice to have (priority) label Mar 20, 2023
@bluwy
Copy link
Member

bluwy commented Mar 21, 2023

I think it's flaky tests happening, but since this is sort-of a feature too, we've pushed it to the next minor so we can test more extensively with Astro.

@patak-dev
Copy link
Member

patak-dev commented Mar 21, 2023

@bluwy feel free to merge it when you feel it is better, let's start the 4.3 beta period 🙌

@bluwy
Copy link
Member

bluwy commented Mar 21, 2023

/ecosystem-ci run astro

@vite-ecosystem-ci

This comment was marked as outdated.

bluwy
bluwy previously approved these changes Apr 4, 2023
@bluwy
Copy link
Member

bluwy commented Apr 4, 2023

/ecosystem-ci run

@vite-ecosystem-ci
Copy link

vite-ecosystem-ci bot commented Apr 4, 2023

📝 Ran ecosystem CI: Open

suite result
astro ❌ failure
histoire ❌ failure
iles ❌ failure
ladle ✅ success
laravel ✅ success
marko ✅ success
nuxt ❌ failure
previewjs ✅ success
qwik ✅ success
rakkas ✅ success
sveltekit ✅ success
vite-plugin-ssr ❌ failure
vite-plugin-react ✅ success
vite-plugin-react-pages ✅ success
vite-plugin-react-swc ✅ success
vite-plugin-svelte ✅ success
vite-plugin-vue ✅ success
vite-setup-catalogue ✅ success
vitepress ✅ success
vitest ✅ success
windicss ✅ success

@bluwy
Copy link
Member

bluwy commented Apr 4, 2023

The current failures also fail in main, except Astro again 😭 I'm quite inclined to merge this still because Astro's CI error doesn't makes sense that it'd be affected by this PR.

@sun0day
Copy link
Member Author

sun0day commented Apr 4, 2023

The current failures also fail in main, except Astro again 😭 I'm quite inclined to merge this still because Astro's CI error doesn't makes sense that it'd be affected by this PR.

Maybe this pr triggers a bug in astro. It looks like the errors are the same between each ecosystem-run


const resolved = normalizePath(
(await resolveId(glob, importer, {
custom: { 'glob-imports': isSubImportsPattern },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bluwy I also think we should merge this one, we have time to fix Astro if it is affecting it (but as you say, I doubt is related)

About the custom option, maybe we should use a namespace for it to avoid collisions? Something like 'vite:import-glob:imports' or 'vite:import-glob-imports' ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah if this gets merged, I'll monitor Astro again for errors. A namespace sounds nice too, maybe we should follow the Vite plugin name we use vite:import-glob, since there's also custom['node-resolve'].

antfu
antfu previously approved these changes Apr 4, 2023
@patak-dev
Copy link
Member

/ecosystem-ci run

@vite-ecosystem-ci
Copy link

vite-ecosystem-ci bot commented Apr 19, 2023

📝 Ran ecosystem CI: Open

suite result
astro ✅ success
histoire ✅ success
iles ✅ success
ladle ✅ success
laravel ✅ success
marko ✅ success
nuxt ✅ success
previewjs ✅ success
qwik ✅ success
rakkas ✅ success
sveltekit ✅ success
vite-plugin-ssr ✅ success
vite-plugin-react ✅ success
vite-plugin-react-pages ✅ success
vite-plugin-react-swc ✅ success
vite-plugin-svelte ✅ success
vite-plugin-vue ✅ success
vite-setup-catalogue ✅ success
vitepress ✅ success
vitest ❌ failure
windicss ✅ success

@patak-dev patak-dev modified the milestones: 4.3, 4.4 Apr 19, 2023
@patak-dev patak-dev dismissed stale reviews from antfu and bluwy via 4c69e4f April 19, 2023 08:47
@patak-dev
Copy link
Member

Updated the custom naming to:

    (await resolveId(glob, importer, {
      custom: { 'vite:import-glob': { isSubImportsPattern } },
    })) || glob,

Let's move this one to the 4.4 milestone, better to avoid merging just before the release.

patak-dev
patak-dev previously approved these changes Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

import.meta.glob doesn't respect "imports" field, but respects aliases
4 participants