ProseMirror / prosemirror-markdown

ProseMirror Markdown integration
https://prosemirror.net
MIT License
344 stars 81 forks source link

Markdown-it import path does not align with current package #124

Closed rajsite closed 3 months ago

rajsite commented 3 months ago

The following Token import does not align with what is exported from markdown-it: https://github.com/ProseMirror/prosemirror-markdown/blob/e59521463f62b296cc072962aa2d60b267ea4397/src/from_markdown.ts#L3

This is not detected by TypeScript because the package is currently using v13 types with the v14 package.

The v14 package switched to esm exports, but did not define bare module paths. So if you clone this repo, update to the v14 types and look in vscode you get errors about the bare module import of Token not existing:

image

This caused an issue for us upstream as we tweak some MarkdownParser behavior so imported the v13 types and with an attempted upgrade of our types to v14 our TypeScript build was failing.

Because this is a type only import it seems to be safe to update the types to v14 and update the import to:

import type Token from "markdown-it/lib/token.mjs";

Which is elided from the cjs/js builds (the different cjs/mjs exports never include the type import) and it fixes the TypeScript issues.

marijnh commented 3 months ago

Thanks for spotting that. Attached patch upgrades the dependency. import type doesn't seem to be needed—TypeScript will automatically drop type-only imports from its build output.