I am trying to import hashids CDN by jsDelivr - A CDN for npm and GitHub and fail. I know that some solution from require debugger will eventually work, but it will be a much better experience if require('hashids@2.2.8') could simply work. But it doesn’t.
And if I understand it correctly, it is an old CommonJS module format, and d3-require that powers Observable require() only support AMD modules (which are also outdated if I understand it right).
“main” normally points to a CommonJS compatible module aimed at the NodeJS environment (CJS).
“browser” normally points to a web browser specific module (one which relies on window, document etc.)
Interesting that d3 doesn’t define browser entry itself.
It is not an ESM module, right? At least I can not find that .default is needed in other examples. And ESM seems async already, so it doesn’t need the wrapper.
https://unpkg.com/hashids@2.2.8?module redirects to https://unpkg.com/hashids@2.2.8/esm/index.js?module; unpkg.com knows how to redirect the request because the package.json contains the entry"module": "esm/index.js".
I understand that Observable JavaScript / Observable | Observable but I my background is Python, and learning the history of JavaScript imports without any experience in that is hard. That’s why I highly rely on examples when bruteforce experiments do not work.