blobs
blobs copied to clipboard
Adding ES Modules to the final build
Currently, if you have a ES bundler (Vite, Snowpack) you cannot use this library, as it uses an outdated module system (UMD).
I added the support for ES modules. It just builds 4 additional files for both versions of the lib.
Most bundlers (Vite including) will use index.module.js by default, but it's a convention to also add a module key in the package.json.
If new versions are planned, I would actually advise in favor of abandoning rollup config at all and using something like dual-publish with CJS as a more common option for module system.
It would also drastically simplify the build process for you.
Hey, so sorry I missed this. Will take a look ASAP
Do you think publishing the TypeScript source could also solve this for you? I'm mostly outputting bundled JS to make it easier to use with a <script> import.
The build command fails because of uglify when I patch that rollup config change, I'll need to iterate on it.
@g-harel
I'm mostly outputting bundled JS to make it easier to use with a
Most of the libs ship bundled code, that is ok. Not only it allows to use stuff, like unpkg and other CDNs right in the script tag, it also speeds up the build, as I don't need to rebuild your library from the source.
Do you think publishing the TypeScript source could also solve this for you?
I believe it's not a common thing to ship raw .ts files. I didn't find a single example of this in my node_modules, tbh. I think it would work, but it's unnecessary work for the compiler and bundler.
As of #4, I don't see any errors, when I try to import the same file. TS doesn't throw any errors and compiles the code successfully. I guess there might be some incompatible configuration settings in tsconfig.json.
I just published 2.2.1-beta.0 with this change, let me know how that works for you! If it works out I'll merge and do a real release
@g-harel I tried your beta release, but it doesn't work. I suspect it's mostly because you haven't added "module" key in package.json.
All these modern bundlers are so fragile :)
That's embarrassing, my bad and thanks for checking. I published a patched version as 2.2.1-beta.1