Skip to content

Commit 32e4123

Browse files
idevovkasm
authored andcommitted
Delete hasteImpl, providesModuleNodeModules, and modulePathNameMapper (facebook#24811)
Summary: **Depends on facebook#25100 This commit depends on having migrated all of RN away from Haste. With 100% standard path-based requires, the key foundation is set and we no longer need `hasteImpl` and related settings in the Jest configuration. This commit deletes the `hasteImpl` file and setting as well as `providesModuleNodeModules` and `modulePathNameMapper`, removing most of the dependency graph overriding performed by Jest. ## Changelog [General] [Changed] - Delete hasteImpl, providesModuleNodeModules, and modulePathNameMapper from Jest config Pull Request resolved: facebook#24811 Differential Revision: D15659274 Pulled By: cpojer fbshipit-source-id: 8a4a3b97ddf7e38fbe62c6d3cc9c98248bfca343 (cherry picked from commit 7a2463e)
1 parent 3ceafea commit 32e4123

File tree

4 files changed

+2
-222
lines changed

4 files changed

+2
-222
lines changed

jest-preset.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,11 @@
99

1010
'use strict';
1111

12-
const dir = __dirname;
13-
1412
module.exports = {
1513
haste: {
1614
defaultPlatform: 'ios',
1715
platforms: ['android', 'ios', 'native'],
18-
hasteImplModulePath: require.resolve('./jest/hasteImpl.js'),
19-
providesModuleNodeModules: ['react-native'],
20-
},
21-
moduleNameMapper: {
22-
'^React$': require.resolve('react'),
2316
},
24-
modulePathIgnorePatterns: [`${dir}/Libraries/react-native/`],
2517
transform: {
2618
'^.+\\.(js|ts|tsx)$': 'babel-jest',
2719
'^.+\\.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$': require.resolve(

jest.config.js

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ module.exports = {
1717
'./jest/setup.js',
1818
],
1919
'timers': 'fake',
20-
'moduleNameMapper': {
21-
'^React$': '<rootDir>/Libraries/react-native/React.js',
22-
},
2320
'testRegex': '/__tests__/.*-test\\.js$',
2421
'testPathIgnorePatterns': [
2522
'/node_modules/',
@@ -29,46 +26,11 @@ module.exports = {
2926
],
3027
'haste': {
3128
'defaultPlatform': 'ios',
32-
'hasteImplModulePath': '<rootDir>/jest/hasteImpl.js',
33-
'providesModuleNodeModules': [
34-
'react-native',
35-
],
3629
'platforms': [
3730
'ios',
3831
'android',
3932
],
4033
},
41-
'modulePathIgnorePatterns': [
42-
'/node_modules/(?!react|fbjs|react-native|react-transform-hmr|core-js|promise)/',
43-
'node_modules/react/node_modules/fbjs/',
44-
'node_modules/react/lib/ReactDOM.js',
45-
'node_modules/fbjs/lib/Map.js',
46-
'node_modules/fbjs/lib/Promise.js',
47-
'node_modules/fbjs/lib/fetch.js',
48-
'node_modules/fbjs/lib/ErrorUtils.js',
49-
'node_modules/fbjs/lib/URI.js',
50-
'node_modules/fbjs/lib/Deferred.js',
51-
'node_modules/fbjs/lib/PromiseMap.js',
52-
'node_modules/fbjs/lib/UserAgent.js',
53-
'node_modules/fbjs/lib/areEqual.js',
54-
'node_modules/fbjs/lib/base62.js',
55-
'node_modules/fbjs/lib/crc32.js',
56-
'node_modules/fbjs/lib/everyObject.js',
57-
'node_modules/fbjs/lib/fetchWithRetries.js',
58-
'node_modules/fbjs/lib/filterObject.js',
59-
'node_modules/fbjs/lib/flattenArray.js',
60-
'node_modules/fbjs/lib/forEachObject.js',
61-
'node_modules/fbjs/lib/isEmpty.js',
62-
'node_modules/fbjs/lib/removeFromArray.js',
63-
'node_modules/fbjs/lib/resolveImmediate.js',
64-
'node_modules/fbjs/lib/someObject.js',
65-
'node_modules/fbjs/lib/sprintf.js',
66-
'node_modules/fbjs/lib/xhrSimpleDataSerializer.js',
67-
'node_modules/jest-cli',
68-
'node_modules/react/dist',
69-
'node_modules/fbjs/.*/__mocks__/',
70-
'node_modules/fbjs/node_modules/',
71-
],
7234
'unmockedModulePathPatterns': [
7335
'node_modules/react/',
7436
'Libraries/Renderer',

jest/__tests__/hasteImpl-test.js

Lines changed: 0 additions & 93 deletions
This file was deleted.

jest/hasteImpl.js

Lines changed: 2 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -5,93 +5,12 @@
55
* LICENSE file in the root directory of this source tree.
66
*
77
* @format
8-
* @flow
98
*/
109

1110
'use strict';
1211

13-
const path = require('path');
14-
const cli = require('@react-native-community/cli');
15-
16-
// Use duck-typing because of Facebook-internal infra that doesn't have the cli package.
17-
const {haste} = (cli.loadConfig && cli.loadConfig()) || {
18-
haste: {
19-
providesModuleNodeModules: [],
20-
platforms: ['ios', 'android'],
21-
},
22-
};
23-
24-
// Detect out-of-tree platforms and add them to the whitelists
25-
const pluginRoots /*: Array<string> */ = haste.providesModuleNodeModules.map(
26-
name => path.resolve(__dirname, '../../', name) + path.sep,
27-
);
28-
29-
const pluginNameReducers /*: Array<[RegExp, string]> */ = haste.platforms.map(
30-
name => [new RegExp(`^(.*)\\.(${name})$`), '$1'],
31-
);
32-
33-
const ROOTS = [path.resolve(__dirname, '..') + path.sep, ...pluginRoots];
34-
35-
const BLACKLISTED_PATTERNS /*: Array<RegExp> */ = [
36-
/.*[\\\/]__(mocks|tests)__[\\\/].*/,
37-
/^Libraries[\\\/]Animated[\\\/]src[\\\/]polyfills[\\\/].*/,
38-
/^Libraries[\\\/]Renderer[\\\/]fb[\\\/].*/,
39-
/DerivedData[\\\/].*/,
40-
];
41-
42-
const WHITELISTED_PREFIXES /*: Array<string> */ = [
43-
'IntegrationTests',
44-
'Libraries',
45-
'ReactAndroid',
46-
'RNTester',
47-
];
48-
49-
const NAME_REDUCERS /*: Array<[RegExp, string]> */ = [
50-
// extract basename
51-
[/^(?:.*[\\\/])?([a-zA-Z0-9$_.-]+)$/, '$1'],
52-
// strip .js/.js.flow suffix
53-
[/^(.*)\.js(\.flow)?$/, '$1'],
54-
// strip native suffix
55-
[/^(.*)\.(native)$/, '$1'],
56-
// strip plugin platform suffixes
57-
...pluginNameReducers,
58-
];
59-
60-
function isHastePath(filePath /*: string */) /*: boolean */ {
61-
if (!filePath.endsWith('.js') && !filePath.endsWith('.js.flow')) {
62-
return false;
63-
}
64-
65-
const root = ROOTS.find(r => filePath.startsWith(r));
66-
if (!root) {
67-
return false;
68-
}
69-
70-
filePath = filePath.substr(root.length);
71-
if (BLACKLISTED_PATTERNS.some(pattern => pattern.test(filePath))) {
72-
return false;
73-
}
74-
return WHITELISTED_PREFIXES.some(prefix => filePath.startsWith(prefix));
75-
}
76-
7712
module.exports = {
78-
/*
79-
* @return {string|void} hasteName for module at filePath; or undefined if
80-
* filePath is not a haste module
81-
*/
82-
getHasteName(
83-
filePath /*: string */,
84-
sourceCode /*: ?string */,
85-
) /*: string | void */ {
86-
if (!isHastePath(filePath)) {
87-
return undefined;
88-
}
89-
90-
const hasteName = NAME_REDUCERS.reduce(
91-
(name, [pattern, replacement]) => name.replace(pattern, replacement),
92-
filePath,
93-
);
94-
95-
return hasteName;
13+
getHasteName() {
14+
return undefined;
9615
},
9716
};

0 commit comments

Comments
 (0)