Package Exports
- ts-import-plugin
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ts-import-plugin) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
ts-import-plugin
Modular import plugin for TypeScript, compatible with antd, antd-mobile and so on.
webpack template ./webpack.config.js, run: npm start to see the bundle analyzer.

Why use this
transform such code:
import { Alert, Card as C } from 'antd'into:
import Alert from 'antd/lib/alert'
import 'antd/lib/alert/style/index.less'
import { default as C } from 'antd/lib/card'
import 'antd/lib/card/style/index.less'Usage
With ts-loader
// webpack.config.js
const tsImportPluginFactory = require('ts-import-plugin')
module.exports = {
// ...
module: {
rules: [
{
test: /\.(jsx|tsx|js|ts)$/,
loader: 'ts-loader',
options: {
transpileOnly: true,
getCustomTransformers: () => ({
before: [ tsImportPluginFactory( /** options */) ]
}),
compilerOptions: {
module: 'es2015'
}
},
exclude: /node_modules/
}
]
},
// ...
}With awesome-typescript-loader
Due to https://github.com/s-panferov/awesome-typescript-loader/issues/447, awesome-typescript-loader is not working with any TypeScript plugin, include this one.
Options
options can be an object:
libraryName
stringdefault
'antd'style
boolean | 'css'default
falselibraryDirectory
stringdefault
'lib'camel2DashComponentName
booleandefault
truecamel2UnderlineComponentName
booleandefault
false
example:
tsImportPluginFactory({
libraryName: 'antd',
libraryDirectory: 'lib',
style: true
}){
libraryName: 'material-ui',
libraryDirectory: 'components',
camel2DashComponentName: false
}options can be an array:
example:
[
{
libraryName: 'antd',
libraryDirectory: 'lib',
style: true
}, {
libraryName: 'material-ui',
libraryDirectory: 'components',
camel2DashComponentName: false
}
]