(node)
| 54 | } |
| 55 | |
| 56 | export function getKeypath(node) { |
| 57 | const parts = []; |
| 58 | |
| 59 | while (node.type === 'MemberExpression') { |
| 60 | if (node.computed) return null; |
| 61 | |
| 62 | parts.unshift(node.property.name); |
| 63 | // eslint-disable-next-line no-param-reassign |
| 64 | node = node.object; |
| 65 | } |
| 66 | |
| 67 | if (node.type !== 'Identifier') return null; |
| 68 | |
| 69 | const { name } = node; |
| 70 | parts.unshift(name); |
| 71 | |
| 72 | return { name, keypath: parts.join('.') }; |
| 73 | } |
| 74 | |
| 75 | export const KEY_COMPILED_ESM = '__esModule'; |
| 76 |