File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed
Filter options
Expand file tree Collapse file tree 1 file changed +13
-7
lines changed
Original file line number Diff line number Diff line change @@ -52,17 +52,23 @@ function compileTypeScript(filePath) {
52
52
return fs . readFileSync ( outputPath , { encoding : 'utf8' } ) ;
53
53
}
54
54
55
+ function withLocalImmutable ( jsSrc ) {
56
+ return jsSrc . replace (
57
+ / r e q u i r e \( ' i m m u t a b l e / g,
58
+ "require('" + path . relative ( path . dirname ( filePath ) , process . cwd ( ) )
59
+ ) ;
60
+ }
61
+
55
62
module . exports = {
56
63
process : function ( src , filePath ) {
57
64
if ( filePath . match ( / \. t s $ / ) && ! filePath . match ( / \. d \. t s $ / ) ) {
58
- return compileTypeScript ( filePath ) ;
59
- } else if ( filePath . match ( / \. j s $ / ) && ~ filePath . indexOf ( '/__tests__/' ) ) {
60
- var result = react . transform ( src , { harmony : true } ) . replace (
61
- / r e q u i r e \( ' i m m u t a b l e / g,
62
- "require('" + path . relative ( path . dirname ( filePath ) , process . cwd ( ) )
63
- ) ;
64
- return result ;
65
+ return withLocalImmutable ( compileTypeScript ( filePath ) ) ;
65
66
}
67
+
68
+ if ( filePath . match ( / \. j s $ / ) && ~ filePath . indexOf ( '/__tests__/' ) ) {
69
+ return withLocalImmutable ( react . transform ( src , { harmony : true } ) ) ;
70
+ }
71
+
66
72
return src ;
67
73
}
68
74
} ;
You can’t perform that action at this time.
0 commit comments