Closed Donil closed 1 year ago
Y'know what everybody loves?
People being opinionated about build systems.
Y'know what everybody loves?
People being opinionated about build systems.
Sorry, it seems I incorrectly explained the goal of this PR. The main point is getting MJS bundle. I have not found the way to do that with browserfy.
I can rework this PR to do that with browserify if you could help me with browserify. Thanks!
One more target - generating type declaration files. Now you provide main.ts as types (in the package.json). This approach makes integration with TS a little bit harder - TS of the host codebase runs type checking also on this library. But if the current library provides d.ts files this will work well without replacing simple import * as LibAVWebCodecs from 'libavjs-webcodecs-polyfill';
with
import type * as LibAVWebCodecsJS from 'libavjs-webcodecs-polyfill';
let LibAVWebCodecs: typeof LibAVWebCodecsJS;
I believe the answer for .mjs is esmify. Not sure what the answer is for .d.ts, but I'm sure tsify does it.
Yes, generating d.ts files is not problem with browserfy, but generating .mjs file is not possible I think. esmify transfrorm from "import / export" to browserify but not to bundle with "import/export". Correct me if I'm wrong
It seems I've found the reason on why I can not use current UMD bundle with my case - I'm working on JS library and want to build it into the signle JS file (as you library does). For that I have to embed libavjs-webcodecs-polyfill into my bundle. But since polyfill is standalone UMD module it has this code:
if (typeof exports === "object" && typeof module !== "undefined") {
module.exports = f();
}
So it just overrides my ESM module exports and breaks it. I resolved it with https://www.npmjs.com/package/@rollup/plugin-commonjs for my case so I'm closing this PR and will return with new PR soon - to add d.ts files generation :)
Hi! That is another one PR - adding support of MJS (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) bundle.
I made this with rollup since it's really good build tool and browserify is not needed anymore since we have ES2015 modules.
So for now we have two bundles:
Take a look on it and say if you are interested with that way