Electron Compilers

raw JSON →
5.9.0 verified Fri May 01 auth: no javascript maintenance

Provides compiler implementations (Babel, TypeScript, CoffeeScript, GraphQL, LESS, Stylus, Jade, CSON) for electron-compile in Electron apps. Current stable version is 5.9.0, but the package is in maintenance mode and tightly coupled to the deprecated electron-compile ecosystem. Key differentiator: designed to be a devDependency to avoid bloating production builds. Not actively developed; users are strongly advised to migrate to modern Electron tooling (e.g., Webpack, Vite).

error Error: Cannot find module 'babel-core'
cause electron-compilers expects babel-core installed as a peer dependency, but it may be missing or mismatched.
fix
Install the required Babel version: npm install babel-core@6.26.3 (for v5) or check README.
error Cannot find module 'typescript'
cause TypeScript compiler requires the typescript package installed but it is not declared as a dependency.
fix
Install typescript: npm install typescript@2.9.2 (or version compatible with your project).
error TypeError: Cannot read property 'transpile' of undefined
cause The BabelCompiler is initialized without a babelConfig or with invalid config, so babel is not properly set up.
fix
Provide a valid babelConfig object with presets/plugins (e.g., { presets: ['env'] }).
error Compiler 'jade' not found
cause Jade is deprecated and may not be installed; the compiler looks for a 'jade' module.
fix
If you need Jade support, install jade (npm install jade). Better: use pug instead.
deprecated The entire electron-compile ecosystem is deprecated. electron-compilers will not receive updates for modern compilers (e.g., Babel 7+).
fix Migrate to a modern build tool like Webpack, Rollup, or Vite.
breaking Version 5.0 removed support for Babel 5 and switched to Babel 6. Existing code relying on Babel 5 presets will break.
fix Update presets/plugins to Babel 6 compatible versions (e.g., 'babel-preset-es2015' -> '@babel/preset-env' with additional packages).
gotcha TypeScript compiler may not support all TypeScript 4+ features; only tested with TypeScript 2.x.
fix If using TypeScript >=3, consider using tsc directly instead of this compiler.
gotcha The Jade compiler expects the jade package, but jade was renamed to pug. The package uses the deprecated 'jade' npm package.
fix Use pug directly instead of the Jade compiler; or pin an old jade version.
breaking GraphQL compiler uses an outdated graphql-tag version; may not parse modern GraphQL schema syntax.
fix Process .graphql files with a current version of graphql-tag instead of relying on this compiler.
npm install electron-compilers
yarn add electron-compilers
pnpm add electron-compilers

Shows how to instantiate the BabelCompiler and use it with electron-compile's CompilerHost to compile a file.

import { BabelCompiler } from 'electron-compilers';
import { CompilerHost } from 'electron-compile';

const compiler = new BabelCompiler({
  babelConfig: {
    presets: ['@babel/preset-env', '@babel/preset-react']
  }
});

const host = new CompilerHost({
  compiler,
  cacheDir: './.compiler-cache'
});

host.compile('/path/to/input.js', 'path/to/output.js')
  .then(result => console.log('Compiled successfully', result))
  .catch(err => console.error('Compilation failed', err));