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

Probably my configuration, but... #67

Open
pragdave opened this issue May 10, 2020 · 2 comments
Open

Probably my configuration, but... #67

pragdave opened this issue May 10, 2020 · 2 comments

Comments

@pragdave
Copy link

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?

@Fuzzyma
Copy link
Member

Fuzzyma commented May 10, 2020

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?

@Fuzzyma
Copy link
Member

Fuzzyma commented May 10, 2020

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

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