jspm / generator

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

unable to generate importmap for @lume/live-code #350

Open trusktr opened 2 months ago

trusktr commented 2 months ago

https://generator.jspm.io/#U2NhYGBkDM0rySzJSU1hcMgpzU3Vz8ksS9VNzk9JdTDQM9MzAQB/3w91JAA

It says:

Error: No './dist/themes/smoothy.js' exports subpath defined in https://ga.jspm.io/npm:thememirror@2.0.1/ resolving thememirror/dist/themes/smoothy.js imported from https://ga.jspm.io/npm:@lume/live-code@0.6.4/dist/index.js.

However we can see that the file exists:

https://unpkg.com/thememirror/dist/themes/smoothy.js

Can you please please remove the non-standard restrictions? 🙏

I keep getting blocked by JSPM Generator, and it is getting tiring (just being honest, nothing personal towards you). This isn't a bug in the software, you write great software, but this is an unnecessary restriction that is not based on the ES Module standard.

Please just allow files to be imported! Please!! At this point I think I will have to remove JSPM from my workflows and documentation, because I can't be blocked due to this any more.

I'm really hoping and wishing for it to change.

If the whole stack were open source, I'd already have forked this and solved it. It is totally unnecessary, and not in the spirit of ES Module standards.

guybedford commented 1 month ago

@trusktr the bug here is actually a strict enforcement of the Node.js module resolution rules.

The package sets an "exports" field of "exports": "./dist/index.js". Per the Node.js module resolution spec, "exports" is encapsulating, so that no other subpaths within the package are allowed to be imported.

If you try doing the same import in Node.js itself it will throw with a similar error.

The solution is to ensure that all of the package exports are listed in "exports" here.

If you want a non-optimizing resolving CDN then try resolving with JSPM generator to jsdelivr via defaultProvider: 'jsdelivr' or another provider. Although typically for compatibility you do want a CDN that applies the standard module resolution rules.