morphir-elm

raw JSON →
2.100.0 verified Fri May 01 auth: no javascript

morphir-elm is an NPM package providing a CLI and Elm integration for the Morphir ecosystem (v2.100.0, active development, releases every few weeks). It parses Elm source code into Morphir IR (intermediate representation), enabling transpilation to Scala, TypeScript, and other languages, as well as visualization. Key differentiators: it bridges Elm's type system with FINOS's technology-agnostic Morphir format, supports both NPM and Elm package distribution, and includes a TypeScript SDK for structural equality and Maybe types. Alternatives include custom transpilers, but morphir-elm provides a standardised, multi-language pipeline.

error Error: Cannot find module 'morphir-elm'
cause Using top-level import instead of sub-path
fix
Use import from 'morphir-elm/ts-sdk/...' or install the Elm package.
error morphir-elm: command not found
cause Package not installed globally or not using npx
fix
Use npx morphir-elm or install globally: npm install -g morphir-elm
error Error: Unrecognized command: make (use -f flag)
cause New CLI requires -f flag for old behavior since v2.96.0
fix
Add -f flag: morphir-elm make -f
error Error: Module 'My.Package.Foo' not found in sourceDirectory
cause Missing or mismatched sourceDirectory in morphir.json
fix
Check morphir.json sourceDirectory and ensure Elm files are placed correctly.
breaking As of v2.96.0, CLI subcommand 'make' requires -f flag for old CLI; new CLI may break without it
fix Use -f flag: morphir-elm make -f
deprecated Gulp build system removed in v2.100.0
fix Use Mise and Bun for building; Gulp scripts no longer available.
gotcha The -f flag is recommended only; new CLI may become default in future breaking change
fix Monitor releases; update scripts to handle both old and new CLI.
gotcha TypeScript SDK exports are under sub-path 'morphir-elm/ts-sdk'; not at top-level
fix Import from 'morphir-elm/ts-sdk/Basics' etc.
deprecated Jest testing removed, replaced with Bun test runner in v2.100.0
fix Use bun test instead of jest.
breaking Elm source parsing may fail without morphir.json file; missing config
fix Ensure morphir.json exists in project directory with required fields.
npm install morphir-elm
yarn add morphir-elm
pnpm add morphir-elm

Creates a minimal Elm project, generates Morphir IR JSON via the CLI.

// Create morphir.json
{
  "name": "My.Package",
  "sourceDirectory": "src",
  "exposedModules": ["Foo"]
}

// In terminal:
mkdir -p src/My/Package
echo "module My.Package.Foo exposing (..)" > src/My/Package/Foo.elm
echo "foo = 42" >> src/My/Package/Foo.elm
npx morphir-elm make -f -p . -o morphir-ir.json

// morphir-ir.json now contains the IR