fix(reactivity-transform): apply transform on exported variable declarations
fix #5298
This commit is contained in:
		
							parent
							
								
									ae4b0783d7
								
							
						
					
					
						commit
						a81a9922bb
					
				@ -4,7 +4,7 @@ exports[`$ unwrapping 1`] = `
 | 
			
		||||
"
 | 
			
		||||
    import { ref, shallowRef } from 'vue'
 | 
			
		||||
    let foo = (ref())
 | 
			
		||||
    let a = (ref(1))
 | 
			
		||||
    export let a = (ref(1))
 | 
			
		||||
    let b = (shallowRef({
 | 
			
		||||
      count: 0
 | 
			
		||||
    }))
 | 
			
		||||
 | 
			
		||||
@ -19,7 +19,7 @@ test('$ unwrapping', () => {
 | 
			
		||||
  const { code, rootRefs } = transform(`
 | 
			
		||||
    import { ref, shallowRef } from 'vue'
 | 
			
		||||
    let foo = $(ref())
 | 
			
		||||
    let a = $(ref(1))
 | 
			
		||||
    export let a = $(ref(1))
 | 
			
		||||
    let b = $(shallowRef({
 | 
			
		||||
      count: 0
 | 
			
		||||
    }))
 | 
			
		||||
@ -30,7 +30,7 @@ test('$ unwrapping', () => {
 | 
			
		||||
  expect(code).not.toMatch(`$(ref(1))`)
 | 
			
		||||
  expect(code).not.toMatch(`$(shallowRef({`)
 | 
			
		||||
  expect(code).toMatch(`let foo = (ref())`)
 | 
			
		||||
  expect(code).toMatch(`let a = (ref(1))`)
 | 
			
		||||
  expect(code).toMatch(`export let a = (ref(1))`)
 | 
			
		||||
  expect(code).toMatch(`
 | 
			
		||||
    let b = (shallowRef({
 | 
			
		||||
      count: 0
 | 
			
		||||
 | 
			
		||||
@ -229,6 +229,12 @@ export function transformAST(
 | 
			
		||||
        stmt.left.type === 'VariableDeclaration'
 | 
			
		||||
      ) {
 | 
			
		||||
        walkVariableDeclaration(stmt.left)
 | 
			
		||||
      } else if (
 | 
			
		||||
        stmt.type === 'ExportNamedDeclaration' &&
 | 
			
		||||
        stmt.declaration &&
 | 
			
		||||
        stmt.declaration.type === 'VariableDeclaration'
 | 
			
		||||
      ) {
 | 
			
		||||
        walkVariableDeclaration(stmt.declaration, isRoot)
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
@ -562,6 +568,7 @@ export function transformAST(
 | 
			
		||||
        return
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      // skip type nodes
 | 
			
		||||
      if (
 | 
			
		||||
        parent &&
 | 
			
		||||
        parent.type.startsWith('TS') &&
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user