feat: add perf benchmark check to mdx
This commit is contained in:
parent
e0a2146b2f
commit
f0135576af
1 changed files with 21 additions and 16 deletions
|
@ -24,6 +24,9 @@ import remarkPrism from './remark-prism.js';
|
||||||
import remarkShiki from './remark-shiki.js';
|
import remarkShiki from './remark-shiki.js';
|
||||||
import { isRelativePath, jsToTreeNode } from './utils.js';
|
import { isRelativePath, jsToTreeNode } from './utils.js';
|
||||||
|
|
||||||
|
// Skip nonessential plugins during performance benchmark runs
|
||||||
|
const isPerformanceBenchmark = Boolean(process.env.ASTRO_CI_PERFORMANCE_RUN);
|
||||||
|
|
||||||
export function recmaInjectImportMetaEnvPlugin({
|
export function recmaInjectImportMetaEnvPlugin({
|
||||||
importMetaEnv,
|
importMetaEnv,
|
||||||
}: {
|
}: {
|
||||||
|
@ -130,25 +133,28 @@ export async function getRemarkPlugins(
|
||||||
): Promise<MdxRollupPluginOptions['remarkPlugins']> {
|
): Promise<MdxRollupPluginOptions['remarkPlugins']> {
|
||||||
let remarkPlugins: PluggableList = [];
|
let remarkPlugins: PluggableList = [];
|
||||||
|
|
||||||
if (mdxOptions.gfm) {
|
if (!isPerformanceBenchmark) {
|
||||||
remarkPlugins.push(remarkGfm);
|
if (mdxOptions.gfm) {
|
||||||
}
|
remarkPlugins.push(remarkGfm);
|
||||||
if (mdxOptions.smartypants) {
|
}
|
||||||
remarkPlugins.push(remarkSmartypants);
|
if (mdxOptions.smartypants) {
|
||||||
|
remarkPlugins.push(remarkSmartypants);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
remarkPlugins = [...remarkPlugins, ...ignoreStringPlugins(mdxOptions.remarkPlugins)];
|
remarkPlugins = [...remarkPlugins, ...ignoreStringPlugins(mdxOptions.remarkPlugins)];
|
||||||
|
|
||||||
// Apply syntax highlighters after user plugins to match `markdown/remark` behavior
|
if (!isPerformanceBenchmark) {
|
||||||
if (mdxOptions.syntaxHighlight === 'shiki') {
|
// Apply syntax highlighters after user plugins to match `markdown/remark` behavior
|
||||||
remarkPlugins.push([await remarkShiki(mdxOptions.shikiConfig)]);
|
if (mdxOptions.syntaxHighlight === 'shiki') {
|
||||||
|
remarkPlugins.push([await remarkShiki(mdxOptions.shikiConfig)]);
|
||||||
|
}
|
||||||
|
if (mdxOptions.syntaxHighlight === 'prism') {
|
||||||
|
remarkPlugins.push(remarkPrism);
|
||||||
|
}
|
||||||
|
// Apply last in case user plugins resolve relative image paths
|
||||||
|
remarkPlugins.push(toRemarkContentRelImageError(config));
|
||||||
}
|
}
|
||||||
if (mdxOptions.syntaxHighlight === 'prism') {
|
|
||||||
remarkPlugins.push(remarkPrism);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply last in case user plugins resolve relative image paths
|
|
||||||
remarkPlugins.push(toRemarkContentRelImageError(config));
|
|
||||||
|
|
||||||
return remarkPlugins;
|
return remarkPlugins;
|
||||||
}
|
}
|
||||||
|
@ -166,8 +172,7 @@ export function getRehypePlugins(mdxOptions: MdxOptions): MdxRollupPluginOptions
|
||||||
...ignoreStringPlugins(mdxOptions.rehypePlugins),
|
...ignoreStringPlugins(mdxOptions.rehypePlugins),
|
||||||
// getHeadings() is guaranteed by TS, so this must be included.
|
// getHeadings() is guaranteed by TS, so this must be included.
|
||||||
// We run `rehypeHeadingIds` _last_ to respect any custom IDs set by user plugins.
|
// We run `rehypeHeadingIds` _last_ to respect any custom IDs set by user plugins.
|
||||||
rehypeHeadingIds,
|
...(isPerformanceBenchmark ? [] : [rehypeHeadingIds, rehypeInjectHeadingsExport]),
|
||||||
rehypeInjectHeadingsExport,
|
|
||||||
// computed from `astro.data.frontmatter` in VFile data
|
// computed from `astro.data.frontmatter` in VFile data
|
||||||
rehypeApplyFrontmatterExport,
|
rehypeApplyFrontmatterExport,
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in a new issue