2016-02-03 16:14:38 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
|
2016-03-01 11:20:54 +00:00
|
|
|
var path = require('path');
|
2016-02-03 16:14:38 +00:00
|
|
|
var resolvePlugins = require('../lib/resolvePlugins');
|
|
|
|
|
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 {
|
|
|
|
plugins: resolvePlugins([
|
|
|
|
[
|
|
|
|
'react-transform',
|
|
|
|
{
|
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
|
|
|
]
|
|
|
|
])
|
2016-02-03 16:14:38 +00:00
|
|
|
};
|
2016-03-21 22:44:12 +00:00
|
|
|
};
|