-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
1 changed file
with
7 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,9 @@ import {searchKeymap, highlightSelectionMatches} from "@codemirror/search" | |
import {autocompletion, completionKeymap, closeBrackets, closeBracketsKeymap} from "@codemirror/autocomplete" | ||
import {lintKeymap} from "@codemirror/lint" | ||
|
||
// (The superfluous function calls around the list of extensions work | ||
// around current limitations in tree-shaking software.) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
marijnh
Author
Member
|
||
|
||
/// This is an extension value that just pulls together a number of | ||
/// extensions that you might want in a basic editor. It is meant as a | ||
/// convenient helper to quickly set up CodeMirror without installing | ||
|
@@ -44,7 +47,7 @@ import {lintKeymap} from "@codemirror/lint" | |
/// you take this package's source (which is just a bunch of imports | ||
/// and an array literal), copy it into your own code, and adjust it | ||
/// as desired. | ||
export const basicSetup: Extension = [ | ||
export const basicSetup: Extension = (() => [ | ||
lineNumbers(), | ||
highlightActiveLineGutter(), | ||
highlightSpecialChars(), | ||
|
@@ -71,15 +74,15 @@ export const basicSetup: Extension = [ | |
...completionKeymap, | ||
...lintKeymap | ||
]) | ||
] | ||
])() | ||
|
||
/// A minimal set of extensions to create a functional editor. Only | ||
/// includes [the default keymap](#commands.defaultKeymap), [undo | ||
/// history](#commands.history), [special character | ||
/// highlighting](#view.highlightSpecialChars), [custom selection | ||
/// drawing](#view.drawSelection), and [default highlight | ||
/// style](#language.defaultHighlightStyle). | ||
export const minimalSetup: Extension = [ | ||
export const minimalSetup: Extension = (() => [ | ||
highlightSpecialChars(), | ||
history(), | ||
drawSelection(), | ||
|
@@ -88,6 +91,6 @@ export const minimalSetup: Extension = [ | |
...defaultKeymap, | ||
...historyKeymap, | ||
]) | ||
] | ||
])() | ||
|
||
export {EditorView} from "@codemirror/view" |
Thanks for this comment. Is there a bug or pending feature this refers to ? Or was it a quick fix where you didn't dig into the specifics.
I ask because I'd like to understand in case I encounter it in the future