File tree Expand file tree Collapse file tree
__fixtures__/rewrite-imports Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,3 +12,5 @@ import {
1212 withTheme ,
1313 LightTheme ,
1414} from 'react-native-paper' ;
15+
16+ export { TextInput } from 'react-native-paper' ;
Original file line number Diff line number Diff line change @@ -8,3 +8,4 @@ import { Palette } from "react-native-paper/lib/module/theme/tokens";
88import { NonExistent , NonExistentSecond as Stuff , LightTheme } from "react-native-paper/lib/module/index.js" ;
99import { ThemeProvider } from "react-native-paper/lib/module/core/theming" ;
1010import { withTheme } from "react-native-paper/lib/module/core/theming" ;
11+ export { default as TextInput } from "react-native-paper/lib/module/components/TextInput" ;
Original file line number Diff line number Diff line change @@ -56,6 +56,70 @@ module.exports = function rewire(babel, options) {
5656 } , [ ] )
5757 ) ;
5858
59+ path . requeue ( ) ;
60+ } ,
61+ ExportNamedDeclaration ( path ) {
62+ if (
63+ ! path . node . source ||
64+ path . node . source . value !== name ||
65+ path . node [ SKIP ]
66+ ) {
67+ return ;
68+ }
69+
70+ path . node . source . value = `${ name } /${ index } ` ;
71+ path . replaceWithMultiple (
72+ path . node . specifiers . reduce ( ( declarations , specifier ) => {
73+ const mapping = mappings [ specifier . local . name ] ;
74+
75+ if ( mapping ) {
76+ const alias = `${ name } /${ mapping . path } ` ;
77+ let s ;
78+
79+ switch ( mapping . name ) {
80+ case 'default' :
81+ s = t . exportSpecifier (
82+ t . identifier ( 'default' ) ,
83+ t . identifier ( specifier . exported . name )
84+ ) ;
85+ break ;
86+ case '*' :
87+ s = t . exportNamespaceSpecifier (
88+ t . identifier ( specifier . exported . name )
89+ ) ;
90+ break ;
91+ default :
92+ s = t . exportSpecifier (
93+ t . identifier ( mapping . name ) ,
94+ t . identifier ( specifier . exported . name )
95+ ) ;
96+ }
97+
98+ declarations . push (
99+ t . exportNamedDeclaration ( null , [ s ] , t . stringLiteral ( alias ) )
100+ ) ;
101+ } else {
102+ const previous = declarations . find (
103+ ( d ) => d . source . value === path . node . source . value
104+ ) ;
105+
106+ if ( previous ) {
107+ previous . specifiers . push ( specifier ) ;
108+ } else {
109+ const node = t . exportNamedDeclaration (
110+ null ,
111+ [ specifier ] ,
112+ path . node . source
113+ ) ;
114+ node [ SKIP ] = true ;
115+ declarations . push ( node ) ;
116+ }
117+ }
118+
119+ return declarations ;
120+ } , [ ] )
121+ ) ;
122+
59123 path . requeue ( ) ;
60124 } ,
61125 } ,
You can’t perform that action at this time.
0 commit comments