https://github.com/simonw/download-esm
Download ESM modules from npm and jsdelivr
https://github.com/simonw/download-esm
Last synced: about 1 year ago
JSON representation
Download ESM modules from npm and jsdelivr
- Host: GitHub
- URL: https://github.com/simonw/download-esm
- Owner: simonw
- License: apache-2.0
- Created: 2023-05-02T01:36:22.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-25T07:47:56.000Z (almost 3 years ago)
- Last Synced: 2024-10-18T07:53:42.265Z (over 1 year ago)
- Language: Python
- Homepage:
- Size: 16.6 KB
- Stars: 94
- Watchers: 4
- Forks: 4
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# download-esm
[](https://pypi.org/project/download-esm/)
[](https://github.com/simonw/download-esm/releases)
[](https://github.com/simonw/download-esm/actions?query=workflow%3ATest)
[](https://github.com/simonw/download-esm/blob/master/LICENSE)
Download ESM modules from npm and jsdelivr
See [download-esm: a tool for downloading ECMAScript modules](https://simonwillison.net/2023/May/2/download-esm/) for background on this project.
## Installation
Install this tool using `pip`:
pip install download-esm
## Warning
This is **alpha software**. It works for downloading Observable Plot, but has not been tested against many other packages yet.
[Your help welcome](https://github.com/simonw/download-esm/issues/2) in testing this further!
## Usage
To download Observable Plot and all of its dependencies as ECMAScript modules:
download-esm @observablehq/plot
This will download around 40 `.js` files to the current directory.
To put them in another directory, add that as an argument:
download-esm @observablehq/plot ./js
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:
```html
import * as Plot from "./js/observablehq-plot-0-6-6.js";
const plot = Plot.rectY(
{length: 10000}, Plot.binX({y: "count"}, {x: Math.random})
).plot();
const div = document.querySelector("#myplot");
div.append(plot);
```
## Development
To contribute to this tool, first checkout the code. Then create a new virtual environment:
cd download-esm
python -m venv venv
source venv/bin/activate
Now install the dependencies and test dependencies:
pip install -e '.[test]'
To run the tests:
pytest