File tree Expand file tree Collapse file tree 3 files changed +9
-8
lines changed
visitors/templateLiterals Expand file tree Collapse file tree 3 files changed +9
-8
lines changed Original file line number Diff line number Diff line change 1+ import annotateAsPure from "@babel/helper-annotate-as-pure"
2+
13import minify from './visitors/minify'
24import displayNameAndId from './visitors/displayNameAndId'
35import templateLiterals from './visitors/templateLiterals'
46import assignStyledRequired from './visitors/assignStyledRequired'
57import { noParserImportDeclaration , noParserRequireCallExpression } from './visitors/noParserImport'
8+ import { useUglifyPure } from './utils/options'
69
710export default function ( { types : t } ) {
811 return {
@@ -11,6 +14,11 @@ export default function({ types: t }) {
1114 noParserImportDeclaration ( path , state )
1215 } ,
1316 CallExpression ( path , state ) {
17+ if ( useUglifyPure ( state ) ) {
18+ if ( path . parent . type == 'VariableDeclarator' || path . parent . type == 'TaggedTemplateExpression' ) {
19+ annotateAsPure ( path . node )
20+ }
21+ }
1422 noParserRequireCallExpression ( path , state )
1523 } ,
1624 TaggedTemplateExpression ( path , state ) {
Original file line number Diff line number Diff line change @@ -8,4 +8,4 @@ export const useFileName = (state) =>getOption(state, 'fileName')
88export const useMinify = ( state ) => getOption ( state , 'minify' )
99export const useCSSPreprocessor = ( state ) => getOption ( state , 'preprocess' , false ) // EXPERIMENTAL
1010export const useTranspileTemplateLiterals = ( state ) => getOption ( state , 'transpileTemplateLiterals' )
11- export const useUglifyPure = ( state ) => getOption ( state , 'uglifyPure' )
11+ export const useUglifyPure = ( state ) => getOption ( state , 'uglifyPure' , false )
Original file line number Diff line number Diff line change 33 useTranspileTemplateLiterals ,
44 useUglifyPure
55} from '../../utils/options'
6- import annotateAsPure from "@babel/helper-annotate-as-pure" ;
76
87import preprocess from './preprocess'
98import transpile from './transpile'
@@ -16,10 +15,4 @@ export default (path, state) => {
1615 } else if ( useTranspileTemplateLiterals ( state ) ) {
1716 transpile ( path , state )
1817 }
19-
20- // add uglify pure (/*#__PURE__*/) comment before function calls
21- if ( useUglifyPure ( state ) ) {
22- path . node . leadingComments = path . node . leadingComments || [ ]
23- annotateAsPure ( path )
24- }
2518}
You can’t perform that action at this time.
0 commit comments