Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use babel-plugin-lodash to optimize lodash imports #525

Merged
merged 2 commits into from
Oct 3, 2019

Conversation

zetoke
Copy link
Contributor

@zetoke zetoke commented Oct 1, 2019

Currently mobx-react-form includes the whole lodash during bundling.
Using the approach with babel-plugin-lodash and making lodash imports more granular I reduced size of my app by around 25kb that is pretty good size.

Before:

var _lodash = require('lodash');

var _lodash2 = _interopRequireDefault(_lodash);

After:

var _isBoolean2 = require('lodash/isBoolean');

var _isBoolean3 = _interopRequireDefault(_isBoolean2);

var _uniqueId2 = require('lodash/uniqueId');

var _uniqueId3 = _interopRequireDefault(_uniqueId2);

@codecov-io
Copy link

codecov-io commented Oct 1, 2019

Codecov Report

Merging #525 into master will decrease coverage by 0.02%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #525      +/-   ##
==========================================
- Coverage    96.6%   96.58%   -0.03%     
==========================================
  Files         130      130              
  Lines        2625     2605      -20     
==========================================
- Hits         2536     2516      -20     
  Misses         89       89
Impacted Files Coverage Δ
src/Base.js 55.17% <0%> (-1.5%) ⬇️
src/Options.js 90.9% <0%> (-0.76%) ⬇️
src/Validator.js 87.23% <0%> (-0.27%) ⬇️
src/validators/VJF.js 88.88% <0%> (-0.25%) ⬇️
src/validators/YUP.js 95.83% <0%> (-0.17%) ⬇️
src/State.js 91.83% <0%> (-0.17%) ⬇️
src/Form.js 92.15% <0%> (-0.16%) ⬇️
src/shared/Events.js 96.87% <0%> (-0.1%) ⬇️
src/Field.js 80.67% <0%> (-0.1%) ⬇️
src/utils.js 95.23% <0%> (-0.08%) ⬇️
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ab714fd...ccce4db. Read the comment docs.

@foxhound87
Copy link
Owner

foxhound87 commented Oct 2, 2019

I already tried this package.
The issue is that introducing babel-plugin-lodash, the UMD build will not work anymore.

Related: #58 #75 #124 #294

@zetoke
Copy link
Contributor Author

zetoke commented Oct 3, 2019

@foxhound87 in this case, will the separate babel configs work for you?
Like .umd.babelrc and .cjs.babelrc ? Or babel.umd.config.js and babel.cjs.config.js

@zetoke
Copy link
Contributor Author

zetoke commented Oct 3, 2019

It should be possible to use configFile option for this one https://babeljs.io/docs/en/options#configfile
And one config will extend another one.

@foxhound87
Copy link
Owner

@zetoke ok try this solution.

@zetoke
Copy link
Contributor Author

zetoke commented Oct 3, 2019

@foxhound87 I've found an easier workaround ccce4db
It eliminates problems with config merging and extending since babel cli does not have any params to point custom config file name 😞

@foxhound87 foxhound87 merged commit ccce4db into foxhound87:master Oct 3, 2019
@foxhound87
Copy link
Owner

Great job! I merged and released.

@foxhound87
Copy link
Owner

🎉 This PR is included in version 2.0.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

@zetoke
Copy link
Contributor Author

zetoke commented Oct 3, 2019

@foxhound87 thank you very much! 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants