ngc-esbuild
raw JSON → 0.0.83 verified Fri May 01 auth: no javascript
An experimental Angular compiler leveraging esbuild for ultra-fast builds, claiming 50x faster than ng build. Current version 0.0.83 (alpha). Release cadence is irregular with frequent updates. Maintained by the community (cherryApp). Supports SCSS, loadChildren, and partial Angular features like templateUrl and angular.json styles/scripts, but many limitations exist (e.g., only one styleUrls). For developers willing to trade off completeness for speed in early-stage projects.
Common errors
error TypeError: NgcEsbuild is not a constructor ↓
cause Forgetting 'new' keyword when instantiating the class.
fix
Use 'new NgcEsbuild({...})' instead of 'NgcEsbuild({...})'.
error Cannot find module 'ngc-esbuild' ↓
cause Package not installed or incorrect import path.
fix
Run 'npm install ngc-esbuild' and use 'const NgcEsbuild = require('ngc-esbuild');'
error resolve is not a function ↓
cause Attempting to call resolve() as a method instead of accessing it as a Promise property.
fix
Use 'builder.resolve.then(...)' not 'builder.resolve(...)'.
Warnings
breaking The package is in early alpha; APIs may change without notice. ↓
fix Pin to a specific version and test updates thoroughly.
gotcha Only one styleUrls entry is supported due to a limitation in internal plugin. ↓
fix Merge multiple stylesheets into one file or use a different bundler if more are needed.
gotcha The 'resolve' property is a Promise, not a method. Calling it as a function will result in 'resolve is not a function' error. ↓
fix Use builder.resolve.then() instead of builder.resolve().
deprecated The option 'outpath' is used in the quickstart, but esbuild uses 'outdir'. Check if both are supported. ↓
fix Prefer 'outdir' for consistency with esbuild, but test if 'outpath' still works.
gotcha The package has limited Angular feature support: no ViewEncapsulation.Emulated, no i18n, no lazy loading via Angular Router (though loadChildren is mentioned as handled). ↓
fix Use Angular CLI's default build for production-grade features; consider ngc-esbuild only for rapid prototyping.
Install
npm install ngc-esbuild yarn add ngc-esbuild pnpm add ngc-esbuild Imports
- NgcEsbuild (default) wrong
import NgcEsbuild from 'ngc-esbuild';correctconst NgcEsbuild = require('ngc-esbuild'); - NgcEsbuild constructor options wrong
NgcEsbuild({ port: 4200 }) // missing 'new'correctnew NgcEsbuild({ port: 4200, serve: true }) - resolve promise wrong
instance.resolve() // resolve is a property, not a methodcorrectinstance.resolve.then(result => console.log(result))
Quickstart
const NgcEsbuild = require('ngc-esbuild');
const builder = new NgcEsbuild({
main: 'src/main.ts',
outpath: 'dist/esbuild',
minify: true,
open: false,
port: 9855,
sourcemap: true,
serve: true,
});
builder.resolve.then(
(result) => console.log('Build succeeded:', result)
).catch(err => console.error('Build failed:', err));