Skip to content

shoukoo/dl-esm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dl-esm

Download ESM modules from npm and jsdelivr

This is the Go version of Simon Willison's download-esm work

Installation

Install this tool using go:

    go install github.com/shoukoo/dl-esm@latest

Usage

To download Solid JS and all of its dependencies as ECMAScript modules:

dl-esm solid-js/html

This will download around 3 .js files to the current directory.

To put them in another directory, add that as an argument:

dl-esm solid-js/html /tmp

To download a specific version of solid js

dl-esm [email protected]/html

Each file will have any import and export statements rewritten as relative paths.

You can then use the library in your own HTML and JavaScript something like this:

...
<script type="importmap">
{
  "imports": {
    "solid-js": "/static/solid-js-1-7-5.js",
    "solid-js/html": "/static/solid-js-1-7-5-html.js",
    "solid-js/web": "/static/solid-js-1-7-5-web.js"
  }
}
</script>
<script type="module">
import html from "solid-js/html";
import { render, hydrate } from "solid-js/web";
import { onCleanup, createEffect, createSignal, onMount, For, Show } from "solid-js";
...

Development

To run dl-esm locally run:

    go run main.go [email protected]

To run the tests:

    go test ./...