pixelmatch icon indicating copy to clipboard operation
pixelmatch copied to clipboard

CDN script error: module not defined

Open derek-ye opened this issue 1 year ago • 1 comments

Description

I'm trying to embed the script in a static HTML file, but I'm running into the following error. I think it might be due to the script being a CommonJS module - any ideas on how I could fix this without converting the entire file to ESM?

index.js:3 Uncaught ReferenceError: module is not defined
    at index.js:3:1
(anonymous) @ index.js:3

HTML file:

<body>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
    ...

derek-ye avatar Feb 22 '24 23:02 derek-ye

Yeah, looks like we need to convert Pixelmatch to ESM to use it on the browser properly now. Meanwhile, as a workaround, maybe you could try using Skypack CDN which does CommonJS to ESM convertion automatically: https://cdn.skypack.dev/pixelmatch

mourner avatar Feb 23 '24 11:02 mourner

pixelmatch v6.0.0 is now a module, so this should be fixed.

mourner avatar Jun 26 '24 12:06 mourner