File tree Expand file tree Collapse file tree 4 files changed +15
-5
lines changed Expand file tree Collapse file tree 4 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ export default function({ types: t }) {
99 visitor : {
1010 CallExpression ( path , state ) {
1111 displayNameAndId ( t ) ( path , state )
12+ pureAnnotation ( t ) ( path , state )
1213 } ,
1314 TaggedTemplateExpression ( path , state ) {
1415 minify ( t ) ( path , state )
Original file line number Diff line number Diff line change @@ -6,13 +6,13 @@ import { isStyled, isPureHelper } from '../utils/detectors'
66export default t => ( path , state ) => {
77 if ( usePureAnnotation ( state ) ) {
88 if (
9- isStyled ( path . node , state ) ||
10- isStyled ( path . node . callee , state ) ||
11- isPureHelper ( path . node . callee , state )
9+ isStyled ( t ) ( path . node , state ) ||
10+ isStyled ( t ) ( path . node . callee , state ) ||
11+ isPureHelper ( t ) ( path . node . tag || path . node . callee , state )
1212 ) {
1313 if (
14- path . parent . type == 'VariableDeclarator' ||
15- path . parent . type == 'TaggedTemplateExpression'
14+ path . parent . type === 'VariableDeclarator' ||
15+ path . parent . type === 'TaggedTemplateExpression'
1616 ) {
1717 annotateAsPure ( path )
1818 }
Original file line number Diff line number Diff line change @@ -162,6 +162,14 @@ styled(Inner).withConfig({
162162 displayName : \\" annotate-styled-calls-with-pure-comments__WrappedComponent\\ " ,
163163 componentId : \\" sc-6tnjs3-6\\ "
164164} )([\\ "\\ "]);
165+ const StyledObjectForm =
166+ /*#__PURE__*/
167+ styled.div.withConfig({
168+ displayName : \\" annotate-styled-calls-with-pure-comments__StyledObjectForm\\ " ,
169+ componentId : \\" sc-6tnjs3-7\\ "
170+ } )({
171+ color : red
172+ } );
165173const notStyled =
166174/*#__PURE__*/
167175styled.div('')\`\` ; // not transpiled by styled components but should add pure comment
Original file line number Diff line number Diff line change @@ -7,5 +7,6 @@ const styles = { One: styled.div`` }
77let Component
88Component = styled . div ``
99const WrappedComponent = styled ( Inner ) ``
10+ const StyledObjectForm = styled . div ( { color : red } )
1011const notStyled = styled . div ( '' ) `` // not transpiled by styled components but should add pure comment
1112const normalFunc = add ( 5 , 3 )
You can’t perform that action at this time.
0 commit comments