Skip to content

Instantly share code, notes, and snippets.

@PotatoesMaster
Last active February 10, 2025 23:13
Show Gist options
  • Save PotatoesMaster/ffdd765c8799327a9e7c85241151ae38 to your computer and use it in GitHub Desktop.
Save PotatoesMaster/ffdd765c8799327a9e7c85241151ae38 to your computer and use it in GitHub Desktop.
JSPM usage example

Using JSPM to generate import map for ES modules.

Getting started : JSPM

  1. Install jspm globally (or locally, if so run npx jspm instead of jspm):
npm install -g jspm
  1. Create a directory, install npm dependencies (es-module-shims is an importmap polyfill that jspm includes by default):
mkdir imtest
cd imtest
npm install es-module-shims @atcute/oauth-browser-client
  1. Create index.html with a script that imports stuff (JSPM also supports scripts in external files):
$ cat > index.html
<!doctype html>
<script type="module">
  import { configureOAuth } from '@atcute/oauth-browser-client';
  console.log(configureOAuth );
</script>
  1. Finally, resolve the importmap and update index.html:
jspm link --provider nodemodules index.html -o index.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment