@@ -19,21 +19,23 @@ const reactTransformPlugin = require('babel-plugin-react-transform').default;
19
19
const hmrTransform = 'react-transform-hmr/lib/index.js' ;
20
20
const transformPath = require . resolve ( hmrTransform ) ;
21
21
22
- const makeHMRConfig = function ( options , filename ) {
23
- const transform = filename ?
24
- './' + path . relative ( path . dirname ( filename ) , transformPath ) : // packager can't handle absolute paths
25
- hmrTransform ;
22
+ const makeHMRConfig = function ( options , filename ) {
23
+ const transform = filename
24
+ ? './' + path . relative ( path . dirname ( filename ) , transformPath ) // packager can't handle absolute paths
25
+ : hmrTransform ;
26
26
27
27
return {
28
28
plugins : [
29
29
[
30
30
reactTransformPlugin ,
31
31
{
32
- transforms : [ {
33
- transform,
34
- imports : [ 'react-native' ] ,
35
- locals : [ 'module' ] ,
36
- } ] ,
32
+ transforms : [
33
+ {
34
+ transform,
35
+ imports : [ 'react-native' ] ,
36
+ locals : [ 'module' ] ,
37
+ } ,
38
+ ] ,
37
39
} ,
38
40
] ,
39
41
] ,
@@ -42,13 +44,22 @@ const makeHMRConfig = function(options, filename) {
42
44
43
45
const buildAliasPreset = ( reactNativePath , reactPath ) => ( {
44
46
plugins : [
45
- [ require ( 'babel-plugin-module-resolver' ) . default , {
46
- alias : Object . assign ( { } , {
47
- 'react-native' : path . resolve ( `${ reactNativePath || './node_modules/react-native' } ` ) ,
48
- react : path . resolve ( `${ reactPath || './node_modules/react' } ` ) ,
49
- } , require ( 'babel-preset-exponent' ) . plugins [ 0 ] [ 1 ] . alias ) ,
50
- cwd : path . resolve ( __dirname , '..' ) ,
51
- } ] ,
47
+ [
48
+ require ( 'babel-plugin-module-resolver' ) . default ,
49
+ {
50
+ alias : Object . assign (
51
+ { } ,
52
+ {
53
+ 'react-native' : path . resolve (
54
+ `${ reactNativePath || './node_modules/react-native' } `
55
+ ) ,
56
+ react : path . resolve ( `${ reactPath || './node_modules/react' } ` ) ,
57
+ } ,
58
+ require ( 'babel-preset-exponent' ) . plugins [ 0 ] [ 1 ] . alias
59
+ ) ,
60
+ cwd : path . resolve ( __dirname , '..' ) ,
61
+ } ,
62
+ ] ,
52
63
] ,
53
64
} ) ;
54
65
@@ -59,7 +70,10 @@ const buildAliasPreset = (reactNativePath, reactPath) => ({
59
70
function buildBabelConfig ( filename , options ) {
60
71
const exponentBabelPreset = require ( 'babel-preset-exponent' ) ;
61
72
const babelConfig = {
62
- presets : [ ...exponentBabelPreset . presets , buildAliasPreset ( options . reactNativePath , options . reactPath ) ] ,
73
+ presets : [
74
+ ...exponentBabelPreset . presets ,
75
+ buildAliasPreset ( options . reactNativePath , options . reactPath ) ,
76
+ ] ,
63
77
plugins : [ ] ,
64
78
} ;
65
79
@@ -97,7 +111,7 @@ function transform(src, filename, options) {
97
111
} ;
98
112
}
99
113
100
- module . exports = function ( data , callback ) {
114
+ module . exports = function ( data , callback ) {
101
115
let result ;
102
116
try {
103
117
result = transform ( data . sourceCode , data . filename , data . options ) ;
0 commit comments