esbuild
esbuild copied to clipboard
Introduce UMD as a new output format
cherry-pick from https://github.com/evanw/esbuild/pull/513 with conflicts resolved
Definitely having no UMD support breaks legacy projects on some users, so much thanks @gwuhaolin for your effort on this dutie!
cc: @jridgewell
For the record, you can achieve this in a hacky way by using the footer.js option with a snippet like this, e.g.
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(factory);
} else if (typeof module === 'object' && module.exports) {
module.exports = factory();
} else {
root.YourExportedModuleAsIIFE = factory();
}
}(typeof self !== 'undefined' ? self : this, () => YourExportedModuleAsIIFE));
Of course, it would be better to having UMD support without having to worry about this nuance.
rebase and try to push this request to master @gwuhaolin
by the way thanks a lot
I would like to see this merged
agreed! merge ETA? thanks @prantlf 👏 + @gwuhaolin 👏
This is the only feature preventing me from switching from Rollup to ESBuild as the author of 50+ open source JS libraries. Gently bringing this to your attention @evanw 🙏
really would like this to be added
@gwuhaolin does this PR supports externals ?
for example https://github.com/mistic100/Photo-Sphere-Viewer/blob/master/dist/photo-sphere-viewer.js#L7-L11 (this is rollup.js output)
edit : well.... as currently a plugin is required to have external globals (esbuild-plugin-external-global), it may not work out of the box. Or said plugin will have to be merged in the core.
why is this pull request still open?