I use @web/dev-server with the --watch and --node-resolve option (web-dev-server --node-resolve --open --watch) that rewrites bare module imports on-the-fly e.g.
import moment from "moment";
will be rewritten on-the-fly to:
import moment from "/node_modules/moment/src/moment.js";
in all .html and .js files.
I use JSPM CLI (jspm link index.html -p nodemodules -o index.html) that can use an HTML file as an entry point, generates only required import maps, then injecting the import map output back into the HTML file.
It's a different approach that I like better, because modern browsers now support import maps natively.
I'd be happy to completely abandon the first tool in favor of the second, but:
It requires an additional tool for serving files e.g. npx http-server -c-1
It requires the jspm link index.html -p nodemodules -o index.html command has to be run manually every time to update the import map
It would be great if the JSPM CLI could serve projects (serve files, watch changes and automatically on-the-fly update import maps in index.html).
Currently while developing I use two tools:
--watch
and--node-resolve
option (web-dev-server --node-resolve --open --watch
) that rewrites bare module imports on-the-fly e.g.will be rewritten on-the-fly to:
in all .html and .js files.
jspm link index.html -p nodemodules -o index.html
) that can use an HTML file as an entry point, generates only required import maps, then injecting the import map output back into the HTML file.It's a different approach that I like better, because modern browsers now support import maps natively.
I'd be happy to completely abandon the first tool in favor of the second, but:
npx http-server -c-1
jspm link index.html -p nodemodules -o index.html
command has to be run manually every time to update the import mapIt would be great if the JSPM CLI could serve projects (serve files, watch changes and automatically on-the-fly update import maps in
index.html
).