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

Rework virtual files #363

Merged
merged 3 commits into from
Dec 11, 2023
Merged

Rework virtual files #363

merged 3 commits into from
Dec 11, 2023

Conversation

remcohaszing
Copy link
Member

Initial checklist

  • I read the support docs
  • I read the contributing guide
  • I agree to follow the code of conduct
  • I searched issues and couldn’t find anything (or linked relevant results below)
  • If applicable, I’ve added docs and tests

Description of changes

Before Volar, the ESM, JSX, and markdown parts of virtual files had to map character by character, with parts shadowed by whitespace characters. This was still how virtual files were built. However, because of how Volar mappings work, this is unnecessary.

This change overhauls how virtual files are generated. This leads to more flexibility of virtual files, meaning we can omit or inject content.

This is already leveraged in several ways:

  • Markdown nodes in MDX are represented by TypeScript fragments. This provides compatibility with JSX elements that require children on a type level.
  • Markdown text nodes in MDX are represented by TypeScript JSX expressions containing an empty string.
  • JavaScript chunks are represented in the virtual markdown files as HTML comments.

Before Volar, the ESM, JSX, and markdown parts of virtual files had to
map character by character, with parts shadowed by whitespace
characters. This was still how virtual files were built. However,
because of how Volar mappings work, this is unnecessary.

This change overhauls how virtual files are generated. This leads to
more flexibility of virtual files, meaning we can omit or inject
content.

This is already leveraged in several ways:

- Markdown nodes in MDX are represented by TypeScript fragments. This
  provides compatibility with JSX elements that require children on a
  type level.
- Markdown text nodes in MDX are represented by TypeScript JSX
  expressions containing an empty string.
- JavaScript chunks are represented in the virtual markdown files as
  HTML comments.
@remcohaszing remcohaszing added 🦋 type/enhancement This is great to have 🏡 area/internal This affects the hidden internals 👶 semver/patch This is a backwards-compatible fix 🤞 phase/open Post is being triaged manually labels Dec 11, 2023
Copy link

changeset-bot bot commented Dec 11, 2023

⚠️ No Changeset found

Latest commit: 8fb2583

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@remcohaszing remcohaszing merged commit 7c00fc3 into main Dec 11, 2023
8 checks passed
@remcohaszing remcohaszing deleted the optimize-virtual-files branch December 11, 2023 16:27

This comment has been minimized.

@remcohaszing remcohaszing added the 💪 phase/solved Post is done label Dec 11, 2023
@github-actions github-actions bot removed the 🤞 phase/open Post is being triaged manually label Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏡 area/internal This affects the hidden internals 💪 phase/solved Post is done 👶 semver/patch This is a backwards-compatible fix 🦋 type/enhancement This is great to have
Development

Successfully merging this pull request may close these issues.

1 participant