-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Handle query parameters in Vite #2629
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
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2629 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 21 21
Lines 2650 2650
Branches 2 2
=========================================
Hits 2650 2650 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I have one comment.
packages/rollup/lib/index.js
Outdated
@@ -79,22 +82,20 @@ export function rollup(options) { | |||
development: env.mode === 'development', | |||
...rest | |||
}) | |||
extnameRegex = extnamesToRegex(formatAwareProcessors.extnames) | |||
}, | |||
async transform(value, path) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently this path
variable is not really a path. Instead, it’s an ID (constructed from the path). It may contain query parameters.
I think the proper fix would be to rename this variable to id
(including in the types). Then construct the path using:
const [path] = id.split('?')
The main difference is that remark/rehype/recma plugins also have access to the VFile. It’s important that it has the correct data.
@remcohaszing Thanks for the feedback. I've just pushed an update. |
This comment has been minimized.
This comment has been minimized.
Cool, thanks! |
Initial checklist
Description of changes
This fixes an issue where MDX imports with query parameters aren't picked up by the Rollup plugin in Vite. To fix this, this PR uses the
extnamesToRegex
util to create a regular expression for matching MDX extensions, and this util already handles the existence of query parameters correctly.I ran into this in the context of React Router where I'm working on RSC support for Framework Mode which uses Vite. We're using query parameters to transform client and server versions of route files, but this approach means that MDX routes are no longer working since the query parameters cause the MDX plugin to skip over them.