-
Notifications
You must be signed in to change notification settings - Fork 45
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
Exporting as ES Module Syntax (ESM) #62
Comments
We added a It seems that "fixing" things for one set of tools tends to break other tools. We also tried supporting What is the practical benefit here? So that it can be indexed by pika? |
With a proposal like this #64, the idea is to export the package in two formats:
The benefit is that importing the library becomes much easier in cases such as:
Many of the modern libraries are already exporting to ES Modules. About the The link to Pika was just a reference to the ES module syntax. |
Based on past experience, I'm still worried that supporting both module systems at the same time will cause issues for existing libraries. Can you give a concrete example of how not supporting both module systems is causing issues? |
Try to use it directly in the browser, without tools. You can't use the standard ES Modules. Example: https://glitch.com/edit/#!/cheddar-girdle If you import the
(I made the example work importing the |
My final goal is use Then I get the error:
Using the #64 PR, I have an app example using |
Maybe the bad experience of the past was for not defining this in the "main": "lib/cjs/index.js",
"module": "lib/index.js", |
What is throwing this error:
Is that rollup, or the browser, or something else? |
This error is from the browser:
If you want to see it, just remove this line and run the application: |
In order to use a library like |
No, it is not necessary. You can test the application running without any build/bundled here: https://github.com/abdonrd/open-wc-application-apollo-client/compare/apollo-client-es-modules We only do the build & bundled step to optimize the application for production. But not during local |
Sounds cool - I'll give it a try. |
Great! Thank you @zenparsing! |
This is a tough one. I tried to run the app but wasn't able to get it working (with the few minutes I had). Node 13 will support ESM without a flag using For now, I've added a better esm entry point at zen-observable/esm.js. For your use case, is there any way that you can tell the browser to look there for the package entry point? |
As far as I know, the only way is to use the
In the future, the idea is to use the |
And there are other big packages like Redux using this https://github.com/reduxjs/redux/blob/c2973f480bc4e5b6bf7d42a714d4790311cd1a26/package.json#L26-L28 |
@zenparsing Please push |
There are any news @zenparsing? Thanks in advance! |
I am running into this same issue with an app built using
https://angular.io/guide/build#configuring-commonjs-dependencies has some good links to explain why CommonJS modules don't support tree shaking and how ES Modules work.
import zenObservable from 'zen-observable'; But due to the lacking It looks like the approach in PR #74 should solve this and hopefully avoid any of the pitfalls that were faced in the past. |
Any updates on this? Looks PR is still not merged yet :C |
any update on this?? |
Will be addressed in #86 |
Please, export
"module"
entry point in thepackage.json
as ES Module Syntax (ESM).More info about it here: https://www.pikapkg.com/about/
The text was updated successfully, but these errors were encountered: