-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
Native support for esm clients #4788
Comments
Hi @plastikfan sorry for any confusion. Our readme and website should have it documented how you import express, which is with require() and not import. I'm not sure where it would have indicated the use of import. As far as adding it, I don't see any issue with adding suport, but I am not familiar with how one would do so. Would you be willing to make a pull request that adds the import in addition to our current require()? |
Hi @dougwilson, I do have some idea, let me investigate further, I would love the opportunity to contribute to this repo, cheers for now. |
Hey, @plastikfan -- I'm not sure if using |
Thanks @Segmentational ill take a look |
Actually I realised that I had done something wrong in my application using the rollup bundler, which was the real problem, so I am going to close this issue. The problem was caused by the bundling process of rollup. I am using rollup to bundle all code with the package, but not 3rd party dependencies. I forgot to add express to the "externals" entity in the rollup config, which is what caused the error I reported on originally. With the correct config, the normal import (import express from "express";) does indeed work. The error message in Rollup was not particularly helpful. |
Yeah I remember using |
Attempting to import from express from an esm package, does not currently work:
Taking a look at express's root index.js reveals:
this is not compatible with esm clients. The client needs to use the esm require workaround, but the user may not be aware of what this is. Eg, I am currently using rollup/typescript in an esm module and attempted to import express and was faced with a confusing error message that did not accurately reflect the problem at hand:
The user needs to esm require instead (but really ought not to):
Now that esm is becoming established it would be good for express to get onboard the esm bandwagon and natively support it for a better developer exprience.
The text was updated successfully, but these errors were encountered: