bundlejs
bundlejs copied to clipboard
Fail to bundle `npm/lib/cli-entry.js` and `@npmcli/arborist`
https://bundlejs.com/?q=npm%2Flib%2Fcli-entry.js
The error during the bundling:
http-url:https://unpkg.com/[email protected]/lib/:1:1
Where https://unpkg.com/[email protected]/lib/
returns HTML (404) while https://unpkg.com/[email protected]/lib/index.js
does return JS.
Is there any option that enables node-like resolving?
https://bundlejs.com/?q=%40npmcli%2Farborist
This also faces the same error, also caused by the https://unpkg.com/[email protected]/lib/
@okikio Would you like to add an option for node like resolving?
I've determined the cause of this issue, but I'll have to delay fixing it by a little bit as I won't be available to fix it issue until a little later on during the week/weekend. This issue seems to be caused by the redirect unpkg.com does when you add a /
to the end of the url. For example, https://unpkg.com/react will lead to react but https://unpkg.com/react/ leads to https://unpkg.com/browse/react/.
I've determined the cause of this issue, but I'll have to delay fixing it by a little bit as I won't be available to fix it issue until a little later on during the week/weekend. This issue seems to be caused by the redirect unpkg.com does when you add a
/
to the end of the url. For example, https://unpkg.com/react will lead to react but https://unpkg.com/react/ leads to https://unpkg.com/browse/react/.
I've tried to switch to other CDNs, but all available CDNs have their flaws:
- unpkg: doesn't support URL ending with
/
(redirect to browse view) - esm.sh: doesn't support externalizing Node.js built-in modules and doesn't support loading
package.json
- cdn.jsdelivr.net and esm.run: doesn't support node-like extension resolving (
https://cdn.jsdelivr.net/npm/[email protected]/deprecated
won't redirect tohttps://cdn.jsdelivr.net/npm/[email protected]/deprecated.json
) - skypack: failed to load the entry
I'm so sorry, I'll try my best to get this fixed when I get the chance
I'm so sorry, I'll try my best to get this fixed when I get the chance
Don't worry. The issue is caused by the behavior of existing CDN providers, not by bundlejs
.
IMHO, bundlejs
could add a node-like
resolver (maybe opt-in by an option?):
- load the URL and parse
- If failed to parse or 404 (this mimics
fs.exists
)- If the URL ends with
/
- Add a trailing
index
then load and parse that URL instead.
- Add a trailing
- If the URL doesn't end with an extension (primarily seen in CommonJS modules)
- Add extensions (
.js
,.cjs
,.json
), then load and parse each one of them. - Maybe use
Promise.any here
to parallel?
- Add extensions (
- If the URL ends with
- If failed to parse or 404 (this mimics