https://github.com/jetsly/ts-dynamic-plugin
Modular dynamic plugin for TypeScript
https://github.com/jetsly/ts-dynamic-plugin
dynamic ts-dynamic-plugin ts-loader typescript
Last synced: 11 months ago
JSON representation
Modular dynamic plugin for TypeScript
- Host: GitHub
- URL: https://github.com/jetsly/ts-dynamic-plugin
- Owner: Jetsly
- License: mit
- Created: 2019-01-10T03:36:12.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-18T05:22:51.000Z (over 7 years ago)
- Last Synced: 2025-07-23T19:47:59.016Z (12 months ago)
- Topics: dynamic, ts-dynamic-plugin, ts-loader, typescript
- Language: TypeScript
- Homepage: https://npm.im/ts-dynamic-plugin
- Size: 6.84 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# ts-dynamic-plugin
> module dynamic import plugin for TypeScript
## Table of Contents
- [Install](#install)
- [Usage](#usage)
- [Examples](#examples)
- [License](#license)
## Installation
For use with [node](http://nodejs.org) and [npm](https://npmjs.com):
```sh
npm install --save-dev ts-dynamic-plugin
```
## Usage
### With ts-loader
```js
// 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
```js
tsDynamicPluginFactory({
funcName:'formatLocale',
importDecla:`import { formatLocale } from './utils/locale'`
})
```
```js
const word = formatLocale('test')
/** will auto add import **/
import { formatLocale } from './utils/locale'
const word = formatLocale('test')
```
## License
[MIT License](LICENSE.md)