Skip to content

Commit

Permalink
Remove unnecessary recmaInjectImportMetaEnv plugin for MDX (#10673)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy authored Apr 4, 2024
1 parent 0899d34 commit db7f9c8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 76 deletions.
5 changes: 5 additions & 0 deletions .changeset/sharp-socks-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@astrojs/mdx": patch
---

Removes unnecessary internal `recmaInjectImportMetaEnv` plugin
1 change: 0 additions & 1 deletion packages/integrations/mdx/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ export default function mdx(partialMdxOptions: Partial<MdxOptions> = {}): AstroI
configResolved(resolved) {
processor = createMdxProcessor(mdxOptions, {
sourcemap: !!resolved.build.sourcemap,
importMetaEnv: { SITE: config.site, ...resolved.env },
});

// HACK: move ourselves before Astro's JSX plugin to transform things in the right order
Expand Down
11 changes: 1 addition & 10 deletions packages/integrations/mdx/src/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import remarkSmartypants from 'remark-smartypants';
import { SourceMapGenerator } from 'source-map';
import type { PluggableList } from 'unified';
import type { MdxOptions } from './index.js';
import { recmaInjectImportMetaEnv } from './recma-inject-import-meta-env.js';
import { rehypeApplyFrontmatterExport } from './rehype-apply-frontmatter-export.js';
import { rehypeInjectHeadingsExport } from './rehype-collect-headings.js';
import rehypeMetaString from './rehype-meta-string.js';
Expand All @@ -23,14 +22,13 @@ const isPerformanceBenchmark = Boolean(process.env.ASTRO_PERFORMANCE_BENCHMARK);

interface MdxProcessorExtraOptions {
sourcemap: boolean;
importMetaEnv: Record<string, any>;
}

export function createMdxProcessor(mdxOptions: MdxOptions, extraOptions: MdxProcessorExtraOptions) {
return createProcessor({
remarkPlugins: getRemarkPlugins(mdxOptions),
rehypePlugins: getRehypePlugins(mdxOptions),
recmaPlugins: getRecmaPlugins(mdxOptions, extraOptions.importMetaEnv),
recmaPlugins: mdxOptions.recmaPlugins,
remarkRehypeOptions: mdxOptions.remarkRehype,
jsx: true,
jsxImportSource: 'astro',
Expand Down Expand Up @@ -95,10 +93,3 @@ function getRehypePlugins(mdxOptions: MdxOptions): PluggableList {

return rehypePlugins;
}

function getRecmaPlugins(
mdxOptions: MdxOptions,
importMetaEnv: Record<string, any>
): PluggableList {
return [...(mdxOptions.recmaPlugins ?? []), [recmaInjectImportMetaEnv, { importMetaEnv }]];
}
65 changes: 0 additions & 65 deletions packages/integrations/mdx/src/recma-inject-import-meta-env.ts

This file was deleted.

0 comments on commit db7f9c8

Please sign in to comment.