Skip to content

Instantly share code, notes, and snippets.

@davesnx
Last active January 3, 2024 17:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davesnx/8a8a84e00b4b903a32336cf294b7bb3c to your computer and use it in GitHub Desktop.
Save davesnx/8a8a84e00b4b903a32336cf294b7bb3c to your computer and use it in GitHub Desktop.
importMaps are cool
export default {
data: [1, 2, 3, 4],
};
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>importmap demo</title>
<script type="importmap">
{
"imports": {
"lodash": "https://esm.sh/lodash@4.17.21",
"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>
dev:
npx http-server -o .
export default {
data: [1, 2, 3, 4],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment