You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using svgdom with TypeScript (ts-jest), it fails in module resolution, because main points to a .cjs file. If I change it to reference main-module.js everything works.
As the likely use case is running inside Node anyway, is the .cjs file needed?
The text was updated successfully, but these errors were encountered:
Yes it is needed indeed. Esm modules in node are not widely supported at this point (and with not widely I mean they just were introduced and the support is pretty damn bad). Therefore there is a cjs version which is always picked up as common js module no matter what the package.json says (type: module in our case). However, for node versions which support modules already, there is a new key in the package.json (exports) which resolves explicitely when which file is used.
If typescript is not picking up the correct module it is because the typescript eco system is not up to date with this change. However, cant you just write import {...} from 'svgdom/main_module.js' anyway?
As a sidenode: Even in the esm version there is at least one file dirname.cjs that is common js. That is because import.meta doesnt work properly yet and i need the dirname
When using svgdom with TypeScript (ts-jest), it fails in module resolution, because
main
points to a.cjs
file. If I change it to referencemain-module.js
everything works.As the likely use case is running inside Node anyway, is the .cjs file needed?
The text was updated successfully, but these errors were encountered: