Modular import plugin for TypeScript, converting named imports like `import { Alert, Card } from 'antd'` into separate per-module imports and optional style imports. Version 3.0.0 requires TypeScript >= 4.8 and drops support for older versions. The plugin is commonly used with antd, antd-mobile, and other large libraries to enable tree shaking and reduce bundle size. It works with ts-loader, awesome-typescript-loader, rollup-plugin-typescript2, and @rollup/plugin-typescript. Key differentiator: operates at the TypeScript compiler level via custom transformers, unlike babel-plugin-import which requires Babel.
npm install ts-import-pluginVerified import paths — ran on the pinned version, not inferred.
Configures ts-loader with ts-import-plugin to transform antd imports to modular ones, enabling tree shaking.
Upgrade TypeScript to 4.8+ or use ts-import-plugin v2.x for TS < 4.8
Upgrade TypeScript to 4.2+ or use v1.x for TS < 4.2
Use named imports (e.g., `import { map } from 'lodash'`) to trigger the transformEnsure both tsconfig and webpack loader config have the module set to ES2015/ESNext
Change `import * as X from 'lib'` to `import { X } from 'lib'`.Upgrade TypeScript to >= 4.8 or downgrade ts-import-plugin to v2.x.
Set `libraryDirectory` to 'es' (or correct path) and ensure style path exists. Use `style: true` for default CSS or provide a custom resolver.