jaredpalmer / tsdx

Zero-config CLI for TypeScript package development
https://tsdx.io
MIT License
11.26k stars 508 forks source link

babel-plugin-lodash is not used but is misleadingly implied in the docs #763

Open zhaoyao91 opened 4 years ago

zhaoyao91 commented 4 years ago

The README says:

Note: TSDX will also transform destructured imports. For example, import { kebabCase } from 'lodash' would have also been transformed to `import o from "lodash-es/kebabCase".

But this is not the truth. the import {map} from 'lodash' result in import {map} from 'lodash-es' for esm and const lodash = require('lodash'); lodash.map ... for cjs. This prevents tree shaking for cjs.

jaredpalmer commented 4 years ago

Cc @TrySound

TrySound commented 4 years ago

I guess this is just a bad wording. I don't remember such feature were added to tsdx. The only optimisation it does is providing lodash for cjs and lodash-es for esm output. "Named to direct import" is the feature of https://github.com/lodash/babel-plugin-lodash

jaredpalmer commented 4 years ago

@zhaoyao91 can you submit a PR with a wording that makes most sense to you?

agilgur5 commented 4 years ago

I don't think this is a wording issue, that "Note" line is just incorrect. Seems to have been added in #97

I think the solution here is not to change the wording but to add babel-plugin-lodash in the correct plugin ordering such that this is possible. Otherwise, the entire line should be removed, and some other docs on lodash should be modified too

can you submit a PR with a wording that makes most sense to you?

Historically, OP has contributed many bug reports, but not code