Knitwork is a utility library designed for programmatic generation of JavaScript and TypeScript code. It provides functions to construct various language constructs, including ESM `import` and `export` statements, dynamic imports, and TypeScript-specific elements like type imports, interfaces, and module augmentations. The library also offers robust serialization utilities for converting JavaScript objects and arrays into string representations, with options for raw or escaped values, and string escaping functions. Currently at stable version 1.3.0, Knitwork is actively maintained within the unjs ecosystem, receiving regular updates with a focus on modern JavaScript practices (ESM-first) and TypeScript integration. Its key differentiator lies in offering granular control over code generation for tasks like bundler plugins, build-time optimizations, and code transformation, providing a lower-level API compared to full AST manipulation libraries.
npm install knitworkVerified import paths — ran on the pinned version, not inferred.
Demonstrates generating various JavaScript and TypeScript code snippets, including imports, object serialization, interfaces, and exports using Knitwork's core utilities.
Use `import { someUtility } from 'knitwork';` instead of `const { someUtility } = require('knitwork');`.For objects containing string, number, or boolean values that need proper JavaScript serialization, use `genObjectFromValues`. Use `genObjectFromRaw` only when values are guaranteed to be valid, raw JavaScript expressions.
Upgrade to Knitwork v1.1.0 or newer to ensure the `singleQuotes` option in `genString` is respected.
Update Knitwork to version 1.3.0 or higher to correctly generate module augmentations without extra commas.
Change your import statements to use ES module syntax: `import { genImport } from 'knitwork';`Ensure you are using `import { functionName } from 'knitwork';` for named exports, and that your environment supports ES Modules or is correctly configured for transpilation if using CJS.Run `npm install knitwork`, `yarn add knitwork`, or `pnpm add knitwork` to install the package. If the error persists, check your module resolution configuration.
No dependency data recorded yet.