embark-compiler

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

Embark compiler module that abstracts the compiler interface and exposes a plugin API for contract extensions. Current stable version is 6.0.0, part of the Embark framework (release cadence: major versions every 6-12 months, nightly releases). Key differentiators: integrates with Solidity (solc), supports plugin-based compiler registration, and provides a command-driven compilation flow. Compared to alternatives like Truffle Compile, it is tightly coupled with the Embark ecosystem and uses a unique event-based request pattern.

error Cannot find module 'embark-core'
cause embark-core is a peer dependency not automatically installed.
fix
Run 'npm install @embark/core' or ensure Embark framework is properly installed.
error Error: ContractSimpleStorage.sol not found
cause File path does not match the contract's actual file path in the resolver.
fix
Set path to the contract's original filename, e.g., 'SimpleStorage.sol'.
error TypeError: contractFiles is not iterable
cause File objects passed in an incorrect format or not an array.
fix
Wrap File in an array: [new File({...})].
breaking embark-compiler v6.0.0 drops support for Node <10.17.0 and npm <6.11.3.
fix Upgrade Node to >=10.17.0 and npm to >=6.11.3 or yarn >=1.19.1.
deprecated The old callback-based plugin API (registerCompiler) may be removed in future versions.
fix Use the event-based request pattern instead (compiler:contracts:compile).
gotcha File objects must include a 'type' property; omitting it may cause errors.
fix Always set type: 'custom' or appropriate value when creating File instances.
gotcha Compilation options parameter is required and must include isCoverage (boolean).
fix Pass { isCoverage: false } if not using coverage.
npm install embark-compiler
yarn add embark-compiler
pnpm add embark-compiler

Compiles a Solidity contract using Embark's event-based request system, showing the minimal setup with a File object.

import { File } from 'embark-core';
const contractFiles = [new File({
  path: 'SimpleStorage.sol',
  type: 'custom',
  resolver: (cb) => cb('pragma solidity ^0.5.0; contract SimpleStorage { uint storedData; }')
})];
embark.events.request('compiler:contracts:compile', contractFiles, { isCoverage: false }, (err, compiledObject) => {
  if (err) { console.error(err); return; }
  console.log('Bytecode:', compiledObject.runtimeBytecode);
});