wix-incubator / react-templates

Light weight templates for react
https://wix.github.io/react-templates
MIT License
2.82k stars 207 forks source link

to be lightweight templates for React, we shouldn't bundle lodash into the build #233

Open rileylnapier opened 6 years ago

rileylnapier commented 6 years ago

im a little bit upset about having 7kb bloating my build because of this library.

these seem to be what you need based on poking around the library: map, assign, defaults, keys, pick, identity, transform

i don't think it would be that difficult to move to native functions and/or writing some of the used lodash dependencies from scratch. im ok with using lodash to build the js file from the template, but im not happy with having to include lodash in my prod bundle.

im using babel-lodash plugin to minimize the lodash but 7kb that could be reduced does not equate "lightweight"

image

rileylnapier commented 6 years ago

btw i do love the library and it helps us migrate a legacy angular 1.x templates to react. but i feel this lodash dependency is sticking out like sore thumb in our build process and eventually i will probably migrate to JSX to improve performance and optimize bundle size

nippur72 commented 6 years ago

unfortunately, the PR that would help solve this is still pending for approval. My solution was to use external helper functions and do not rely explicitly on lodash (see also #184).

A possible workaround for this would be using the lodash-import-path flag to switch to your own implementation of lodash where you can have native functions with a minimal footprint. I have not tried it but it should work.

As for myself, I used a fork with my PR for a while, but since I needed more features I ended up writing a templating engine of my own.

In my opinion, html-templates are much more readable than JSX, but JSX carries several other advantages that it's difficult to make a choice. I currently use both.

rileylnapier commented 6 years ago

why still pending? does wix not accept PR or are they busy?

nippur72 commented 6 years ago

They do accept PRs but activity on this repo has dropped cosiderably in the past years. My guess is that they are no longer using it as a primary tool.

rileylnapier commented 6 years ago

yeah. so probably should migrate away from it to plain jsx