Open simonw opened 1 year ago
So it would generate this code:
<script type="importmap">
{
"imports": {
"browser-fs-access": "https://unpkg.com/browser-fs-access@0.33.0/dist/index.modern.js"
}
}
</script>
And rewrite the JavaScript to use lines like this:
import {fileOpen} from 'browser-fs-access';
I'm going to add a --importmap
option which dumps out importmap.json
containing this:
{
"imports": {
"browser-fs-access": "https://unpkg.com/browser-fs-access@0.33.0/dist/index.modern.js"
}
}
It's also going to print the full <script>
block to stderr, as a convenience.
import-map rails uses the JSPM API for this. Perhaps that could be a fruitful approach?
(Also mentioned in a comment from me on lobse.rs)
https://web.dev/import-maps-in-all-modern-browsers/
It might be possible to have it rewrite modules it downloads to use this syntax, and to spit out an import maps block to make that work.