Skip to content
This repository was archived by the owner on Apr 15, 2026. It is now read-only.

Commit 49e3909

Browse files
committed
Use a kludge to improve tree-shaking of extension sets
FIX: Work around limitations in tree-shaking software that prevented `basicSetup` from being removed when unused.
1 parent 4b83cb1 commit 49e3909

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/codemirror.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import {searchKeymap, highlightSelectionMatches} from "@codemirror/search"
99
import {autocompletion, completionKeymap, closeBrackets, closeBracketsKeymap} from "@codemirror/autocomplete"
1010
import {lintKeymap} from "@codemirror/lint"
1111

12+
// (The superfluous function calls around the list of extensions work
13+
// around current limitations in tree-shaking software.)
14+
1215
/// This is an extension value that just pulls together a number of
1316
/// extensions that you might want in a basic editor. It is meant as a
1417
/// convenient helper to quickly set up CodeMirror without installing
@@ -44,7 +47,7 @@ import {lintKeymap} from "@codemirror/lint"
4447
/// you take this package's source (which is just a bunch of imports
4548
/// and an array literal), copy it into your own code, and adjust it
4649
/// as desired.
47-
export const basicSetup: Extension = [
50+
export const basicSetup: Extension = (() => [
4851
lineNumbers(),
4952
highlightActiveLineGutter(),
5053
highlightSpecialChars(),
@@ -71,15 +74,15 @@ export const basicSetup: Extension = [
7174
...completionKeymap,
7275
...lintKeymap
7376
])
74-
]
77+
])()
7578

7679
/// A minimal set of extensions to create a functional editor. Only
7780
/// includes [the default keymap](#commands.defaultKeymap), [undo
7881
/// history](#commands.history), [special character
7982
/// highlighting](#view.highlightSpecialChars), [custom selection
8083
/// drawing](#view.drawSelection), and [default highlight
8184
/// style](#language.defaultHighlightStyle).
82-
export const minimalSetup: Extension = [
85+
export const minimalSetup: Extension = (() => [
8386
highlightSpecialChars(),
8487
history(),
8588
drawSelection(),
@@ -88,6 +91,6 @@ export const minimalSetup: Extension = [
8891
...defaultKeymap,
8992
...historyKeymap,
9093
])
91-
]
94+
])()
9295

9396
export {EditorView} from "@codemirror/view"

0 commit comments

Comments
 (0)