Skip to content

fix: include vite/types/* in exports field#14296

Merged
sapphi-red merged 1 commit intovitejs:mainfrom
yuheiy:export-vite-types
Sep 6, 2023
Merged

fix: include vite/types/* in exports field#14296
sapphi-red merged 1 commit intovitejs:mainfrom
yuheiy:export-vite-types

Conversation

@yuheiy
Copy link
Copy Markdown
Contributor

@yuheiy yuheiy commented Sep 5, 2023

Description

This PR exports the files under vite/types/*. This makes internal type definitions available for external reference.

Additional context

In Astro, we are referencing files within the types directory to provide users with type information like ViteHotContext and ImportGlobFunction.

https://github.com/withastro/astro/blob/b6066e109c5807f16dd81e07c81f300459e12897/packages/astro/import-meta.d.ts#L12-L20

However, these are not defined in exports field in Vite's package.json. As a result, when running tsc to check the contents of import-meta.d.ts, an error occurs. To resolve this, we need to extend the exports field in Vite's package.json.

ref:

withastro/astro#8360 (comment)


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.

@bolt-new-by-stackblitz
Copy link
Copy Markdown

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

Copy link
Copy Markdown
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.

This sounds good to me. Presumably we only document /// <reference types="vite/types/importMeta" /> and that bypasses the exports which made it work.

Note though that this change is going into Vite 5. And Vite 5 should also include #14279 which fixes the core issue in Astro in the first place that needed to import the vite/types/*. Unless we backport this to Vite 4.

Comment thread packages/vite/package.json Outdated
@sapphi-red sapphi-red changed the title feat: export vite/types/* fix: include vite/types/* in exports field Sep 6, 2023
@sapphi-red sapphi-red added the p3-minor-bug An edge case that only affects very specific usage (priority) label Sep 6, 2023
@sapphi-red sapphi-red merged commit 66a97be into vitejs:main Sep 6, 2023
Gaubee pushed a commit to Gaubee/vite that referenced this pull request Sep 13, 2023
bluwy pushed a commit that referenced this pull request Oct 3, 2023
@bluwy bluwy mentioned this pull request Oct 3, 2023
bluwy pushed a commit that referenced this pull request Oct 3, 2023
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.

3 participants