-
-
Notifications
You must be signed in to change notification settings - Fork 772
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
add ESM exports in package.json #692
Conversation
package.json
Outdated
"types": "./dist/fuse.d.ts", | ||
"import": "./dist/fuse.esm.js", | ||
"require": "./dist/fuse.common.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"types": "./dist/fuse.d.ts", | |
"import": "./dist/fuse.esm.js", | |
"require": "./dist/fuse.common.js" | |
"import": { | |
"types": "./dist/fuse.d.ts", | |
"default": "./dist/fuse.esm.js" | |
}, | |
"require": { | |
"types": "./dist/fuse.d.ts", | |
"default": "./dist/fuse.common.js" | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated! Thanks for reviewing!
This would be something that would help us. Is there something I can do to help here on this effort ? |
@rchandu seems like there hasn't been active development in this repo for a couple of months now 🤔 |
package.json
Outdated
"type": "module", | ||
"exports": { | ||
".": { | ||
"types": "./dist/fuse.d.ts", | ||
"import": "./dist/fuse.esm.js", | ||
"require": "./dist/fuse.common.js" | ||
} | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"type": "module", | |
"exports": { | |
".": { | |
"types": "./dist/fuse.d.ts", | |
"import": "./dist/fuse.esm.js", | |
"require": "./dist/fuse.common.js" | |
} | |
}, | |
"exports": { | |
"types": "./dist/fuse.d.ts", | |
"import": "./dist/fuse.esm.js", | |
"require": "./dist/fuse.common.js" | |
}, |
The old version was invalid. You cannot just add "type": "module"
unless Fuse itself is rewritten to ESM. Also "type": "module"
only affects the module itself, not when the module is loaded through node_modules.
Furthermore the subgrouping of "."
is not necessary because Fuse doesn't have subpath exports
Lastly, after including this change thus reverting "type": "module"
you should also revert the other .cjs
related changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for reviewing! I have updated to your suggestions.
It's been a while and I haven't checked again, locally, but I hope this would work well with Typescript + Jest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should. I maintain the Sapphire project and we use this structure in all projects there are it works with a variety of stacks. CJS, ESM, Jest, Vitest, etc
@krisk Could you kindly please take a look at this? Thanks! |
@akphi expect a PR to your fork with a completely refreshed but also thoroughly tested setup very soon, when you merge that it'll pop up here for Krisk to then review fully. I noticed my comment above introduced some other issues as well but now I am testing the scenarios:
Edit: Only having some trouble with the last one still so I need to figure that out. |
hey @favna, thanks for being super transparent; I really don't mind you carrying that out; all I need is just to have ESM ready :) Thanks so much for the help! - let me know, I'll close it out in favor of your PR |
@krisk We're using
Typescript
module: Node16
in our project and sinceFuse.js
ESM does not specifytype: module
andexports
field inpackage.json
, it does not get picked up properly by Typescript. So I would like to add these to thepackage.json
file.The error I got is something like this, for the following import:
I believe this would help with #541 as I have noted there
For Typescript esm mode, such as
Node16
,NodeNext
,esModuleInterop
is not supported in this mode, it's worth if we do something like lukeed/clsx#44 - I have given it an attempt but not quite sure how I can modify thed.ts
file accordingly.