ts-dynamic-plugin
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

npm downloads travis

ts-dynamic-plugin

module dynamic import plugin for TypeScript

Table of Contents

Installation

For use with node and npm:

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')

License

MIT License

Package Sidebar

Install

npm i ts-dynamic-plugin

Weekly Downloads

0

Version

0.1.2

License

MIT

Unpacked Size

6.51 kB

Total Files

8

Last publish

Collaborators

  • ddotjs