-
-
Notifications
You must be signed in to change notification settings - Fork 721
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
[Feature]: Support Native ESM #717
Comments
I suspect that this is the cause of TS2307 when using node16 module resolution. |
any progress on this? would be happy to support as well. running into issues using this lib ina vite ESM SSR project related: UPDATE: this comment solved my issue w/ building via vite: #509 (comment) |
Having this problem with the Vercel integration of Astro.js, during SSR. Happy to help as well! |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
For me it works as long as I append "index.js" to all of my imports which is annoying but workable 🤔 import { AiOutlineMenu } from "react-icons/ai/index.js"; |
Describe
Hello. Thank you for developing this wonderful library.
Currently, this library provides both CommonJS format files and ES Module format files. However, the ESM files are only specified as
"module"
in package.json."module"
is not supported by Node.js, and Node.js running as ESM cannot import ESM files from this library.To enable Node.js to import ESM files, you should add
"type": "module"
to package.json and provide CommonJS format files as.cjs
.Solution
First, add
"type": "module"
topackage.json
to indicate that the library is provided by ESM. Next, rewrite the file extensions provided by CommonJS from.js
to.cjs
and the file extensions provided by ESM from.esm.js
to.js
. This will work in CommonJS by auto-completion ofmain
and extensions, and in ESM by directly specifyingindex.js
. This should also work well in TypeScript with"moduleResolution": "node16"
set.Conditional exports would also be better supported, but since there are so many subdirectories in this library, I think it may not be necessary to do this at first.
Minimal sample repository URL
No response
Additional context
I would like to be able to import ESM and CommonJS files in the standard Node.js functionality. I would love to work on this issue and would love to send you a PR!
The text was updated successfully, but these errors were encountered: