The `dprint-node` package provides a high-performance Node.js API for integrating the `dprint` TypeScript and JavaScript code formatter into applications. Leveraging Rust via `napi-rs`, it offers significantly faster formatting speeds compared to traditional JavaScript-based formatters like Prettier, a key differentiator showcased in its benchmarks. The library is currently stable at version 1.0.8, with a focus on active maintenance, indicated by consistent patch releases addressing bug fixes and internal dependency updates. Its core functionality involves a simple `dprint.format` method, which accepts a file path, the code string, and an optional configuration object, enabling developers to programmatically apply `dprint`'s extensive formatting rules for TypeScript, JavaScript, and JSX/TSX syntax. Users can customize formatting behavior by passing configuration options that align with the `dprint` plugin documentation.
npm install dprint-nodeVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to format a TypeScript code string using `dprint-node` with custom configuration options for line width, semi-colons, indentation, and quote style, logging both the original and formatted output.
Upgrade to `dprint-node@1.0.5` or later to ensure complete type declarations are available.
Update to `dprint-node@1.0.3` or newer to resolve the stability issues on Apple Silicon devices.
Always refer to the official `dprint` plugin configuration documentation (e.g., `dprint.dev/plugins/typescript/config/`) to ensure correct and valid options are passed. Consider creating a local TypeScript interface for your configuration objects based on the dprint schema for better type safety.
Run `npm install dprint-node` or `yarn add dprint-node` to add the package to your project dependencies.
Ensure you are using `const dprint = require('dprint-node');` for CommonJS or `import dprint from 'dprint-node';` for ES Modules, as the library exports its primary functionality as a default object.Consult the official `dprint` plugin configuration documentation (e.g., `dprint.dev/plugins/typescript/config/`) for valid options. Ensure the option name and value type match the expected schema.
No dependency data recorded yet.