File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed
packages/plugin-minify/lib/merge-variables Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change 77
88const { remove} = operator ;
99const getNode = ( a ) => a . node ;
10+ const maybeStartLine = ( a ) => a . node . loc ?. start . line || 0 ;
1011
1112export const report = ( ) => `Merge variables` ;
1213
@@ -51,7 +52,7 @@ export const traverse = ({push, uplist}) => ({
5152 const [ path , ...vars ] = allVars ;
5253 const { kind} = path . parentPath . node ;
5354 const { bindings} = path . scope ;
54- const startLine = path . node . loc ?. start . line ;
55+ const startLine = maybeStartLine ( path ) ;
5556
5657 for ( const [ index , path ] of vars . entries ( ) ) {
5758 const { node} = path ;
@@ -60,7 +61,7 @@ export const traverse = ({push, uplist}) => ({
6061 if ( isCallExpression ( init ) && isMemberExpression ( init . callee ) ) {
6162 const binding = bindings [ init . callee . object . name ] ;
6263
63- if ( binding && startLine && startLine !== path . node . loc . start . line - index ) {
64+ if ( binding && startLine && startLine !== maybeStartLine ( path ) - index ) {
6465 vars . splice ( index , 2 ) ;
6566 continue ;
6667 }
You can’t perform that action at this time.
0 commit comments