You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a Jaeger developer, I shouldn't need to rely on specific build plugins to optimize lodash imports.
Problem
Some components already import only the parts of the lodash library that they need, e.g. import map from 'lodash/map';, but some still import the entire library via e.g. import * as _ from 'lodash'; or import { debounce } from 'lodash';. The latter two stanzas only avoid importing the entire library because the current build happens to include the babel-import-plugin which optimizes these. Accidentally shipping all of lodash needlessly inflates the bundle size.
Proposal
Convert all lodash imports to lodash/subcomponent imports, or use lodash-es for ES imports that don't bring in the entire library.
Open questions
No response
The text was updated successfully, but these errors were encountered:
As a Jaeger developer, I shouldn't need to rely on specific build plugins to optimize lodash imports.
This kinda feels like an anti-requirement to me, because it means the developer always has to worry about importing in the right way, instead of the tooling taking care of it. It's easy to forget and inadvertently bring the whole lib into the bundle again.
Is there no equivalent plugin for Vite?
Alternatively, if we could enforce importing submodules only via a linter, then it would at least provide protection agains developer mistakes.
I think the automatic equivalent would be lodash-es, since that's lodash built as ES modules and thus imports like import { debounce } from 'lodash-es'; will automatically do the right thing.
I'll try some more with the current vite-plugin-imp; if we fix some problematic import * as _ imports, it should be able to cover the import { debounce } from 'lodash' rewrites.
Requirement
As a Jaeger developer, I shouldn't need to rely on specific build plugins to optimize
lodash
imports.Problem
Some components already import only the parts of the
lodash
library that they need, e.g.import map from 'lodash/map';
, but some still import the entire library via e.g.import * as _ from 'lodash';
orimport { debounce } from 'lodash';
. The latter two stanzas only avoid importing the entire library because the current build happens to include thebabel-import-plugin
which optimizes these. Accidentally shipping all oflodash
needlessly inflates the bundle size.Proposal
Convert all
lodash
imports tolodash/subcomponent
imports, or uselodash-es
for ES imports that don't bring in the entire library.Open questions
No response
The text was updated successfully, but these errors were encountered: