From 27c6e01826a6da525f1f811d97784accd1ebbd96 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Wed, 24 May 2023 17:02:04 +0800 Subject: [PATCH] Remove `@mdx-js/rollup` dependency (#7191) --- .changeset/spotty-glasses-return.md | 5 +++++ packages/integrations/mdx/package.json | 1 - packages/integrations/mdx/src/index.ts | 7 +++---- packages/integrations/mdx/src/plugins.ts | 5 ++--- pnpm-lock.yaml | 19 ------------------- 5 files changed, 10 insertions(+), 27 deletions(-) create mode 100644 .changeset/spotty-glasses-return.md diff --git a/.changeset/spotty-glasses-return.md b/.changeset/spotty-glasses-return.md new file mode 100644 index 0000000000..6786f77ebf --- /dev/null +++ b/.changeset/spotty-glasses-return.md @@ -0,0 +1,5 @@ +--- +'@astrojs/mdx': patch +--- + +Remove `@mdx-js/rollup` dependency diff --git a/packages/integrations/mdx/package.json b/packages/integrations/mdx/package.json index 4e06bea89e..63d520cb13 100644 --- a/packages/integrations/mdx/package.json +++ b/packages/integrations/mdx/package.json @@ -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", diff --git a/packages/integrations/mdx/src/index.ts b/packages/integrations/mdx/src/index.ts index 2ccf662665..3e1f84c0a3 100644 --- a/packages/integrations/mdx/src/index.ts +++ b/packages/integrations/mdx/src/index.ts @@ -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'; @@ -67,7 +66,7 @@ export default function mdx(partialMdxOptions: Partial = {}): AstroI ), }); - const mdxPluginOpts: MdxRollupPluginOptions = { + const mdxPluginOpts: CompileOptions = { remarkPlugins: await getRemarkPlugins(mdxOptions, config), rehypePlugins: getRehypePlugins(mdxOptions), recmaPlugins: mdxOptions.recmaPlugins, @@ -87,8 +86,8 @@ export default function mdx(partialMdxOptions: Partial = {}): AstroI vite: { plugins: [ { + name: '@mdx-js/rollup', enforce: 'pre', - ...mdxPlugin(mdxPluginOpts), configResolved(resolved) { importMetaEnv = { ...importMetaEnv, ...resolved.env }; }, diff --git a/packages/integrations/mdx/src/plugins.ts b/packages/integrations/mdx/src/plugins.ts index 859cf3bbea..af99504516 100644 --- a/packages/integrations/mdx/src/plugins.ts +++ b/packages/integrations/mdx/src/plugins.ts @@ -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'; @@ -99,7 +98,7 @@ export function rehypeApplyFrontmatterExport() { export async function getRemarkPlugins( mdxOptions: MdxOptions, config: AstroConfig -): Promise { +): Promise { let remarkPlugins: PluggableList = [ ...(config.experimental.assets ? [remarkCollectImages, remarkImageToComponent] : []), ]; @@ -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, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index df4ad8e2bd..f91304cf45 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4125,9 +4125,6 @@ importers: '@mdx-js/mdx': specifier: ^2.3.0 version: 2.3.0 - '@mdx-js/rollup': - specifier: ^2.3.0 - version: 2.3.0 acorn: specifier: ^8.8.0 version: 8.8.2 @@ -8089,22 +8086,6 @@ packages: - supports-color dev: false - /@mdx-js/rollup@2.3.0: - resolution: {integrity: sha512-wLvRfJS/M4UmdqTd+WoaySEE7q4BIejYf1xAHXYvtT1du/1Tl/z2450Gg2+Hu7fh05KwRRiehiTP9Yc/Dtn0fA==} - peerDependencies: - rollup: '>=2' - peerDependenciesMeta: - rollup: - optional: true - dependencies: - '@mdx-js/mdx': 2.3.0 - '@rollup/pluginutils': 5.0.2(rollup@3.20.1) - source-map: 0.7.4 - vfile: 5.3.2 - transitivePeerDependencies: - - supports-color - dev: false - /@miniflare/cache@2.14.0: resolution: {integrity: sha512-0mz0OCzTegiX75uMURLJpDo3DaOCSx9M0gv7NMFWDbK/XrvjoENiBZiKu98UBM5fts0qtK19a+MfB4aT0uBCFg==} engines: {node: '>=16.13'}