Parcel Elm Bundle Resolver

1.0.2 · active · verified Tue Apr 21

parcel-resolver-elm-bundle is a Parcel resolver designed to streamline the compilation and bundling of multiple Elm source files into a single JavaScript output. It simplifies the process that would otherwise require manually listing all Elm entry points for `elm make`. The package is currently at version 1.0.2, indicating a stable, actively maintained release. While release cadence isn't explicitly stated, its integration with Parcel's resolver system suggests updates would align with major Parcel releases or significant Elm compiler changes. Its key differentiator is the custom `elm-bundle:` import syntax, allowing developers to define Elm bundles within their `package.json` and reference them abstractly, enhancing modularity and build system clarity for Elm projects within Parcel. This approach mimics the `elm make MainA.elm MainB.elm` command but integrates it directly into the JavaScript import graph, providing a seamless development experience for larger Elm applications.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to configure Parcel to use the `elm-bundle` resolver via `.parcelrc`, define an Elm bundle named 'widget-a' in `package.json`, and then import the compiled bundle into a JavaScript entry point for initialization.

{
  "extends": "@parcel/config-default",
  "resolvers": ["parcel-resolver-elm-bundle", "..."]
}

// package.json
{
  "name": "my-elm-app",
  "version": "1.0.0",
  "description": "My Elm application bundled with Parcel",
  "main": "index.js",
  "source": "index.html",
  "scripts": {
    "start": "parcel",
    "build": "parcel build"
  },
  "elm-bundle": {
    "widget-a": [
      "./src/Main.elm",
      "./src/MainB.elm",
      "./src/MainC.elm"
    ]
  },
  "devDependencies": {
    "parcel": "^2.6.2",
    "parcel-resolver-elm-bundle": "^1.0.0"
  },
  "peerDependencies": {
    "elm": "^0.19.1-5"
  }
}

// src/index.js
import { Elm } from 'elm-bundle:widget-a';

const app = Elm.Main.init({
  node: document.getElementById('elm-app')
});

// Example: Interact with Elm ports (if defined in Main.elm)
// app.ports.fromElm.subscribe(message => {
//   console.log('Received from Elm:', message);
// });

// app.ports.toElm.send('Hello from JavaScript!');

view raw JSON →