Milkdown / milkdown

🍼 Plugin driven WYSIWYG markdown editor framework.
https://milkdown.dev
MIT License
8.97k stars 411 forks source link

[Bug] How to reduce Crepe bundle size? #1533

Open sindras opened 1 month ago

sindras commented 1 month ago

Initial checklist

Affected packages and versions

Crepe

Link to runnable example

https://stackblitz.com/edit/github-gpc2xr

Steps to reproduce

To reproduce:

  1. Create a Vite-based React project.
  2. Create an editor with milkdown-crepe. Disable the CodeMirror.
  3. Try building the assets vite build, notice that all CodeMirror languages are still bundled in the output.

Expected behavior

The unused features should be dropped from final output. Or, create a more reasonable defaults by limiting the number of CodeMirror supported languages to popular ones such as HTML, CSS, JS, Python, C++, PHP, Java, SQL, etc instead of including Brainfuck?

Actual behavior

All language and CodeMirror specific code are still bundled together after running vite build, under the dist/assets folder.

Runtime

No response

OS

No response

Build and bundle tools

Remix

seangwright commented 4 weeks ago

I would love to know how to tree-shake out all those unused languages. Even when I supply an explicit list, the full set ends up in my bundle. I think it could be caused by this dynamic import