perf(mdx-loader): cache mdx/remark compiler instances (#4997)

* (mdx-loader) only create mdx compiler once per webpack config

* type fixes

* fix path

* remove assertion

* docs: add missing Tab/TabItem imports

* fixup

Co-authored-by: slorber <lorber.sebastien@gmail.com>
Co-authored-by: Josh-Cena <sidachen2003@gmail.com>
This commit is contained in:
Lenz Weber-Tronic 2022-03-31 09:42:57 +02:00 committed by GitHub
parent bb55586c20
commit 949a72e6a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 61 additions and 45 deletions

View file

@ -10,19 +10,17 @@ declare module '@mdx-js/mdx' {
import type {Processor} from 'unified';
import type {RemarkOrRehypePlugin} from '@docusaurus/mdx-loader';
namespace mdx {
interface Options {
filepath?: string;
skipExport?: boolean;
wrapExport?: string;
remarkPlugins?: RemarkOrRehypePlugin[];
rehypePlugins?: RemarkOrRehypePlugin[];
}
function sync(content: string, options?: Options): string;
function createMdxAstCompiler(options?: Options): Processor;
function createCompiler(options?: Options): Processor;
export interface Options {
filepath?: string;
skipExport?: boolean;
wrapExport?: string;
remarkPlugins?: RemarkOrRehypePlugin[];
rehypePlugins?: RemarkOrRehypePlugin[];
}
export function sync(content: string, options?: Options): string;
export function createMdxAstCompiler(options?: Options): Processor;
export function createCompiler(options?: Options): Processor;
export default function mdx(
content: string,
options?: mdx.Options,