-
Notifications
You must be signed in to change notification settings - Fork 97
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
ESM export is seen as default.default
#80
Comments
Hi, this is interesting. |
Yes, it's called ECMAScript Modules (ESM), or alternatively JavaScript modules. Some resources:
It is possible to load such a module directly in a browser via |
Excellent, do you have a lot of experience with this? I am excited to finally get rid of the hack I had to implement. |
No, |
I did the required changes if you want and tested with a couple environments to make sure everything was backwards compatible. Hope it was helpful :) #83 |
@silverwind - please try the v6.0.0 branch |
Yes, looks good there: $ node
> await import("ansi_up")
[Module: null prototype] { AnsiUp: [class AnsiUp] } For the record, I installed via
|
@silverwind - excellent, I want to get a few more things in and then I will create a release |
One caveat when going ESM is that some older code bases that are still using CommonJS (CJS) may not be able to import the module. Advice to them should be pretty much this. There is a possibilty to dual-publish ESM and CJS, but I think it's generally not worth the trouble. You should definitely publish a new major version with this change. |
Released |
Because of the AMD wrapper, the
AnsiUp
export is seen asdefault.default.AnsiUp
when the module is loaded in ESM context:Ideally convert the module to ESM with
export default AnsiUp
which can be loaded direcly in a browser viaimport AnsiUp from "./ansi_up.js"
without any extra<script>
tag needed.The text was updated successfully, but these errors were encountered: