{"id":20241,"library":"npm-dts-webpack-plugin","title":"npm-dts-webpack-plugin","description":"Webpack plugin (v1.3.13) that generates a single bundled index.d.ts file for an NPM package, enabling code intelligence in consumers without shipping TypeScript sources. It wraps the npm-dts library and runs the TypeScript compiler declaratively. Releases are infrequent (last update 2021) and the plugin is in maintenance mode. Key differentiator: simple integration into Webpack pipelines as a plugin rather than a separate CLI step.","status":"maintenance","version":"1.3.13","language":"javascript","source_language":"en","source_url":"https://github.com/vytenisu/npm-dts-webpack-plugin","tags":["javascript","webpack","dts","npm","package","ts","TypeScript","tsc","index.d.ts","typescript"],"install":[{"cmd":"npm install npm-dts-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add npm-dts-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add npm-dts-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core logic for generating the single .d.ts file","package":"npm-dts","optional":false},{"reason":"Required peer dependency to be used as a Webpack plugin","package":"webpack","optional":false}],"imports":[{"note":"Plugin does not ship ES module exports; use CommonJS require() or wrap in default import.","wrong":"import NpmDtsPlugin from 'npm-dts-webpack-plugin';","symbol":"NpmDtsPlugin","correct":"const NpmDtsPlugin = require('npm-dts-webpack-plugin');"},{"note":"Default import works in TypeScript or with ESM-aware bundlers but the package itself is CJS.","wrong":"","symbol":"NpmDtsPlugin (ESM)","correct":"import NpmDtsPlugin from 'npm-dts-webpack-plugin';"},{"note":"TypeScript types are provided; use type import for options interface.","wrong":"","symbol":"Options","correct":"import type { Options } from 'npm-dts-webpack-plugin';"}],"quickstart":{"code":"const NpmDtsPlugin = require('npm-dts-webpack-plugin');\nmodule.exports = {\n  entry: './src/index.ts',\n  output: { filename: 'bundle.js', path: __dirname + '/dist' },\n  resolve: { extensions: ['.ts', '.js'] },\n  module: { rules: [{ test: /\\.ts$/, use: 'ts-loader', exclude: /node_modules/ }] },\n  plugins: [new NpmDtsPlugin({\n    logLevel: 'info',\n    output: 'index.d.ts'\n  })]\n};","lang":"javascript","description":"Configures Webpack with the plugin to generate a bundled index.d.ts alongside the JavaScript bundle."},"warnings":[{"fix":"Update to Webpack 4 or 5 and Node >=10.","message":"Plugin requires Node.js >=10 and Webpack 4/5. Webpack 2/3 are not supported.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Set rootDir explicitly in tsconfig.json under compilerOptions.","message":"The plugin may fail if TypeScript rootDir is not correctly inferred; define rootDir in tsconfig.json to avoid issues.","severity":"breaking","affected_versions":"<1.3.0"},{"fix":"Remove force: true and address TypeScript errors in source.","message":"The force option is deprecated; non-critical errors should be fixed instead of ignored.","severity":"deprecated","affected_versions":">=1.2.0"},{"fix":"Use a single entry point or consider alternative dts generation tools.","message":"Plugin generates index.d.ts only; if multiple entry points exist, behavior is undefined.","severity":"breaking","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Ensure plugins: [new NpmDtsPlugin()] is placed inside module.exports.","cause":"Webpack configuration lacks a valid 'plugins' array or plugin is not instantiated correctly.","error":"TypeError: Cannot read property 'options' of undefined"},{"fix":"Create tsconfig.json or set root option: new NpmDtsPlugin({ root: __dirname })","cause":"Plugin needs a tsconfig.json in the project root or root option pointing to correct directory.","error":"Error: Could not find tsconfig.json"},{"fix":"Specify entry: new NpmDtsPlugin({ entry: 'src/main.ts' })","cause":"Entry file (default index.ts) is missing or entry option points to wrong path.","error":"error TS6053: File 'index.ts' not found"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}