Registry / devops / webpack-fix-default-import-plugin

webpack-fix-default-import-plugin

JSON →
library1.0.3jsnpmunverified

Webpack plugin that hooks into require() to polyfill module.exports.default for non-ES6 modules, enabling default imports (e.g., import React from 'react') when using TypeScript compiled to ES5. Current version 1.0.3 (last release), stable with no recent updates. Differentiators: avoids the need for a two-pass TypeScript→ES6→Babel pipeline, preserving source maps and reducing build time. Compatible with CommonJS output from TypeScript. Lightweight and specific to webpack + TypeScript workflows.

npm install webpack-fix-default-import-plugin
INSTALL
IMPORT
SIG · WEBPACK-FIX-DEFAUL
W
webpack-fix-default-import-plugin
devopsjavascriptv1.0.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

FixDefaultImportPlugin
const FixDefaultImportPlugin = require('webpack-fix-default-import-plugin');
import FixDefaultImportPlugin from 'webpack-fix-default-import-plugin';
Package is CommonJS-only; ES import will break. Use require() in webpack config.
FixDefaultImportPlugin
plugins: [new FixDefaultImportPlugin()]
plugins: [FixDefaultImportPlugin]
Must instantiate with new. Common mistake: passing the class directly.
FixDefaultImportPlugin
new FixDefaultImportPlugin()
new FixDefaultImportPlugin({})
Constructor takes no arguments. Options object not supported.

Basic webpack configuration to enable default imports from CommonJS modules using TypeScript compiled to ES5.

// webpack.config.js var FixDefaultImportPlugin = require('webpack-fix-default-import-plugin'); module.exports = { entry: './src/index.ts', output: { filename: 'bundle.js' }, module: { rules: [ { test: /\.tsx?$/, use: 'ts-loader', exclude: /node_modules/ } ] }, resolve: { extensions: ['.tsx', '.ts', '.js'] }, plugins: [ new FixDefaultImportPlugin() ] };
Debug
Known issues
gotchaThe plugin only works when TypeScript targets ES5 with CommonJS module output. It does not support ES modules or other targets.
fix
Ensure tsconfig.json has: "target": "es5", "module": "commonjs", "allowSyntheticDefaultImports": true.
affects: >=0.0.0
gotchaThe plugin does not handle all edge cases (e.g., modules that intentionally have no default export). It may incorrectly assign a value to module.exports.default.
fix
Test modules individually; consider using allowSyntheticDefaultImports and esModuleInterop in TypeScript instead.
affects: >=0.0.0
deprecatedTypeScript 2.7+ includes esModuleInterop which solves this issue natively; consider upgrading instead of using this plugin.
fix
Set "esModuleInterop": true in tsconfig.json and remove this plugin.
affects: >=0.0.0
gotchaPlugin version 1.0.3 fixes compatibility with axios v2; older versions may break with axios imports.
fix
Upgrade to >=1.0.3.
affects: <1.0.3
Errors
Common errors & fixes
Module not found: Error: Can't resolve 'webpack-fix-default-import-plugin'
Plugin not installed or referenced correctly in webpack config.
fix
Run: npm install --save-dev webpack-fix-default-import-plugin and require it using correct path.
TypeError: FixDefaultImportPlugin is not a constructor
Importing the plugin incorrectly (e.g., using ES import syntax on a CommonJS module).
fix
Use: const FixDefaultImportPlugin = require('webpack-fix-default-import-plugin');
Default import still not working after adding plugin
TypeScript configuration missing allowSyntheticDefaultImports or not compiling to CommonJS.
fix
Set "allowSyntheticDefaultImports": true and "module": "commonjs" in tsconfig.json.
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
12 hits · last 30 days
node
10
Amazon
1
Resources
webpack-fix-default-import-plugin — npm install webpack-fix-default-import-plugin · libregistry