Skip to content

Commit

Permalink
Remove @mdx-js/rollup dependency (#7191)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy authored May 24, 2023
1 parent 2bda7fb commit 27c6e01
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 27 deletions.
5 changes: 5 additions & 0 deletions .changeset/spotty-glasses-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/mdx': patch
---

Remove `@mdx-js/rollup` dependency
1 change: 0 additions & 1 deletion packages/integrations/mdx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"@astrojs/markdown-remark": "^2.2.1",
"@astrojs/prism": "^2.1.2",
"@mdx-js/mdx": "^2.3.0",
"@mdx-js/rollup": "^2.3.0",
"acorn": "^8.8.0",
"es-module-lexer": "^1.1.1",
"estree-util-visit": "^1.2.0",
Expand Down
7 changes: 3 additions & 4 deletions packages/integrations/mdx/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { markdownConfigDefaults } from '@astrojs/markdown-remark';
import { toRemarkInitializeAstroData } from '@astrojs/markdown-remark/dist/internal.js';
import { compile as mdxCompile } from '@mdx-js/mdx';
import { compile as mdxCompile, type CompileOptions } from '@mdx-js/mdx';
import type { PluggableList } from '@mdx-js/mdx/lib/core.js';
import mdxPlugin, { type Options as MdxRollupPluginOptions } from '@mdx-js/rollup';
import type { AstroIntegration, ContentEntryType, HookParameters } from 'astro';
import { parse as parseESM } from 'es-module-lexer';
import fs from 'node:fs/promises';
Expand Down Expand Up @@ -67,7 +66,7 @@ export default function mdx(partialMdxOptions: Partial<MdxOptions> = {}): AstroI
),
});

const mdxPluginOpts: MdxRollupPluginOptions = {
const mdxPluginOpts: CompileOptions = {
remarkPlugins: await getRemarkPlugins(mdxOptions, config),
rehypePlugins: getRehypePlugins(mdxOptions),
recmaPlugins: mdxOptions.recmaPlugins,
Expand All @@ -87,8 +86,8 @@ export default function mdx(partialMdxOptions: Partial<MdxOptions> = {}): AstroI
vite: {
plugins: [
{
name: '@mdx-js/rollup',
enforce: 'pre',
...mdxPlugin(mdxPluginOpts),
configResolved(resolved) {
importMetaEnv = { ...importMetaEnv, ...resolved.env };
},
Expand Down
5 changes: 2 additions & 3 deletions packages/integrations/mdx/src/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
} from '@astrojs/markdown-remark/dist/internal.js';
import { nodeTypes } from '@mdx-js/mdx';
import type { PluggableList } from '@mdx-js/mdx/lib/core.js';
import type { Options as MdxRollupPluginOptions } from '@mdx-js/rollup';
import type { AstroConfig } from 'astro';
import type { Literal, MemberExpression } from 'estree';
import { visit as estreeVisit } from 'estree-util-visit';
Expand Down Expand Up @@ -99,7 +98,7 @@ export function rehypeApplyFrontmatterExport() {
export async function getRemarkPlugins(
mdxOptions: MdxOptions,
config: AstroConfig
): Promise<MdxRollupPluginOptions['remarkPlugins']> {
): Promise<PluggableList> {
let remarkPlugins: PluggableList = [
...(config.experimental.assets ? [remarkCollectImages, remarkImageToComponent] : []),
];
Expand Down Expand Up @@ -128,7 +127,7 @@ export async function getRemarkPlugins(
return remarkPlugins;
}

export function getRehypePlugins(mdxOptions: MdxOptions): MdxRollupPluginOptions['rehypePlugins'] {
export function getRehypePlugins(mdxOptions: MdxOptions): PluggableList {
let rehypePlugins: PluggableList = [
// ensure `data.meta` is preserved in `properties.metastring` for rehype syntax highlighters
rehypeMetaString,
Expand Down
19 changes: 0 additions & 19 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 27c6e01

Please sign in to comment.