New:Microsoft Teams Notifications Are Now Available in Socket.Learn more
Get Started

lightning-dts

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

lightning-dts

Lightning-fast TypeScript .d.ts generator and bundler ⚡️

latest
Source
npmnpm
Version
0.1.2
Version published
Maintainers
1
Created
Source

⚡️ lightning-dts

Lightning-fast TypeScript .d.ts generator and bundler with sourcemap support and ability to resolve types from node_modules, all at blazing speed.

Benchmarks

ToolExecution TimeComparison
lightning-dts0.64ms ⚡️baseline
rolldown-plugin-dts49.51ms77.74x slower
rollup-plugin-dts84.43ms132.55x slower
dts-bundle-generator833.71ms1308.90x slower

Benchmarks run on identical code with sourcemap generation enabled

Features

  • Ultra-Fast: Generate TypeScript declaration files at lightning speed
  • Bundling: Not just generation, bundles all declarations into a single .d.ts file ready to ship
  • Sourcemaps: Full sourcemap support for better debugging with the same speed
  • Node Module Resolution: Seamlessly resolves types from node_modules
  • Configurable: Customize with TSConfig options

Installation

# npm
npm install lightning-dts --save-dev

# bun
bun add lightning-dts --dev

# pnpm
pnpm add lightning-dts -D

Usage

import { generateDts } from 'lightning-dts';

// Basic usage
const result = generateDts('./src/index.ts');

// With options
const result = generateDts('./src/index.ts', {
	rootDir: './src',
	sourcemap: true,
	stripInternal: true,
	preferredTsConfigPath: './tsconfig.build.json',
	resolve: true, // resolve all external modules from node_modules
});

// Access the generated declaration
console.log(result.code);

// Access sourcemap if enabled
console.log(result.map);

// Handle any errors
if (result.errors.length > 0) {
	console.error(result.errors);
}

API

generateDts(entryFilePath, options?)

Generates and bundles TypeScript declaration files.

Parameters

  • entryFilePath: Path to the entry TypeScript file
  • options: (Optional) Configuration options
    • rootDir: Root directory of the project (default: process.cwd())
    • preferredTsConfigPath: Path to the preferred tsconfig.json file (by default, the closest tsconfig.json will be used)
    • resolve: Controls which external modules should be resolved:
      • true to resolve all external modules
      • Array of strings or RegExp to match specific modules
      • false or undefined to disable external resolution
    • sourcemap: Generate sourcemap (default: false)
    • stripInternal: Remove declarations marked as @internal (default: false)

Returns

{
  code: string;     // The generated .d.ts content
  errors: OxcError[];  // Any errors encountered during generation
  map?: SourceMap;  // Sourcemap (if enabled)
}

Contributing

For guidelines on contributing, please read the contributing guide.

Keywords

typescript

FAQs

Package last updated on 02 May 2025

Related posts