gerber-parser is a JavaScript/TypeScript library that provides a streaming parser for Gerber (RS-274X) and NC drill files, commonly used for Printed Circuit Board (PCB) manufacturing. It functions as a Node.js transform stream, taking a text stream of a Gerber file and emitting structured JavaScript objects representing the file's contents, which can then be consumed by PCB visualization or plotting tools. The library is part of the Tracespace collection of open-source PCB visualization tools. The current stable version is 4.2.7. While a precise release cadence isn't explicitly stated, the project maintains an active development cycle within the Tracespace ecosystem, with major versions introducing breaking changes to improve parsing accuracy and specification compliance. Its key differentiator is its streaming architecture, allowing efficient processing of large Gerber files without loading the entire content into memory, and its explicit focus on the Gerber X2 standard for enhanced data integrity.
npm install gerber-parserVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to create a `gerber-parser` instance, pipe a Gerber file stream into it, and handle data, warnings, and completion events.
Ensure all Gerber files passed to the parser conform to the Gerber X2 standard. If processing older Gerber files is necessary, consult the API documentation for options to disable this strict validation, though it's not recommended for production.
For modern browser applications, bundle `gerber-parser` using a module bundler. For simple script tag inclusion, ensure you use the `dist/gerber-parser.min.js` file and access the global `gerberParser` variable.
Always attach an `on('warning', handler)` listener to the parser stream to log or handle these warnings. This helps identify and address potential issues in the Gerber input files.Convert the Gerber file to the X2 standard or ensure it is a valid X2 file. Alternatively, if explicitly needed and understood, consult the `gerber-parser` API documentation for options to relax X2 strictness (though generally not recommended).
For ES Modules, use `import gerberParser from 'gerber-parser';`. For CommonJS, use `const gerberParser = require('gerber-parser');`. The module exports a function that you call directly to get a stream instance (e.g., `const parser = gerberParser();`).No dependency data recorded yet.