excalidraw / mermaid-to-excalidraw

Generate Excalidraw diagrams from Mermaid
https://mermaid-to-excalidraw.vercel.app
MIT License
265 stars 46 forks source link

fix: support module resolution nodenext so type module works in host #30

Closed ad1992 closed 1 year ago

ad1992 commented 1 year ago

Since we are using ESM build so when compiling to js using tsc the imports don't have .js extension due to which it fails to resolve in host and throws error (The below error is when integrating in @excalidraw/excalidraw docs)

Module not found: Error: Can't resolve './graphToExcalidraw' in '/excalidraw/dev-docs/node_modules/@excalidraw/mermaid-to-excalidraw/dist'
Did you mean 'graphToExcalidraw.js'?
BREAKING CHANGE: The request './graphToExcalidraw' failed to resolve only because it was resolved as fully specified

Hence I am upgrading typescript version and using nodeNext as module resolution which makes sure all imports have .js extension as that's recommended by typescript team - https://github.com/microsoft/TypeScript/issues/42151 and https://github.com/microsoft/TypeScript/issues/16577

To test install the preview version

yarn add @excalidraw/mermaid-to-excalidraw@preview
vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
mermaid-to-excalidraw ✅ Ready (Inspect) Visit Preview Sep 21, 2023 6:32am
dwelle commented 1 year ago

The fact TS vehemently rejects compiling ./file (or ./file.ts) -> ./file.js and instead forces us to write .js when importing TS files is nuts.