Skip to content

@codemirror/language-data creates 100+ unnecessary chunks when code plugins are not used #895

@greg-betterreports

Description

@greg-betterreports

I've noticed that MDXEditor includes @codemirror/language-data as a dependency, which causes bundlers to generate 100+ lazy-loaded language chunks even when codeBlockPlugin and codeMirrorPlugin are not used. We are not using any of these feature as we just want basic formattting.

Impact:

  • Before MDXEditor: 14 lazy chunks
  • After MDXEditor: 150+ lazy chunks (python, sql, css, ruby, perl, etc.)
  • Initial bundle only increased by ~10 kB, but deployment now has 136 extra files

Reproduction
My imports (no code plugins):

import {
    MDXEditor,
    headingsPlugin,
    toolbarPlugin,
    BlockTypeSelect,
} from '@mdxeditor/editor';

Build result:

chunk-CWTJBLNK.js     | python    |   6.53 kB
chunk-SMLDLULW.js     | sql       |  37.15 kB
chunk-5K5AGJRX.js     | css       |  27.25 kB
... (100+ more language files)

Would there be a way to not include those chunks if we don't use the code plugin ?

Thank you !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions