Skip to content

Commit bf8d918

Browse files
idefacebook-github-bot
authored andcommitted
Make Flow configs use path-based imports instead of Haste (#24812)
Summary: **Depends on #25100 This is one of the steps unlocked by migrating RN from Haste to path-based imports. This commit sets Flow to use path-based imports by removing all of the Haste-related configuration options. Additionally, it maps `react-native` to import from within this module to match Node's module resolution behavior. It also adds `<PROJECT_ROOT>` to the image name mapper so that the mapped name doesn't rely on Haste. ## Changelog [General] [Changed] - Make Flow configs use path-based imports instead of Haste Pull Request resolved: #24812 Differential Revision: D15659189 Pulled By: cpojer fbshipit-source-id: d0efaa2884485a492dcdef8d94061129cebc2566
1 parent c1e03b3 commit bf8d918

File tree

3 files changed

+9
-83
lines changed

3 files changed

+9
-83
lines changed

.flowconfig

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@
1111
; Ignore "BUCK" generated dirs
1212
<PROJECT_ROOT>/\.buckd/
1313

14-
; Ignore unexpected extra "@providesModule"
15-
.*/node_modules/.*/node_modules/fbjs/.*
16-
17-
; Ignore duplicate module providers
18-
; For RN Apps installed via npm, "Libraries" folder is inside
19-
; "node_modules/react-native" but in the source repo it is in the root
20-
.*/Libraries/react-native/React.js
21-
2214
; Ignore polyfills
2315
.*/Libraries/polyfills/.*
2416

@@ -48,28 +40,11 @@ module.file_ext=.js
4840
module.file_ext=.json
4941
module.file_ext=.ios.js
5042

51-
module.system=haste
52-
module.system.haste.use_name_reducers=true
53-
# keep the following in sync with server/haste/hasteImpl.js
54-
# get basename
55-
module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1'
56-
# strip .js or .js.flow suffix
57-
module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
58-
# strip .ios suffix
59-
module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
60-
module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
61-
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
62-
module.system.haste.paths.blacklist=.*/__tests__/.*
63-
module.system.haste.paths.blacklist=.*/__mocks__/.*
64-
module.system.haste.paths.whitelist=<PROJECT_ROOT>/Libraries/.*
65-
module.system.haste.paths.whitelist=<PROJECT_ROOT>/RNTester/.*
66-
module.system.haste.paths.whitelist=<PROJECT_ROOT>/IntegrationTests/.*
67-
module.system.haste.paths.blacklist=<PROJECT_ROOT>/Libraries/react-native/react-native-implementation.js
68-
module.system.haste.paths.blacklist=<PROJECT_ROOT>/Libraries/Animated/src/polyfills/.*
69-
7043
munge_underscores=true
7144

72-
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
45+
module.name_mapper='^react-native$' -> '<PROJECT_ROOT>/Libraries/react-native/react-native-implementation'
46+
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/\1'
47+
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/Libraries/Image/RelativeImageStub'
7348

7449
suppress_type=$FlowIssue
7550
suppress_type=$FlowFixMe

.flowconfig.android

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@
1111
; Ignore "BUCK" generated dirs
1212
<PROJECT_ROOT>/\.buckd/
1313

14-
; Ignore unexpected extra "@providesModule"
15-
.*/node_modules/.*/node_modules/fbjs/.*
16-
17-
; Ignore duplicate module providers
18-
; For RN Apps installed via npm, "Libraries" folder is inside
19-
; "node_modules/react-native" but in the source repo it is in the root
20-
.*/Libraries/react-native/React.js
21-
2214
; Ignore polyfills
2315
.*/Libraries/polyfills/.*
2416

@@ -48,28 +40,11 @@ module.file_ext=.js
4840
module.file_ext=.json
4941
module.file_ext=.android.js
5042

51-
module.system=haste
52-
module.system.haste.use_name_reducers=true
53-
# keep the following in sync with server/haste/hasteImpl.js
54-
# get basename
55-
module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1'
56-
# strip .js or .js.flow suffix
57-
module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
58-
# strip .android suffix
59-
module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
60-
module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
61-
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
62-
module.system.haste.paths.blacklist=.*/__tests__/.*
63-
module.system.haste.paths.blacklist=.*/__mocks__/.*
64-
module.system.haste.paths.whitelist=<PROJECT_ROOT>/Libraries/.*
65-
module.system.haste.paths.whitelist=<PROJECT_ROOT>/RNTester/.*
66-
module.system.haste.paths.whitelist=<PROJECT_ROOT>/IntegrationTests/.*
67-
module.system.haste.paths.blacklist=<PROJECT_ROOT>/Libraries/react-native/react-native-implementation.js
68-
module.system.haste.paths.blacklist=<PROJECT_ROOT>/Libraries/Animated/src/polyfills/.*
69-
7043
munge_underscores=true
7144

72-
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
45+
module.name_mapper='^react-native$' -> '<PROJECT_ROOT>/Libraries/react-native/react-native-implementation'
46+
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/\1'
47+
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/Libraries/Image/RelativeImageStub'
7348

7449
suppress_type=$FlowIssue
7550
suppress_type=$FlowFixMe

template/_flowconfig

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@
55
; Ignore "BUCK" generated dirs
66
<PROJECT_ROOT>/\.buckd/
77

8-
; Ignore unexpected extra "@providesModule"
9-
.*/node_modules/.*/node_modules/fbjs/.*
10-
11-
; Ignore duplicate module providers
12-
; For RN Apps installed via npm, "Libraries" folder is inside
13-
; "node_modules/react-native" but in the source repo it is in the root
14-
node_modules/react-native/Libraries/react-native/React.js
15-
168
; Ignore polyfills
179
node_modules/react-native/Libraries/polyfills/.*
1810

@@ -42,27 +34,11 @@ module.file_ext=.js
4234
module.file_ext=.json
4335
module.file_ext=.ios.js
4436

45-
module.system=haste
46-
module.system.haste.use_name_reducers=true
47-
# get basename
48-
module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1'
49-
# strip .js or .js.flow suffix
50-
module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
51-
# strip .ios suffix
52-
module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
53-
module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
54-
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
55-
module.system.haste.paths.blacklist=.*/__tests__/.*
56-
module.system.haste.paths.blacklist=.*/__mocks__/.*
57-
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/Libraries/.*
58-
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/RNTester/.*
59-
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/IntegrationTests/.*
60-
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/react-native/react-native-implementation.js
61-
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/Animated/src/polyfills/.*
62-
6337
munge_underscores=true
6438

65-
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
39+
module.name_mapper='^react-native$' -> '<PROJECT_ROOT>/Libraries/react-native/react-native-implementation'
40+
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/\1'
41+
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/Libraries/Image/RelativeImageStub'
6642

6743
suppress_type=$FlowIssue
6844
suppress_type=$FlowFixMe

0 commit comments

Comments
 (0)