ts-dynamic-plugin
v0.1.2
Published
module dynamic import plugin for TypeScript
Downloads
4
Maintainers
Readme
ts-dynamic-plugin
module dynamic import plugin for TypeScript
Table of Contents
Installation
npm install --save-dev ts-dynamic-plugin
Usage
With ts-loader
// webpack.config.js
const tsDynamicPluginFactory = require('ts-dynamic-plugin')
module.exports = {
// ...
module: {
rules: [
{
test: /\.(jsx|tsx|js|ts)$/,
loader: 'ts-loader',
options: {
getCustomTransformers: () => ({
before: [ tsDynamicPluginFactory( /** options */) ]
}),
},
exclude: /node_modules/
}
]
},
// ...
}
Examples
tsDynamicPluginFactory({
funcName:'formatLocale',
importDecla:`import { formatLocale } from './utils/locale'`
})
const word = formatLocale('test')
/** will auto add import **/
import { formatLocale } from './utils/locale'
const word = formatLocale('test')