Last active
January 3, 2024 17:14
-
-
Save davesnx/8a8a84e00b4b903a32336cf294b7bb3c to your computer and use it in GitHub Desktop.
importMaps are cool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
data: [1, 2, 3, 4], | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dev: | |
npx http-server -o . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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