Skip to content

Latest commit

 

History

History
62 lines (49 loc) · 1.73 KB

README.md

File metadata and controls

62 lines (49 loc) · 1.73 KB

esbuild-plugin-gleam

A small wrapper around the Gleam build script for use with esbuild.

Prerequisites

This plugin assumes that there is a gleam executable available on the current PATH. Installation instructions are available on the Gleam website.

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:

    $ npm install https://github.com/jim/esbuild-plugin-gleam
  2. Add the GleamPlugin to your esbuild script (for example, build.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:

    "scripts": {
        "build": "node ./build.js",
    },
  4. Add the following to the top level of your package.json file:

    "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.