2016-02-03 16:14:38 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
*
|
2018-02-17 02:24:55 +00:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2016-02-03 16:14:38 +00:00
|
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
|
2016-03-01 11:20:54 +00:00
|
|
|
var path = require('path');
|
2016-02-03 16:14:38 +00:00
|
|
|
|
2016-03-01 11:20:54 +00:00
|
|
|
var hmrTransform = 'react-transform-hmr/lib/index.js';
|
|
|
|
var transformPath = require.resolve(hmrTransform);
|
|
|
|
|
|
|
|
module.exports = function(options, filename) {
|
|
|
|
var transform = filename
|
2017-07-13 02:22:43 +00:00
|
|
|
? './' + path.relative(path.dirname(filename), transformPath) // packager can't handle absolute paths
|
|
|
|
: hmrTransform;
|
2016-04-05 08:12:13 +00:00
|
|
|
|
|
|
|
// Fix the module path to use '/' on Windows.
|
|
|
|
if (path.sep === '\\') {
|
|
|
|
transform = transform.replace(/\\/g, '/');
|
|
|
|
}
|
|
|
|
|
2016-02-03 16:14:38 +00:00
|
|
|
return {
|
2018-03-21 16:27:25 +00:00
|
|
|
plugins: [
|
2016-02-03 16:14:38 +00:00
|
|
|
[
|
2018-04-20 16:17:39 +00:00
|
|
|
require('metro-babel7-plugin-react-transform'),
|
2016-02-03 16:14:38 +00:00
|
|
|
{
|
2017-07-13 02:22:43 +00:00
|
|
|
transforms: [{
|
|
|
|
transform: transform,
|
|
|
|
imports: ['react'],
|
|
|
|
locals: ['module'],
|
|
|
|
}]
|
2016-02-03 16:14:38 +00:00
|
|
|
},
|
2017-07-13 02:22:43 +00:00
|
|
|
]
|
2018-03-21 16:27:25 +00:00
|
|
|
]
|
2016-02-03 16:14:38 +00:00
|
|
|
};
|
2016-03-21 22:44:12 +00:00
|
|
|
};
|