esm.sh
esm.sh copied to clipboard
API that provides all the urls of packages that are being imported by an package
How does it help?
Lets us download all the dependencies of the packages instead of executing the whole package before.
This lets us bundle/vendor dependencies without running them.
Whats my usecase?
Currently working on URL Imports in Nodejs, and it works pretty fine, with some tweaks and polyfills. You can read source code at https://github.com/rovelstars/reejs/blob/master/project/import.js and it uses Nodejs' vm modules to sandbox the downloaded code and run it.
Example that my code works incase you think its a bad idea:
But now my project installs deps only during it starts the application, so I would like to basically crawl and download before the application starts (preferrably for those installation and build scripts in heroku/railway). This will also allow me to have a uninstaller too, that doesnt executes the whole code again before crawling for all the links and then uninstalling...
You might be interested in the deno info
CLI, that can report the dependency graph of a module file/URL:
https://deno.land/manual/tools/dependency_inspector
It has a --json
option if you want to use the dependency graph information programatically.
Deno also has commands for caching and vendoring, but they might not be helpful to you if you are using Node.js at runtime.
As you figured out I am using nodejs as runtime, deno info
won't help me too lol.
This api feature would help pre-downloading required packages instead of downloadingthem at runtime :clap:
Also it looks like Deno downloads the code in order to crawl the links.
If esm.sh could provide an api for all the urls used, it would make it easier to download files in parallel since the code doesnt run and crawl one by one file.
esm.sh has now support for preloading of js files. Consider this issue as resolved.