Minimal setup (because by default v6 is +50kb compared to v5)

Is there a way to have a minimal setup, because switching to v6 has increased the total bundle size by 50kB (total is now 850kB)

Maybe it’s possible to replace basicSetup and ‘codemirror’ dependency by other things and lower the size.

I don’t need features like autocompletion, if that can help

If not, it’s not much an issue, no worry

import { useEffect, useState, useRef } from 'react';
import { basicSetup } from 'codemirror';
import { EditorView, keymap } from '@codemirror/view';
import { indentWithTab } from '@codemirror/commands';


function Editor({ value, onChange, placeholder, ...props }) {
  const ref = useRef();

  useEffect(() => {
    new EditorView({
      doc: value || placeholder,
      extensions: [
        basicSetup,
        EditorView.lineWrapping,
        keymap.of([indentWithTab]),
        EditorView.updateListener.of(({ state }) => {
          onChange(state.doc.text?.join('\n'));
        }),
        // + possibly javascript() or markdown() extensions
      ],
      parent: ref.current
    });
  }, []);

  return <div ref={ref} {...props} />;
}

Ok following CodeMirror 5 to 6 Migration Guide I saved 25kB (demo: https://codesandbox.io/s/codemirror6-t9ywwc)

Solved