Last active
March 20, 2022 20:08
-
-
Save llimllib/6730d9d01011e4031b2f1190740d9ad4 to your computer and use it in GitHub Desktop.
The simplest possible use of esbuild to import a package and run a function in the browser
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
# run this first, then run `make` to build your bundle at `out.js` | |
npm install esbuild simplex-noise |
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
import SimplexNoise from 'simplex-noise' | |
s = new SimplexNoise(Math.random); | |
console.log(s.noise2D(1.23, 2.34)); |
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
build: | |
./node_modules/.bin/esbuild index.js --bundle --outfile=out.js |
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
<html> | |
<head> | |
<script src="out.js"></script> | |
</head> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment