sergeysova / styled-normalize

normalize.css for styled-components
https://npmjs.com/styled-normalize
MIT License
446 stars 19 forks source link

Use function to construct Normalize component #17

Closed kevin940726 closed 5 years ago

kevin940726 commented 5 years ago

css call returns an array of strings, so we can use function to construct <Normalize> component without using tagged template. The result is even smaller bundle size since we can now eliminate the unnecessary helpers generated by babel.

- function _templateObject() {      
-   var data = _taggedTemplateLiteral(["", ""]);        
-   _templateObject = function _templateObject() {      
-     return data;      
-   };      
-   return data;        
- }     
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }       
...
- var Normalize = (0, _styledComponents.createGlobalStyle)(_templateObject(), normalize);
+ var Normalize = (0, _styledComponents.createGlobalStyle)(normalize);
ghost commented 5 years ago

DeepCode Report (#dca66a)

DeepCode analyzed this pull request. There are no new issues.

sergeysova commented 5 years ago

Thank you!