babel-plugin-react-turbo
Advanced tools
Comparing version 0.1.20 to 0.1.21
import * as t from '@babel/types'; | ||
import { destructingId } from '../constants.js'; | ||
function findJSXContainer(path) { | ||
@@ -20,3 +21,4 @@ if (!path) | ||
const name = path.node.name; | ||
const binding = scope.getBinding(name); | ||
const binding = scope.getOwnBinding(name); | ||
console.log('dd444xx55', name, !!binding); | ||
if (!binding) { | ||
@@ -29,4 +31,6 @@ return; | ||
} | ||
state.deps_.add(name); | ||
const refed = binding.referencePaths.some((ref) => ref === path); | ||
if (refed || name.includes(destructingId)) | ||
state.deps_.add(name); | ||
}, | ||
}; |
@@ -5,1 +5,2 @@ export const ReactTurbo = 'ReactTurbo'; | ||
export const ReactifiedName = 'reactified'; | ||
export const destructingId = 'ds_tr_ctr'; |
import * as t from '@babel/types'; | ||
import { destructingId } from '../../../constants.js'; | ||
import { hookType } from '../../../utils/hookType.js'; | ||
@@ -67,3 +68,3 @@ import { isConst } from '../constCombine.js'; | ||
const keyPaths = getKeyPaths(id); | ||
const uid = fn.scope.generateDeclaredUidIdentifier(); | ||
const uid = fn.scope.generateDeclaredUidIdentifier(destructingId); | ||
id.replaceWith(uid); | ||
@@ -70,0 +71,0 @@ console.log('dd'); |
{ | ||
"name": "babel-plugin-react-turbo", | ||
"version": "0.1.20", | ||
"version": "0.1.21", | ||
"description": "Babel plugin for react-turbo", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -5,2 +5,3 @@ /* eslint-disable @typescript-eslint/ban-ts-comment */ | ||
import { CollectVisitorState } from './types.js'; | ||
import { destructingId } from '../constants.js'; | ||
@@ -30,4 +31,4 @@ function findJSXContainer( | ||
const name = path.node.name; | ||
const binding = scope.getBinding(name); | ||
// console.log('dd444xx55', name, !!binding); | ||
const binding = scope.getOwnBinding(name); | ||
console.log('dd444xx55', name, !!binding); | ||
if (!binding) { | ||
@@ -43,6 +44,5 @@ // if (scope.hasBinding(name)) { | ||
// const refed = binding.referencePaths.some((ref) => ref === path); | ||
// if (refed) | ||
state.deps_.add(name); | ||
const refed = binding.referencePaths.some((ref) => ref === path); | ||
if (refed || name.includes(destructingId)) state.deps_.add(name); | ||
}, | ||
}; |
@@ -5,1 +5,2 @@ export const ReactTurbo = 'ReactTurbo'; | ||
export const ReactifiedName = 'reactified'; | ||
export const destructingId = 'ds_tr_ctr'; |
/* eslint-disable @typescript-eslint/ban-ts-comment */ | ||
import type { NodePath } from '@babel/traverse'; | ||
import * as t from '@babel/types'; | ||
import { destructingId } from '../../../constants.js'; | ||
import { hookType } from '../../../utils/hookType.js'; | ||
@@ -72,3 +73,3 @@ import { isConst } from '../constCombine.js'; | ||
// const uid = fn.scope.generateUidIdentifier(); | ||
const uid = fn.scope.generateDeclaredUidIdentifier(); | ||
const uid = fn.scope.generateDeclaredUidIdentifier(destructingId); | ||
id.replaceWith(uid); | ||
@@ -75,0 +76,0 @@ console.log('dd'); |
99076
2710