1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | 'use strict';
|
10 |
|
11 | var path = require('path');
|
12 |
|
13 | var hmrTransform = 'react-transform-hmr/lib/index.js';
|
14 | var transformPath = require.resolve(hmrTransform);
|
15 |
|
16 | module.exports = function(options, filename) {
|
17 | var transform = filename
|
18 | ? './' + path.relative(path.dirname(filename), transformPath)
|
19 | : hmrTransform;
|
20 |
|
21 |
|
22 | if (path.sep === '\\') {
|
23 | transform = transform.replace(/\\/g, '/');
|
24 | }
|
25 |
|
26 | return {
|
27 | plugins: [
|
28 | [
|
29 | require('metro-babel7-plugin-react-transform'),
|
30 | {
|
31 | transforms: [
|
32 | {
|
33 | transform: transform,
|
34 | imports: ['react'],
|
35 | locals: ['module'],
|
36 | },
|
37 | ],
|
38 | },
|
39 | ],
|
40 | ],
|
41 | };
|
42 | };
|