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
configure Babel in esm packaging config #2463
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Why is it needed in ESM? |
In short : Improving stability thanks for your reply. I think the ESM module building needs Babel for the following reasons.
|
UMD is meant to be used client side. The best client side option would be to use the minified file The point of the esm file is so developers can get the speed advantages of modern JavaScript. Using babel (even in loose mode) slows it down slightly. |
Perhaps the solution could be to create a new file like |
Thanks for your reminding. I have understood the differences between the versions of marked before I asked the question. Compiling with iife format can also reduce the space of But use the UMD or IIFE package is more troublesome in modular development. My current solution is to build the ES5 version ESM. And copied a copy from @types/marked as declaration file of the custom marked. so that I can use custom marked while continuing to code in TypeScript
but limited in common front-end development, In universal front-end project, a better way is import ESM and work with TypeScript to reduce errors Unfortunately, I am.
Nice solution! I would appreciate it if 'marked. es5.esm.js' exists. If two ESMs are included in a package, the TypeScript declaration file need modify slightly. please modify it as well. thanks and good night~ |
Typescript types are maintained by DefinitelyTyped. You will need to create a PR there to change the types. |
I see, thank you for your help. |
Babel is not only needed in UMD packagin, but also in ESM.
I'm notice this commit, #1572,
Use Babel's loose mode for shorted & more performant code
I couldn't agree more with that statement,
and also think that use Babel translate javascript to esm module would also have the same benefits