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
fix: replace last 'export default MDXContent;' #2045
Conversation
🦋 Changeset detectedLatest commit: 8994d24 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
@soata is attempting to deploy a commit to the Vercel Team on Vercel. A member of the Team first needs to authorize it. |
packages/nextra/src/loader.ts
Outdated
${finalResult.replace('export default MDXContent;', '')} | ||
${finalResult.replace(/(export default MDXContent;).*$/, '$1')} |
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.
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.
Thank you for the review.
I apologize for pushing the wrong regex code.
What I intended was
${finalResult.replace(/export default MDXContent;(.*)$/, '$1')}
I used regex to minimize the changes, but I'll think about using String#lastIndexOf
.
could You add also a helpful comment in code why we did it and could you add changeset with patch?
I'll try it later!
Co-authored-by: Dimitri POSTOLOV <dmytropostolov@gmail.com>
Fix to replace the last 'export default MDXContent;' instead of the first one.
If .mdx file contains a string that exactly matches 'export default MDXContent;', the certain export is not removed and it will result in an error.