-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cache MDX compiler in the Webpack loader #1468
Conversation
A new MDX compiler was created for every file that’s processed. This means that any initialization logic in remark or rehype plugins was always run for every file. By reusing the MDX compiler, remark and rehype plugins can run heavy setup logic once, just like when they are called by unified directly.
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/mdx/mdx/98pc7aCniJSuaojuJsD8ikpgZopW |
@wooorm has this caching system been removed in v2? I don't see it anymore here: https://github.com/mdx-js/mdx/blob/main/packages/loader/lib/index.js |
I believe xdm was fast enough, it does a lot less work. Do you need it then? |
The main issue isn’t the MDX compiler, but the plugins that may be slow. Specifically Personally I haven’t been affected by this issue lately, because I disabled |
Oh right. This was around the xdm time, I believe the plan was to land it there too but it never did? |
Related-to: mdx-js/mdx#1468.
Related-to: mdx-js/mdx#1468.
Backports: wooorm/xdm@decafe9. Related-to: GH-1468.
Backports: wooorm/xdm@decafe9. Related-to: GH-1468.
added again! |
Related-to: GH-1468. Related-to: GH-1912. Reviewed-by: Remco Haszing <[email protected]> Reviewed-by: Christian Murphy <[email protected]>
A new MDX compiler was created for every file that’s processed. This means that any initialization logic in remark or rehype plugins was always run for every file.
By reusing the MDX compiler, remark and rehype plugins can run heavy setup logic once, just like when they are called by unified directly.
In practice I use this in remark-mermaidjs. This starts a browser once to process a bunch of files, but it requires the same unified processor to run to be able to do so.
The same principle is used in ts-loader to cache the TypeScript compiler.