UNPKG

981 BJavaScriptView Raw
1/**
2 * Copyright (c) 2015-present, Facebook, Inc.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 *
7 * @format
8 */
9'use strict';
10
11var path = require('path');
12
13var hmrTransform = 'react-transform-hmr/lib/index.js';
14var transformPath = require.resolve(hmrTransform);
15
16module.exports = function(options, filename) {
17 var transform = filename
18 ? './' + path.relative(path.dirname(filename), transformPath) // packager can't handle absolute paths
19 : hmrTransform;
20
21 // Fix the module path to use '/' on Windows.
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};