Skip to content

Instantly share code, notes, and snippets.

@llimllib
Last active March 20, 2022 20:08
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save llimllib/6730d9d01011e4031b2f1190740d9ad4 to your computer and use it in GitHub Desktop.
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
# run this first, then run `make` to build your bundle at `out.js`
npm install esbuild simplex-noise
import SimplexNoise from 'simplex-noise'
s = new SimplexNoise(Math.random);
console.log(s.noise2D(1.23, 2.34));
build:
./node_modules/.bin/esbuild index.js --bundle --outfile=out.js
<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