-
Notifications
You must be signed in to change notification settings - Fork 557
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
Drop Lodash #1041
Comments
By the looks of things, it's only used for the template code & examples.
I assume these need to still be supported, what would be the best approach here? Maybe the template package to be used standalone https://www.npmjs.com/package/lodash.template (however, I think Lodash still needs to make utils available inside the function like |
With regards to template, I think it would be good to just take the templates and turn them into template literals (function that returns template literal if dynamic vars are needed). ES6 has a good method for templating nowadays so then we don't need some third-party templating lib like lodash for it anymore. Before: export default `<?xml version="1.0" encoding="UTF-8"?>
<%
var props = dictionary.allTokens.filter(function(prop) {
return prop.attributes.category === 'color';
});
%>
<%= fileHeader({file, commentStyle: 'xml'}) %>
<resources>
<% props.forEach(function(prop) {
%><color name="<%= prop.name %>"><%= prop.value %></color><% if (prop.comment) { %><!-- <%= prop.comment %> --><% } %>
<% }); %>
</resources>`; After: export default (props, fileHeader) => `<?xml version="1.0" encoding="UTF-8"?>
${fileHeader}
<resources>
${props.reduce(
(acc, prop) =>
`${acc} <color name="${prop.name}">${prop.value}</color>${
prop.comment ? `<!-- ${prop.comment} -->` : ''
}\n`,
'',
)}
</resources>`; |
@Tahul
Mostly wanna drop this because Lodash is quite a node_modules bloating thing, and usually modern JS can do it already anyway. We don't use that much of lodash anyway, shouldn't be too much work.
The text was updated successfully, but these errors were encountered: