Extension needs to be declared as a type import #2

Closed
NullVoxPopuli wants to merge 1 commit from patch-1 into main
NullVoxPopuli commented 2022-07-13 03:52:41 +02:00 (Migrated from github.com)

Without this, the build will include Extension in the output, which, when used with esm.run (or any other CDN), this theme loads a separate copy of @codemirror/state, which gets the error about instanceof checks with multiple states loaded.

In general, type imports are a good signal to the compiler for stripping imports out during builds and help out humans know what the intend of imports are 🥳

Here is a reproduction of the problem being fixed: https://jsbin.com/sacumiraju/1/edit?html,output (currently only works in chrome due to import map support)

Without this, the build will include `Extension` in the output, which, when used with esm.run (or any other CDN), this theme loads a separate copy of `@codemirror/state`, which gets the error about instanceof checks with multiple states loaded. In general, type imports are a good signal to the compiler for stripping imports out during builds _and_ help out humans know what the intend of imports are :partying_face: Here is a reproduction of the problem being fixed: https://jsbin.com/sacumiraju/1/edit?html,output (currently only works in chrome due to import map support)
marijnh commented 2022-07-13 19:51:36 +02:00 (Migrated from github.com)

Extension is already not imported in dist/index.js, so this definitely won't help with loading a different copy of @codemirror/state (that happens through the import from @codemirror/view). Code style for this project is to just import things, regardless of whether they are type or other imports, and I don't see a compelling reason to change that.

`Extension` is already not imported in `dist/index.js`, so this definitely won't help with loading a different copy of @codemirror/state (that happens through the import from @codemirror/view). Code style for this project is to just import things, regardless of whether they are type or other imports, and I don't see a compelling reason to change that.
NullVoxPopuli commented 2022-07-13 20:19:13 +02:00 (Migrated from github.com)

hmm -- how do we get codemirror to work via ESM CDNs?

hmm -- how do we get codemirror to work via ESM CDNs?
marijnh commented 2022-07-13 20:39:13 +02:00 (Migrated from github.com)

Until they figure out how to properly deduplicate modules, you can't.

Until they figure out how to properly deduplicate modules, you can't.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
codemirror/theme-one-dark!2
No description provided.