0.0.2 • Published 3 months ago
@silentflick/esm-extractor v0.0.2
ESM Extractor
This project automates the extraction of TypeScript exports from a given package and aggregates them into a single
declaration file (index.d.ts
). This file can then be used as a unified type definition bundle for tooling, such as
compiling ESM modules to CommonJS with esbuild.
Overview
The project is divided into three main components:
- Extractor Module: Recursively scans a target package’s directory, reads TypeScript files, and collects export declarations.
- Generator Module: Processes the collected export declarations and generates a single aggregated declaration file.
- Updator Module: (Optional) Reads the project's package.json, locates the dependency version for the target package, and updates the project's version accordingly. This ensures consistency between the library version and the package version used.
Usage
The script accepts the following options:
-p, --packageName
(required): The name of the package from which to extract exports.-o, --output
(optional): The output directory whereindex.d.ts
will be generated. Defaults to the current script directory if not provided.-j, --packageJson
(optional): The path to thepackage.json
file. Defaults topackage.json
in the current directory.-u, --update
(optional): Flag to update the project's version based on the version of the extracted package. Defaults tofalse
.