lezer-parser/javascript

Yarn PnP ambiguous import of @lezer/common

jakzo opened this issue · 3 comments

jakzo commented

Yarn in PnP mode complains when using this package (and I assume any of the other language packages) with this message:

@lezer/javascript tried to access @lezer/common, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

I think this is because an import of @lezer/common exists in the generated code but its version is not specified in the package.json, meaning it is unclear which version to use if there happen to be multiple versions of @lezer/common in the dependency tree.

Oh, that's annoying. I think the least intrusive way to address it is to set things up so that the output of lezer-generator doesn't directly need to import from common, but that'd involve a breaking change, so it will have to wait until the next breaking release.

Looks like this makes a bug in codemirror 6.
I cant import codemirror through skypack CDN.

await import('https://cdn.skypack.dev/@codemirror/lang-javascript')
common?from=@lezer/javascript:14
Uncaught Error: [Package Error] "@lezer/common" no dependency version info found. (Imported by "@lezer/javascript").

in @lezer/javascript

/*
 * [Package Error] "@lezer/common" no dependency version info found. (Imported by "@lezer/javascript").
 *
 * The package "@lezer/javascript" depends on "@lezer/common" as a dependency,
 * but did not list any dependency version info in its package manifest.
 * Without this information, the CDN is unable to properly resolve this import.
 *
 * How to fix:
 *   - Let the "@lezer/javascript" package author know that "@lezer/common" needs to be included in their package.json manifest.
 *   - Use https://skypack.dev/ to find a web-friendly alternative to find another package.
 */

throw new Error("[Package Error] \"@lezer/common\" no dependency version info found. (Imported by \"@lezer/javascript\").");
export default null;

When using jsDelivr CDN, jsDelivr resolves it but throws another codemirror related error.

Uncaught Error: Unrecognized extension value in extension set ([object Object]). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.

Looks crazy.

@marijnh

same error.
Why not add dependencies.