1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = load;
|
7 | exports.getDefaultConfig = void 0;
|
8 |
|
9 | function _path() {
|
10 | const data = _interopRequireDefault(require("path"));
|
11 |
|
12 | _path = function () {
|
13 | return data;
|
14 | };
|
15 |
|
16 | return data;
|
17 | }
|
18 |
|
19 | function _metro() {
|
20 | const data = require("metro");
|
21 |
|
22 | _metro = function () {
|
23 | return data;
|
24 | };
|
25 |
|
26 | return data;
|
27 | }
|
28 |
|
29 | function _metroConfig() {
|
30 | const data = require("metro-config");
|
31 |
|
32 | _metroConfig = function () {
|
33 | return data;
|
34 | };
|
35 |
|
36 | return data;
|
37 | }
|
38 |
|
39 | function _fs() {
|
40 | const data = require("fs");
|
41 |
|
42 | _fs = function () {
|
43 | return data;
|
44 | };
|
45 |
|
46 | return data;
|
47 | }
|
48 |
|
49 | var _findSymlinkedModules = _interopRequireDefault(require("./findSymlinkedModules"));
|
50 |
|
51 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
52 |
|
53 | function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
|
54 |
|
55 | function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
56 |
|
57 | function resolveSymlinksForRoots(roots) {
|
58 | return roots.reduce((arr, rootPath) => arr.concat((0, _findSymlinkedModules.default)(rootPath, roots)), [...roots]);
|
59 | }
|
60 |
|
61 | function getWatchFolders() {
|
62 | const root = process.env.REACT_NATIVE_APP_ROOT;
|
63 | return root ? resolveSymlinksForRoots([_path().default.resolve(root)]) : [];
|
64 | }
|
65 |
|
66 | const getBlacklistRE = () => (0, _metro().createBlacklist)([/.*\/__fixtures__\/.*/]);
|
67 |
|
68 | const INTERNAL_CALLSITES_REGEX = new RegExp(['/Libraries/Renderer/implementations/.+\\.js$', '/Libraries/BatchedBridge/MessageQueue\\.js$', '/Libraries/YellowBox/.+\\.js$', '/node_modules/react-devtools-core/.+\\.js$'].join('|'));
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 | const getDefaultConfig = ctx => {
|
77 | const hasteImplPath = _path().default.join(ctx.reactNativePath, 'jest/hasteImpl.js');
|
78 |
|
79 | return {
|
80 | resolver: {
|
81 | resolverMainFields: ['react-native', 'browser', 'main'],
|
82 | blacklistRE: getBlacklistRE(),
|
83 | platforms: [...ctx.haste.platforms, 'native'],
|
84 | providesModuleNodeModules: ctx.haste.providesModuleNodeModules,
|
85 | hasteImplModulePath: (0, _fs().existsSync)(hasteImplPath) ? hasteImplPath : undefined
|
86 | },
|
87 | serializer: {
|
88 | getModulesRunBeforeMainModule: () => [require.resolve(_path().default.join(ctx.reactNativePath, 'Libraries/Core/InitializeCore'))],
|
89 | getPolyfills: () => require(_path().default.join(ctx.reactNativePath, 'rn-get-polyfills'))()
|
90 | },
|
91 | server: {
|
92 | port: Number(process.env.RCT_METRO_PORT) || 8081
|
93 | },
|
94 | symbolicator: {
|
95 | customizeFrame: frame => {
|
96 | const collapse = Boolean(frame.file && INTERNAL_CALLSITES_REGEX.test(frame.file));
|
97 | return {
|
98 | collapse
|
99 | };
|
100 | }
|
101 | },
|
102 | transformer: {
|
103 | babelTransformerPath: require.resolve('metro-react-native-babel-transformer'),
|
104 | assetRegistryPath: _path().default.join(ctx.reactNativePath, 'Libraries/Image/AssetRegistry')
|
105 | },
|
106 | watchFolders: getWatchFolders()
|
107 | };
|
108 | };
|
109 |
|
110 | exports.getDefaultConfig = getDefaultConfig;
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 | function load(ctx, options) {
|
118 | const defaultConfig = getDefaultConfig(ctx);
|
119 |
|
120 | if (options && options.reporter) {
|
121 | defaultConfig.reporter = options.reporter;
|
122 | }
|
123 |
|
124 | return (0, _metroConfig().loadConfig)(_objectSpread({
|
125 | cwd: ctx.root
|
126 | }, options), defaultConfig);
|
127 | } |
\ | No newline at end of file |