Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in-range breaking change with @codemirror/state #1520

Open
trusktr opened this issue Feb 9, 2025 · 2 comments
Open

in-range breaking change with @codemirror/state #1520

trusktr opened this issue Feb 9, 2025 · 2 comments

Comments

@trusktr
Copy link

trusktr commented Feb 9, 2025

Describe the issue

Here's a currently working example, where I use my <code-mirror> HTML element inside of a <live-code> HTML element to make my static HTML pages live-editable:

https://github.com/trusktr/trusktr/blob/44151b83f8cd8d9759f14391f59290470798ec47/index.html

The importmap.js has the CodeMirror dependencies:

https://github.com/trusktr/trusktr/blob/44151b83f8cd8d9759f14391f59290470798ec47/importmap.js

If we update @codemirror/state from 6.4.1 to 6.5.2, the app will break with this error:

Uncaught TypeError: Failed to resolve module specifier "@marijn/find-cluster-break".

This is not a breaking change with the API, but if change the URL from this pinned version,

https://cdn.jsdelivr.net/npm/@codemirror/[email protected]/dist/index.js

to one that has a semver version range,

https://cdn.jsdelivr.net/npm/@codemirror/state@^6.4.1/dist/index.js

then it will automatically get the latest "compatible" in-range version, https://cdn.jsdelivr.net/npm/@codemirror/[email protected]/dist/index.js at time of writing, which currently adds the new import of a missing dependency,

import { findClusterBreak as findClusterBreak$1 } from '@marijn/find-cluster-break';

I think this might be something we have to consider in the age of import maps with semver CDN URLs. It is now something I have to try to remember for my libs too, as I strongly engourage people to use versions in import map CDN URLs, and don't want them to have broken apps if they use a compatible range such as ^ which is supposed to pull the latest non-breaking version.

Browser and platform

No response

Reproduction link

No response

@trusktr
Copy link
Author

trusktr commented Feb 9, 2025

For fun, here's a version that is updated to work via raw.githack.com and has an updated importmap, so the example can be viewed live in your browser:

https://rawcdn.githack.com/trusktr/trusktr/5056cefe67fba007cbf3c9a2e927d404edca5797/index.html

@marijnh
Copy link
Member

marijnh commented Feb 10, 2025

find-cluster-break is a new dependency of @codemirror/state, since 6.5.0. It is properly declared in package.json, so if your setup isn't installing it that would be an issue with your CDN or your use of it.

@codemirror codemirror deleted a comment from tchiefin666 Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants