Skip to content

Instantly share code, notes, and snippets.

@davesnx
Last active January 3, 2024 17:14
Show Gist options
  • Save davesnx/8a8a84e00b4b903a32336cf294b7bb3c to your computer and use it in GitHub Desktop.
Save davesnx/8a8a84e00b4b903a32336cf294b7bb3c to your computer and use it in GitHub Desktop.

Revisions

  1. davesnx revised this gist Jan 3, 2024. 3 changed files with 7 additions and 1 deletion.
    2 changes: 1 addition & 1 deletion Makefile
    Original file line number Diff line number Diff line change
    @@ -1,2 +1,2 @@
    dev:
    npx http-server -o .
    npx http-server -o .
    3 changes: 3 additions & 0 deletions absolute.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    export default {
    data: [1, 2, 3, 4],
    };
    3 changes: 3 additions & 0 deletions relative.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    export default {
    data: [1, 2, 3, 4],
    };
  2. davesnx created this gist Jan 3, 2024.
    2 changes: 2 additions & 0 deletions Makefile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    dev:
    npx http-server -o .
    31 changes: 31 additions & 0 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>importmap demo</title>
    <script type="importmap">
    {
    "imports": {
    "lodash": "https://esm.sh/[email protected]",
    "relative": "./relative.js",
    "absolute": "/absolute.js"
    }
    }
    </script>
    </head>
    <body>
    <script type="module">
    import _ from 'lodash';
    import relative from 'relative';
    import absolute from 'absolute';

    console.log(relative.data);
    console.log(absolute.data);

    const message = 'hello, world!';
    const capitalizedMessage = _.capitalize(message);

    console.log(capitalizedMessage);
    </script>
    </body>
    </html>