-
Notifications
You must be signed in to change notification settings - Fork 226
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
feat: add ESM support #252
Conversation
Can't we use a wrapper as documented here https://nodejs.org/api/packages.html#approach-1-use-an-es-module-wrapper instead of duplicating everything? |
AFAIK, that doesn't work in practice. I can give it a try to see how it works out. |
Good news. I have tried it and it works. The reason it works is the Also updated the |
Another issue I see is that this works in Node.js but not in the browser. We only have the UMD for the browser. |
I think UMD is ok, people who use UMD are not using ESM. So the code can remain as is. |
Yes I was referring to the fact that is not possible to use this as ESM in the browser. For example using a CDN like https://www.jsdelivr.com/. I wonder if it makes sense to create both an ESM and UMD module renaming the |
I see, so you want to have two bundles, one for umd and one for esm.
That will be a braking change for |
Ideally yes, that is what I would expect from "ESM support". |
There are already breaking changes. |
Ok. let me see if I can cook up one. |
If that's the case, do you still want to support the use case of I don't see why people would do deep linking in NodeJS env. |
One more question. Do you want to also replace UPDATE: I have updated to use |
There is some problem with the adjustment of:
in the First one works, second doesn't. But rollup complain about the first one. Need to fix that UPDATE: done |
Thanks. I will review properly in the next few days. |
bundle using rollup
All review changes updated and squashed for easier reading. |
Co-authored-by: Luigi Pinca <luigipinca@gmail.com>
Thank you. |
I kept the existing code unchanged and only add the new
index.mjs
file copied fromindex.js
.Adjusted
var
=>const
andlet
,and update
package.json
to with theexports
field and addedtest:esm
script.Updated
ci.yml
to runnpm run test:esm
.Fixes #251 #248