Skip to content
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

Export ESM #501

Open
idleberg opened this issue Mar 14, 2022 · 6 comments
Open

Export ESM #501

idleberg opened this issue Mar 14, 2022 · 6 comments

Comments

@idleberg
Copy link

idleberg commented Mar 14, 2022

getstream is currently exported as UMD only. ESM support has been around in NodeJS (and the browser) for some time and, I believe, since v12.20 it can be used without a flag. With NodeJS 16 being LTS at the time of this writing, I think it would be nice to provide an ESM export. The main advantage (for me, anyway) would be to use the same syntax when importing from a CDN and node_modules, rather than using a global variable.

Further reading:

While I don't want to get too specific on my own code, I would like to provide an example where this would help developers. When using Vite's development server, I can't import getstream from without running into NodeJS-specific problems (this issue is possibly related). The same import works fine when Vite builds my code and optimizes it for the browser. Currently, my only workaround is to change the import from import stream from "getstream" to import "https://cdn.jsdelivr.net/npm/[email protected]/dist/js_min/getstream.js". However, I need to undo this change whenever I build, since I want to import the locally installed npm package of getstream. If you provided an (browser-optimized) ESM, I could simply put a condition on NODE_ENV in my config file (example below), not rewriting my import on every switch between development and build.

resolve: {
  alias: {
    "getstream": process.env.NODE_ENV ? "https://cdn.skypack.dev/getstream" : "getstream"
  }
}
@bradintheusa
Copy link

I came here to say the same thing. Thanks for the workaround but any ETA on a fix?

@bradintheusa
Copy link

Does anyone have a working Vue3 client example of this? I'm just bouncing between errors at the moment.

@oski646
Copy link

oski646 commented Aug 16, 2022

Hi! Any updates?

petyosi added a commit that referenced this issue Aug 31, 2022
@ferhatelmas
Copy link
Contributor

Can we give a test drive to [email protected] ? Thanks

@idleberg
Copy link
Author

idleberg commented Sep 12, 2022

Can we give a test drive to [email protected] ? Thanks

Thanks for the heads up. I'm currently on paternal leave and won't have a chance to touch company code before December.

@petyosi
Copy link

petyosi commented Sep 12, 2022

@oski646 @bradintheusa - did you have a chance to test that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants