-
Notifications
You must be signed in to change notification settings - Fork 34
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
Ember helpers? #82
Comments
How would you select which ones you expose? Until we have tree shaking in ember-cli I would be against this addition. |
Ember composable helpers have a feature where you can select which helpers to expose https://github.com/DockYard/ember-composable-helpers/blob/master/index.js |
@tchak - I apologize for deviating from the subject, but what are you trying to gain from tree-shaking with ember? As I see it,
// from
import { map, invoke } from 'lodash';
// to
import map from 'lodash/map';
import invoke from 'lodash/invoke';
|
@olsonpm some tree shaking can already be done via ember-browserify and broccoli-rollup. For example using ember-date-fns instead of ember-moment can save you quite a lot of code and it is a significant decrease in filesize. glimmer-application-pipeline also uses rollup underneath and importing 3rd party modules is very effective |
@MartinMalinda - Tree shaking as a whole does not work well. It can't tree shake lodash-es for many reasons. Here's an extremely simple example of tree-shaking failing. This problem is not specific to rollup - it's that tree-shaking is difficult. Rich harris was working on a a different method to determine whether code causes side-effects, but the last commit of that branch was in january so I assume that work was deemed not time-effective. |
It could be responsibility of each addon how to handle tree shaking - whether to tree shake 3rd party lib code, whether to tree shake ember modules that being exported. If there 100 helpers the addon is exporting, it is quite straightforward to check which are used and which not in the parent app. They are generally pure functions without side effects. I agree that having one global switch for tree shaking is probably not a good idea. |
I see - I confused your mentioning of "tree shaking" to mean one provided by a bundler. Removing code using heuristics specific to ember is very reasonable. |
I've found that in many of my projects that I use
ember-lodash
, I end up writing Ember helpers that mostly just call a Lodash function and pass along arguments. For example:This allows me to take advantage of Lodash transformations in my template (without having to make a CP):
Would there be interest in a PR that adds some of these helpers to the addon?
The text was updated successfully, but these errors were encountered: