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

Move MDX plugin re-ordering hack to MDX integration #7872

Merged
merged 2 commits into from
Jul 31, 2023
Merged

Move MDX plugin re-ordering hack to MDX integration #7872

merged 2 commits into from
Jul 31, 2023

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Jul 31, 2023

Changes

... instead of doing it in Astro core.

Testing

Existing tests should pass. However, next might need to merge up main changes for the recent fixes to the MDX fails.

Docs

n/a. This change should not be visible as long as they upgrade Astro core and MDX integration to latest

@changeset-bot
Copy link

changeset-bot bot commented Jul 31, 2023

🦋 Changeset detected

Latest commit: ea61231

The changes in this PR will be included in the next version bump.

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

@github-actions github-actions bot added pkg: integration Related to any renderer integration (scope) pkg: astro Related to the core `astro` package (scope) labels Jul 31, 2023
@ematipico
Copy link
Member

ematipico commented Jul 31, 2023

n/a. This change should not be visible as long as they upgrade Astro core and MDX integration to latest

Maybe we should enforce this via package.json using peerDependencies, inside the MDX integration?

@ematipico ematipico requested a review from a team as a code owner July 31, 2023 11:00
@bluwy
Copy link
Member Author

bluwy commented Jul 31, 2023

Good call, looks like most other integrations has the peer dep, will add it for MDX too.

Comment on lines +99 to +112
// HACK: move ourselves before Astro's JSX plugin to transform things in the right order
const jsxPluginIndex = resolved.plugins.findIndex((p) => p.name === 'astro:jsx');
if (jsxPluginIndex !== -1) {
const myPluginIndex = resolved.plugins.findIndex(
(p) => p.name === '@mdx-js/rollup'
);
if (myPluginIndex !== -1) {
const myPlugin = resolved.plugins[myPluginIndex];
// @ts-ignore-error ignore readonly annotation
resolved.plugins.splice(myPluginIndex, 1);
// @ts-ignore-error ignore readonly annotation
resolved.plugins.splice(jsxPluginIndex, 0, myPlugin);
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Left a question, not a blocker :)

@@ -53,6 +53,9 @@
"unist-util-visit": "^4.1.2",
"vfile": "^5.3.7"
},
"peerDependencies": {
"astro": "workspace:^2.9.6"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this become 3.0.0 before the release?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think changesets or pnpm will bump that before the release. We should definitely check our existing integrations also have that bumped before the initial release too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope) pkg: integration Related to any renderer integration (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants