https://github.com/jim/esbuild-plugin-gleam
Build Gleam projects with esbuild
https://github.com/jim/esbuild-plugin-gleam
esbuild gleam gleam-lang
Last synced: over 1 year ago
JSON representation
Build Gleam projects with esbuild
- Host: GitHub
- URL: https://github.com/jim/esbuild-plugin-gleam
- Owner: jim
- License: mit
- Created: 2021-11-01T17:44:26.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-11-09T23:05:00.000Z (over 4 years ago)
- Last Synced: 2025-01-29T17:25:12.175Z (over 1 year ago)
- Topics: esbuild, gleam, gleam-lang
- Language: JavaScript
- Homepage:
- Size: 58.6 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# esbuild-plugin-gleam
A small wrapper around [the Gleam build script](https://github.com/gleam-lang/template-gleam-javascript/blob/main/bin/build.js) for use with [esbuild](https://esbuild.github.io).
## Prerequisites
This plugin assumes that there is a `gleam` executable available on the current PATH. Installation instructions are available on [the Gleam website](https://gleam.run/getting-started/).
## Project Setup
To use this esbuild plugin, [you will need to use the JavaScript API](). For an example of a complete setup, see the `examples` directory.
You'll want to:
1. Add this plugin to your package's dependencies:
```console
$ npm install https://github.com/jim/esbuild-plugin-gleam
```
2. Add the GleamPlugin to your esbuild script (for example, `build.js`):
```js
import esbuild from 'esbuild';
import { GleamPlugin } from 'esbuild-plugin-gleam';
esbuild.build({
entryPoints: ['src/index.js'],
bundle: true,
outdir: 'dist',
plugins: [
GleamPlugin()
]
}).catch(_e => process.exit(1));
```
3. Add the build script to `package.json`:
```json
"scripts": {
"build": "node ./build.js",
},
```
4. Add the following to the top level of your `package.json` file:
```json
"gleamDependencies": [
{
"name": "gleam_stdlib",
"ref": "main",
"url": "https://github.com/gleam-lang/stdlib.git"
},
{
"name": "gleam_javascript",
"ref": "main",
"url": "https://github.com/gleam-lang/javascript.git",
"dependencies": [
"gleam_stdlib"
]
}
]
```
5. Run `npm run build` to build your project.