compatfactory v4.0.4 is a TypeScript library that unifies the TypeScript Compiler API factory functions across all TypeScript versions (3.x, 4.x, 5.x) and makes them conform with the Node Factory API. It solves the problem of different method signatures and availability across TypeScript versions, especially after the removal of old factory functions in TS 5.0. The library provides a single `ensureNodeFactory` function that accepts a `NodeFactory` or a `typescript` module and returns a normalized `NodeFactory` compatible with the latest API. It is actively maintained with frequent updates to support new TypeScript versions (e.g., v5.6, v5.5, v5.3 in v4.0.0). Key differentiators: simple wrapper, tiny footprint, supports all TypeScript versions in one package. Requires Node >=18.20.0.
npm install compatfactoryNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates using ensureNodeFactory to create a normalized NodeFactory, then creating an import declaration with a unified API.
Upgrade Node to >=18.20.0
Use named import: import { ensureNodeFactory } from 'compatfactory'Switch to named export ensureNodeFactory
Cache the factory if called frequently; avoid repeated calls in hot paths
Use import { ensureNodeFactory } from 'compatfactory' in an ESM context (package.json with "type": "module")Use named import: import { ensureNodeFactory } from 'compatfactory'Convert to ESM imports or use dynamic import: await import('compatfactory')No dependency data recorded yet.