jspm / generator

JSPM Import Map Generator
Apache License 2.0
160 stars 20 forks source link

esm.sh externals no longer working #299

Closed guybedford closed 1 year ago

guybedford commented 1 year ago

Unfortunately it seems the esm.sh provider is no longer supporting externalization of dependencies, so it's become more difficult to support for us.

For now I've just reverted the test case in https://github.com/jspm/generator/commit/a4808ffd2be1ec102dee6a58979549110cc64fc6.

@ije is there a way that we can still support externals on esm.sh for JSPM CLI support?

ije commented 1 year ago

there is a bug that makes lit (just lit) ignoring the ?external query in v117 builds, this will be fixed at next deploy.

guybedford commented 1 year ago

Thanks for the update here @ije! Glad to hear we can re-enable the test soon.

ije commented 1 year ago

@guybedford just deployed the fixes, can you please try again thanks 🙏

guybedford commented 1 year ago

@ije that seems to be working to me. Although the online generator seems to be failing due to access-control-allow-origin unfortunately:

https://generator.jspm.io/#U2xhYGBkDM0rySzJSU1hyMkscTDSM9Az0C1K1jMEAI4dhrMdAA

guybedford commented 1 year ago

Hmm, actually it seems like the test is still not passing. We're currently using the * import form. Perhaps we should be using external queries explicitly?

We're accessing this URL for Lit: https://esm.sh/stable/lit@2.0.0-rc.1/es2022/lit.mjs, resolved via https://esm.sh/*lit@2.0.0-rc.1.

ije commented 1 year ago
Screenshot 2023-05-01 at 12 21 41

after purging (cdn) cache, it works for me now, but i found some other 404 errors, eg:

GET https://esm.sh/v118/lit@2.0.0-rc.1/X-ZS8q/es2022/package.json 404

this correct path is:

https://esm.sh/lit@2.0.0-rc.1/package.json
guybedford commented 1 year ago

@ije thanks, I can confirm that allows us to reenable the tests here too. For the unnecessary package.json checks, this is a fallback behaviour in JSPM when it doesn't recognize the pathing system in use by the provider. It usually works eg in Node.js, but breaks down in the browser due to 404 pages often not including access-control-allow-origin, as seems to be the case for esm.sh here.

I've got a possible fix in https://github.com/jspm/generator/pull/302 to better support working out the package root, although need more time to test it properly.

guybedford commented 1 year ago

Closing as resolved, thanks again for the help!