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
ES Modules Compatibility #83
Comments
Thanks for filing @asantos00! I think it's already possible to use with Deno ;) I'm relatively hesitant to add a build process here to a two-file library with minimal maintenance assistance when compat options exist for the most common uses already. It's not the initial work that I'm concerned with, more the ongoing sync concerns that publishing is no longer just the source files in the repo for what I currently see as a minimal benefit. The typical ESM benefits such as tree shaking don't really matter in this case when there's 1-function per file already, ya know? |
Thanks for answering! Hum, it might be, but unfortunately, the compatibility layer still has a long way to go 😢 The way it's currently exporting doesn't work natively in Deno because it doesn't have the global Yeah, I get your point, my suggestion might overcomplicate things a bit. My suggestion came because the only thing I had to do to get it working on Deno (and on the browser, natively) was to export the import { encode } from 'https://unpkg.com/jpeg-js@0.4.2/lib/encoder.js'; But yeah, that would break for Node users under v12. |
Hm, strange. I'm able to get jpeg-js working as described in the CommonJS module compat instructions. go.ts import { createRequire } from "https://deno.land/std@0.83.0/node/module.ts";
const require = createRequire(import.meta.url);
const jpegjs = require("jpeg-js");
console.log(jpegjs)
Proposal How about a super basic |
I think that would do the job, yes! And it would more likely enable using it directly on browsers (with just an ES import). Are you using any "Node exclusives" except the Deno.Buffer (that can use the UintArrays under a flag)? |
Nope, the library already works in browser as-is.
FWIW this is also possible today if you're comfortable using the global object |
Glad you agree! I'm happy to review such a PR if you'd like to contribute :) |
Thank you for your job in this library!
I'd like to suggest making it ES module compatible, it wouldn't require much, just a matter of exporting the functions using the
export
function and importing modules using theimport
keyword.My suggestion, to keep compatibility with Node is to have a single version that would then "compile" into the others (as there are versions of Node that still don't support ESM)
This change would also make it possible to use this library on Deno (https://deno.land/).
If you're willing to do it, I'm eager to help!
The text was updated successfully, but these errors were encountered: