File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change
1
+ function registerRefs ( newPath , getRefPaths ) {
2
+ if ( Array . isArray ( newPath ) ) {
3
+ if ( newPath . length > 1 ) {
4
+ throw new Error (
5
+ 'registerRefs is only meant to handle single node transformations. Received more than one path node.'
6
+ ) ;
7
+ }
8
+
9
+ newPath = newPath [ 0 ] ;
10
+ }
11
+
12
+ let refPaths = getRefPaths ( newPath ) ;
13
+
14
+ for ( let ref of refPaths ) {
15
+ let binding = ref . scope . getBinding ( ref . node . name ) ;
16
+ if ( binding !== undefined ) {
17
+ binding . reference ( ref ) ;
18
+ }
19
+ }
20
+ }
21
+
22
+
1
23
// For ease of debuggin / tweaking:
2
24
// https://astexplorer.net/#/gist/bcca584efdab6c981a75618642c76a22/1e1d262eaeb47b7da66150e0781a02b96e597b25
3
25
module . exports = function ( babel ) {
@@ -39,7 +61,7 @@ module.exports = function (babel) {
39
61
. find ( ( { node } ) => {
40
62
return exportName === 'default'
41
63
? t . isImportDefaultSpecifier ( node )
42
- : node . imported . name === exportName ;
64
+ : node . imported && node . imported . name === exportName ;
43
65
} ) ;
44
66
45
67
if ( importSpecifier ) {
You can’t perform that action at this time.
0 commit comments