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

Refactor MDX postprocess plugin #10832

Merged
merged 1 commit into from
Apr 22, 2024
Merged

Refactor MDX postprocess plugin #10832

merged 1 commit into from
Apr 22, 2024

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Apr 21, 2024

Changes

Refactor the @astrojs/mdx-postprocess Vite plugin to its own file and separate its inner content to functions. This makes the code a bit more readable, and prepares for some upcoming changes I'd like to add to this plugin.

I had a few iterations of this refactor locally. Initially using MagicString so that we can prepend strings with sourcemap intact, however I noticed it has a significant perf impact, so I switched back to plain strings. Here's the Rollup build time of the Astro docs.

  • Main: 113s
  • MagicString w/ sourcemap: 132s
  • MagicString w/o sourcemap: 111s
  • Plain strings (this PR): 110s

Testing

Existing tests should pass.

Docs

Internal refactor. No changeset.

Copy link

changeset-bot bot commented Apr 21, 2024

⚠️ No Changeset found

Latest commit: cbe9122

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.

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

@github-actions github-actions bot added the pkg: integration Related to any renderer integration (scope) label Apr 21, 2024
@ematipico
Copy link
Member

ematipico commented Apr 22, 2024

I don't understand. Does this PR move code, or does it change too? If it does change the code, could you please tell us where the changes are? Since you moved the file, it's very difficult to view the change in logic

@bluwy
Copy link
Member Author

bluwy commented Apr 22, 2024

It only moves the code. There shouldn't be any logic change, other than how it updates the code string in the transform hook.

@ematipico
Copy link
Member

Thank you, I was confused by the perf comparison

@bluwy
Copy link
Member Author

bluwy commented Apr 22, 2024

Ah yeah it was to show there's no perf regressions 😅

@bluwy bluwy merged commit 2f4d627 into main Apr 22, 2024
13 checks passed
@bluwy bluwy deleted the mdx-postprocess-refactor branch April 22, 2024 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: integration Related to any renderer integration (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants