jspm / generator

JSPM Import Map Generator
Apache License 2.0
166 stars 21 forks source link

htmlInject() esModuleShims option flag doesn't work as expected #161

Closed zachsa closed 2 years ago

zachsa commented 2 years ago

Using the generator like so:

generator = new Generator({ ... })
html = generator.htmlInject(htmlText, {
  ...,
  esModuleShims: // <- This option isn't working as expected
})

I was attempting to try 'swapping' the order of script tag inclusion. Currently the es-module-shims script is added before the import map - and this doesn't work on Firefox. I haven't actually found that switching the script tag order around improves things for Firefox, however I have found that the htmlInject has some limitations that seems like bugs.

So long as I'm using htmlInject there are limitations in terms of manually including an es-module-shims script, which may be useful to pin a specific version of the script, or other general reasons. Here are the cases:

I found this out as I was trying to debug why the import maps are not working in firefox (https://github.com/jspm/generator/issues/160)

What I would expect is that:

guybedford commented 2 years ago

Thanks for the clear analysis here. I've implemented your suggestion in https://github.com/jspm/generator/pull/162.