https://github.com/morlay/typescript-plugin-lodash
https://github.com/morlay/typescript-plugin-lodash
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/morlay/typescript-plugin-lodash
- Owner: morlay
- Created: 2017-08-02T07:43:00.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-09-04T06:35:09.000Z (almost 9 years ago)
- Last Synced: 2025-04-19T12:45:55.125Z (about 1 year ago)
- Language: TypeScript
- Size: 32.2 KB
- Stars: 9
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## typescript-plugin-lodash
A simple typescript transform to cherry-pick Lodash modules so you don’t have to.
### Example
Transforms
```ts
import { map } from 'lodash';
import { add } from 'lodash/fp';
const addOne = add(1);
map([1, 2, 3], addOne);
```
roughly to
```ts
import * as map from 'lodash/map';
import * as add from 'lodash/fp/add';
const addOne = add(1);
map([1, 2, 3], addOne);
```
## Usage
like https://github.com/Igorbek/typescript-plugin-styled-components
```ts
// 1. import default from the plugin module
import { createLodashTransformer } from 'typescript-plugin-lodash');
// 2. add getCustomTransformer method to the loader config
var config = {
...
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
options: {
... // other loader's options
getCustomTransformers: () => ({ before: [createLodashTransformer()] })
}
}
]
}
...
};
```
## Notice
1. **No supports for `* as _`**
2. `lodash-es` will be force transformed to `lodash`
### `alias` in Webpack
please use `{ "lodash-es": "lodash" }` to replace `lodash-es` to `lodash` for smaller bundle size.