Webpack TypeScript Declaration Bundler

1.0.2 · maintenance · verified Tue Apr 21

types-webpack-bundler is a specialized webpack plugin designed to combine multiple TypeScript declaration files (`.d.ts`) generated by `ts-loader` (or similar tools) into a single, consolidated declaration file. Unlike standard declaration bundling which often produces external modules, this plugin recomposes declarations to mimic an 'internal module' structure, exposing classes and interfaces to a global-like module space. This is a fork of an unmaintained original library, updated to support Webpack 5. Its primary use case is highly niche: allowing external modules to behave like internal modules for specific scenarios, such as mapping prefixed URIs to module paths. The current stable version is 1.0.2. It does not have a stated regular release cadence and is described as an 'experimental setup' by its author, suggesting infrequent updates unless a specific need arises.

Common errors

Warnings

Install

Imports

Quickstart

This configuration demonstrates how to integrate `types-webpack-bundler` into a webpack setup with `ts-loader` to generate a bundled declaration file. It shows the plugin options `moduleName` and `out` in action.

import * as path from 'path';
import DeclarationBundlerPlugin from 'types-webpack-bundler';

export default {
    entry: './src/init.ts',
    output: {
        filename: './builds/bundle.js',
        path: path.resolve(__dirname, 'dist')
    },
    resolve: {
        extensions: ['.ts', '.tsx', '.js']
    },
    module: {
        rules: [
            {
                test: /\.ts(x?)$/,
                loader: 'ts-loader',
                options: {
                    compilerOptions: { declaration: true, outDir: './builds' } // ts-loader must generate declarations
                }
            }
        ]
    },
    plugins: [
        new DeclarationBundlerPlugin({
            moduleName:'some.path.moduleName',
            out:'./builds/bundle.d.ts',
            excludedReferences: []
        })
    ],
    mode: 'development' // or 'production'
};

view raw JSON →