Webpack TypeScript Resolution Plugin

2.0.1 · deprecated · verified Sun Apr 19

resolve-typescript-plugin is a webpack plugin designed to bridge the gap between TypeScript's ES Module output expectations and webpack's module resolution for ES Modules. It allows developers to import TypeScript files using a `.js` extension (e.g., `import { foo } from './bar.js'`) which aligns with native ES Module resolution behavior in Node.js and browsers, rather than webpack's default of requiring `.ts` or no extension. The current stable version is 2.0.1. Its release cadence has been infrequent since the introduction of an equivalent built-in feature in webpack. A key differentiator was solving the specific import extension problem for ESM TypeScript projects before webpack v5.74.0; now, its primary use case is for projects still on older webpack versions that require this specific resolution behavior. It is effectively in maintenance mode for older webpack versions, as webpack itself now offers `resolve.extensionAlias` for this functionality, making the plugin largely obsolete for modern webpack setups.

Common errors

Warnings

Install

Imports

Quickstart

Illustrates how to integrate the plugin into a webpack configuration for an ES Module TypeScript project, enabling `.js` extension imports for `.ts` files.

import ResolveTypeScriptPlugin from 'resolve-typescript-plugin';

/** @type {import('webpack').Configuration} */
export default {
    mode: 'development',
    entry: './src/index.ts',
    output: {
        filename: 'bundle.js',
        path: new URL('./dist', import.meta.url).pathname
    },
    module: {
        rules: [
            {
                test: /\.tsx?$/,
                use: 'ts-loader',
                exclude: /node_modules/
            }
        ]
    },
    resolve: {
        // It's recommended to remove .ts and .tsx from resolve.extensions when using this plugin
        extensions: ['.js', '.json'],
        plugins: [new ResolveTypeScriptPlugin()]
    },
    // Recommended for ES Module projects
    experiments: {
        outputModule: true
    }
};

view raw JSON →