mirror of
https://github.com/status-im/react-native.git
synced 2025-01-09 17:15:54 +00:00
a3706411ab
Summary: Related to #3999 There is an issue with the `preprocessor` script when using node >=5 as it uses npm 3. ~~There are (at least) two solutions, (I'm submitting the first one):~~ - ~~specify min required node version to 5.x and modify [this the preprocessor script](https://github.com/facebook/react-native/blob/0.16-stable/jestSupport/preprocessor.js#L29) to match npm 3 requirements~~ - ~~specifify node version >= 4.x and < 5.x and let the preprocessor script as it is~~ **EDIT**: Using `require.resolve` will do the trick ! -- Thank you guys for this amazing project by the way ;) Closes https://github.com/facebook/react-native/pull/4903 Reviewed By: svcscm Differential Revision: D2838759 Pulled By: androidtrunkagent fb-gh-sync-id: ebb12f225a519ea23afc4f013bb063a920193719
32 lines
981 B
JavaScript
32 lines
981 B
JavaScript
/**
|
|
* 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';
|
|
|
|
const createCacheKeyFunction = require('fbjs-scripts/jest/createCacheKeyFunction');
|
|
const path = require('path');
|
|
const transformer = require('../packager/transformer.js');
|
|
|
|
module.exports = {
|
|
process(src, file) {
|
|
// Don't transform node_modules, except react-tools which includes the
|
|
// untransformed copy of React
|
|
if (file.match(/node_modules\/(?!react-tools\/)/)) {
|
|
return src;
|
|
}
|
|
|
|
return transformer.transform(src, file, {inlineRequires: true}).code;
|
|
},
|
|
|
|
getCacheKey: createCacheKeyFunction([
|
|
__filename,
|
|
path.join(__dirname, '../packager/transformer.js'),
|
|
require.resolve('babel-core/package.json'),
|
|
]),
|
|
};
|