okikio / bundlejs

An online tool to quickly bundle & minify your projects, while viewing the compressed gzip/brotli bundle size, all running locally on your browser.
https://bundlejs.com
MIT License
751 stars 13 forks source link

Fail to bundle `npm/lib/cli-entry.js` and `@npmcli/arborist` #57

Open SukkaW opened 1 year ago

SukkaW commented 1 year ago

https://bundlejs.com/?q=npm%2Flib%2Fcli-entry.js

The error during the bundling:

http-url:https://unpkg.com/validate-npm-package-name@5.0.0/lib/:1:1

Where https://unpkg.com/validate-npm-package-name@5.0.0/lib/ returns HTML (404) while https://unpkg.com/validate-npm-package-name@5.0.0/lib/index.js does return JS.

Is there any option that enables node-like resolving?

SukkaW commented 1 year ago

https://bundlejs.com/?q=%40npmcli%2Farborist

This also faces the same error, also caused by the https://unpkg.com/validate-npm-package-name@5.0.0/lib/

SukkaW commented 1 year ago

@okikio Would you like to add an option for node like resolving?

okikio commented 1 year ago

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/.

SukkaW commented 1 year ago

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:

okikio commented 1 year ago

I'm so sorry, I'll try my best to get this fixed when I get the chance

SukkaW commented 1 year ago

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?):