Registry / devops / elm-optimize-level-2

elm-optimize-level-2

JSON →
library0.3.5jsnpmunverified

A CLI tool (v0.3.5) that applies a second level of optimization to the JavaScript output of the Elm compiler, producing faster code while maintaining Elm semantics. It can be used as a drop-in replacement for `elm make --optimize` and supports an `--optimize-speed` flag for even faster code at the cost of ~5% larger bundle size. The project is experimental and may introduce breaking changes. Key differentiators: Elm-specific JS transformations (e.g., tweaking record updates), active development with community benchmarks, and no built-in minification.

npm install elm-optimize-level-2
INSTALL
IMPORT
SIG · ELM-OPTIMIZE-LEVEL
E
elm-optimize-level-2
devopsjavascriptv0.3.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import { elmOptimizeLevel2 } from 'elm-optimize-level-2'
const elmOptimizeLevel2 = require('elm-optimize-level-2')
The package is ESM-only for Node >= 16 and ships TypeScript types. There is no CommonJS module export; using require() will fail.
CLI
npx elm-optimize-level-2 Main.elm
npm run elm-optimize-level-2
The package is primarily a CLI tool. To use programmatically, import the default export and call it with options.
types
import type { OptimizeOptions } from 'elm-optimize-level-2'
TypeScript types are bundled; use type import for TypeScript projects.

Shows installation, CLI usage with output filename and --optimize-speed flag, and programmatic compilation using ESM import with TypeScript.

// Install globally // $ npm install -g elm-optimize-level-2 // Then compile an Elm file: // $ elm-optimize-level-2 Main.elm --output app.js // Or with the --optimize-speed flag: // $ elm-optimize-level-2 Main.elm --optimize-speed --output app.js // Programmatic usage: import elmOptimizeLevel2 from 'elm-optimize-level-2'; import { promises as fs } from 'fs'; async function compile() { const result = await elmOptimizeLevel2({ entry: 'Main.elm', output: 'app.js', optimizeSpeed: false, }); await fs.writeFile('app.js', result.code); } compile();
elm-optimize-level-2 --version
Debug
Known issues
breakingelm-optimize-level-2 only generates JS files; it does not support HTML generation like `elm make`.
fix
Use a separate tool (e.g., elm-live) or serve the JS file with an HTML host.
affects: *
deprecatedThe `--optimize-speed` flag may produce ~5% larger bundle sizes. Consider whether asset size or runtime performance is more important.
fix
Do not use `--optimize-speed` if bundle size is a constraint.
affects: >=0.1.0
gotchaThis package is experimental and may break your Elm code in unexpected ways. Run your test suite after each compilation.
fix
Only use in production after thorough testing.
affects: *
gotchaDoes not minify or gzip the output; you must do that separately before deployment.
fix
Use a minifier like Terser and gzip before deploying.
affects: *
breakingRequires Node.js >= 16 and ES modules; does not support CommonJS.
fix
Set `"type": "module"` in your package.json or use `.mjs` extension.
affects: >=0.3.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module
The package is ESM-only and cannot be used with require() in CommonJS contexts.
fix
Use `import` or set "type": "module" in package.json.
elm-optimize-level-2: command not found
The package is not installed globally or not in PATH.
fix
Install globally: `npm install -g elm-optimize-level-2` or use `npx elm-optimize-level-2`.
elm-optimize-level-2: error: unrecognized argument: --help
The CLI does not support --help; try --help?
fix
Check documentation or README; run without arguments to see usage (if supported).
Upgrade
Version history
0.3.5latest on npm
Audit
Dependencies
elmrequiredRequires Elm to be installed globally to compile Elm code
Agent activity
4 hits · last 30 days
node
4
Resources
elm-optimize-level-2 — npm install elm-optimize-level-2 · libregistry