{"id":15750,"library":"parcel-resolver-elm-bundle","title":"Parcel Elm Bundle Resolver","description":"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.","status":"active","version":"1.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/ChristophP/parcel-resolver-elm-bundle","tags":["javascript","parcel","elm","compile","bundle"],"install":[{"cmd":"npm install parcel-resolver-elm-bundle","lang":"bash","label":"npm"},{"cmd":"yarn add parcel-resolver-elm-bundle","lang":"bash","label":"yarn"},{"cmd":"pnpm add parcel-resolver-elm-bundle","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This package is a Parcel resolver and requires Parcel to function.","package":"parcel","optional":false},{"reason":"The resolver compiles Elm source code and requires the Elm compiler.","package":"elm","optional":false}],"imports":[{"note":"This is a custom Parcel resolver import syntax. 'elm-bundle:widget-a' refers to a bundle defined in your `package.json`, not a direct file path. Parcel 2+ primarily uses ESM.","wrong":"const { Elm } = require('elm-bundle:widget-a');","symbol":"Elm","correct":"import { Elm } from 'elm-bundle:widget-a';"},{"note":"When using TypeScript, if you need to reference the type of the Elm application object, use a type-only import.","symbol":"Elm_Type","correct":"import type { Elm } from 'elm-bundle:widget-a';"}],"quickstart":{"code":"{\n  \"extends\": \"@parcel/config-default\",\n  \"resolvers\": [\"parcel-resolver-elm-bundle\", \"...\"]\n}\n\n// package.json\n{\n  \"name\": \"my-elm-app\",\n  \"version\": \"1.0.0\",\n  \"description\": \"My Elm application bundled with Parcel\",\n  \"main\": \"index.js\",\n  \"source\": \"index.html\",\n  \"scripts\": {\n    \"start\": \"parcel\",\n    \"build\": \"parcel build\"\n  },\n  \"elm-bundle\": {\n    \"widget-a\": [\n      \"./src/Main.elm\",\n      \"./src/MainB.elm\",\n      \"./src/MainC.elm\"\n    ]\n  },\n  \"devDependencies\": {\n    \"parcel\": \"^2.6.2\",\n    \"parcel-resolver-elm-bundle\": \"^1.0.0\"\n  },\n  \"peerDependencies\": {\n    \"elm\": \"^0.19.1-5\"\n  }\n}\n\n// src/index.js\nimport { Elm } from 'elm-bundle:widget-a';\n\nconst app = Elm.Main.init({\n  node: document.getElementById('elm-app')\n});\n\n// Example: Interact with Elm ports (if defined in Main.elm)\n// app.ports.fromElm.subscribe(message => {\n//   console.log('Received from Elm:', message);\n// });\n\n// app.ports.toElm.send('Hello from JavaScript!');\n","lang":"javascript","description":"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."},"warnings":[{"fix":"Ensure `parcel-resolver-elm-bundle` is listed before other generic resolvers (like `...`) in your `.parcelrc` resolvers array: `\"resolvers\": [\"parcel-resolver-elm-bundle\", \"...\"]`.","message":"Incorrect resolver order in `.parcelrc` can prevent `parcel-resolver-elm-bundle` from being invoked, leading to 'Module not found' errors or incorrect Elm compilation.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade Parcel to `^2.6.2` or higher to ensure compatibility with the resolver. Run `npm install parcel@latest` or `yarn add parcel@latest`.","message":"Using an older Parcel version than specified in `engines` may cause compatibility issues or build failures, as Parcel's internal resolver APIs can change significantly between major versions.","severity":"gotcha","affected_versions":"<2.6.2"},{"fix":"Install Elm globally via `npm install -g elm` or as a dev dependency `npm install --save-dev elm`, ensuring it's accessible to your build environment.","message":"The resolver depends on the `elm` compiler being available. If `elm` is not installed or discoverable in the system's PATH, compilation will fail.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Verify `parcel-resolver-elm-bundle` is in your `.parcelrc` before `...`, and ensure the `elm-bundle` section in `package.json` correctly defines `widget-a` with valid paths to Elm entry files.","cause":"The Parcel resolver for `elm-bundle` is not correctly configured or active, or the bundle name (`widget-a`) is misspelled or not defined in `package.json`.","error":"Module not found: Can't resolve 'elm-bundle:widget-a'"},{"fix":"Install Elm globally or locally: `npm install -g elm` or `npm install --save-dev elm` (if using `npx elm`). Ensure it's available in your system's PATH or `node_modules/.bin`.","cause":"The `elm` peer dependency is missing or not correctly installed/accessible in the project environment.","error":"Error: Could not find Elm executable. Please install Elm: elm install"},{"fix":"Double-check all file paths within your `package.json` `elm-bundle` definitions. Paths must be relative to the `package.json` file itself.","cause":"A file path specified in the `elm-bundle` array in `package.json` is incorrect, or the file does not exist at the specified relative path.","error":"Error: Failed to resolve entry point \"./src/Main.elm\" (or similar path error)"}],"ecosystem":"npm"}