-
-
Notifications
You must be signed in to change notification settings - Fork 160
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
Consider to support ES "module" #87
Comments
Sorry for my ignorance, what does that mean? |
Gotcha. I have seen folks doing If you do make a pull request, please be sure it includes tests and documentation, that would be most appreciated! Also any info you can provide written out that I need to know (not just long generic articles) so I can properly support any issues that arise from this in the future would be helpful too :) |
I was reading and I guess that we need 2 stages: |
Hey, so I am not sure any PR should be made for this. When node and the browsers can land on a final path forward for ES Modules then maybe there will be something to do here ( |
Well, this is a Node.js module, so it doesn't work out-of-the-box in the web browser. You need to use browserify, webpack, etc. to create a browser version of this module for you to use. This would apply to pretty much every Node.js module out there. |
That's why I would like to move to ES-modules and distribute different versions adding them in the
If the library has all ways final user doesn't need require other libraries to convert it. |
Gotcha. Well, that is very different, though, then changing the export type. For example, supporting the web browser means we actually need to test this module in the web browsers too, so we can support this. For example, if this module makes use of a Node.js API, then it still won't work in the web browser, right? And what about the pending PR that will add a dependency to this module, will that still work in the browser with your changes? |
I'm using cookie-api-handler that it's an extension of rest-api-handler, a handler for REST APIs. That should work in the browser using module syntax. I was looking for different approaches and I found cjs-to-es6 that you can run in the publish process to generate the es6 distribution. I'm going to decline the PR until we can find the right solution. |
That module is using this module incorrectly. The parse function of this module is only made to parse the Perhaps that module should not even be using this module in the first place? |
Maybe it's not crazy serve libs in several versions: My PR uses pika and NPM is considering to add it natively in NPM. npm/rfcs#35. I guess it time to change the test process and build the distribution versions which will be tested in all Node versions. |
Maybe I'm wrong, but the syntax it's not very different:
vs
What am I loosing? |
I would love to be able to use this lib also in the browser! |
@BorntraegerMarc, there is no reason you cannot use this in the browser today. Is there something specific you are looking for here? |
well @dougwilson wrote:
So I guess it's not possible at the moment to use it in the browser. Am I missing something? |
I think that comment is misleading for this discussion. Doug is pointing out that if we wanted to promote browser support we would need to add tests. And if this module did use a node api it would need something to support browsers. But this module does not have such a node api usage. If you import this into the browser today it should work just fine. I think I have even done so. |
oh ok, so I completely misunderstood 😅 sorry for bothering then 😃 |
No worries, hopefully this conversation will help people in the future who land here :) |
FYI I've created an ES Module version of this package called |
Hey @mkay581, thanks for Heads up, seems like your npm package is still |
@franciscop that's the incorrect package haha. The cookie-esm package is at https://www.npmjs.com/package/cookie-esm. Latest version is 1.0.1. |
Oops, my bad! 👍 |
@wesleytodd I think this issue can be safely closed. If developers want to use this library in an esm environment, they can. This works just fine:
In addition, developers can use this module in the browser (provided they're using a bundler like rollup, browserify, webpack, etc). |
Sorry but this still isn't working for me. I'm using it in an esm environment in Chrome Browser via Karma using the I'll just have to keep using https://www.npmjs.com/package/cookie-esm package which has been a good workaround. |
@mkay581 You can use Given the versions of node this module must support and the fact that there's no transpile step for any modules under the jshttp org, I don't see this package working with esmodules in the browser out of the box any time soon |
It would be great to implement ES module entrypoint
The text was updated successfully, but these errors were encountered: