CanvasGUI problems

In Node.JS, JS files are always treated as a module, regardless it’s CommonJS (.cjs) or ESM (.mjs), or it’s just using extension “.js”.

Even though the entry “main” has a specific meaning in Node.JS, some CDNs may read the root “package.json” and identify paths for it and other properties, such as “browser”, “types”, “module”, “exports”, etc.

BtW, “index.js” doesn’t even exist in your repo’s root, and having “main” pointing to the actual library file “dist/lib/gui.js” can help CDNs and, if you end up publishing your library as an NPM package as well, identify the real executable file!

As an example, p5.js 1.x.x has a “main” entry pointing to “lib/p5.min.js”:

And that’s why some CDNs allow this very short URL for it:
https://cdn.jsDelivr.net/npm/p5

Although it seems like they’ve replaced “main” w/ “browser” for its next major release 2.x.x:

Not sure why wouldn’t they keep both. But anyways, 2.x.x is already a compatibility wreck.