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+
123// For ease of debuggin / tweaking:
224// https://astexplorer.net/#/gist/bcca584efdab6c981a75618642c76a22/1e1d262eaeb47b7da66150e0781a02b96e597b25
325module . exports = function ( babel ) {
@@ -39,7 +61,7 @@ module.exports = function (babel) {
3961 . find ( ( { node } ) => {
4062 return exportName === 'default'
4163 ? t . isImportDefaultSpecifier ( node )
42- : node . imported . name === exportName ;
64+ : node . imported && node . imported . name === exportName ;
4365 } ) ;
4466
4567 if ( importSpecifier ) {
You can’t perform that action at this time.
0 commit comments