From bf8d91868182955899edab3b0b91a0be53ce276d Mon Sep 17 00:00:00 2001 From: James Ide Date: Wed, 5 Jun 2019 15:57:36 -0700 Subject: [PATCH] Make Flow configs use path-based imports instead of Haste (#24812) Summary: **Depends on https://github.com/facebook/react-native/pull/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 `` 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: https://github.com/facebook/react-native/pull/24812 Differential Revision: D15659189 Pulled By: cpojer fbshipit-source-id: d0efaa2884485a492dcdef8d94061129cebc2566 --- .flowconfig | 31 +++---------------------------- .flowconfig.android | 31 +++---------------------------- template/_flowconfig | 30 +++--------------------------- 3 files changed, 9 insertions(+), 83 deletions(-) diff --git a/.flowconfig b/.flowconfig index 2df42b89ca..0fa25e0ca3 100644 --- a/.flowconfig +++ b/.flowconfig @@ -11,14 +11,6 @@ ; Ignore "BUCK" generated dirs /\.buckd/ -; Ignore unexpected extra "@providesModule" -.*/node_modules/.*/node_modules/fbjs/.* - -; Ignore duplicate module providers -; For RN Apps installed via npm, "Libraries" folder is inside -; "node_modules/react-native" but in the source repo it is in the root -.*/Libraries/react-native/React.js - ; Ignore polyfills .*/Libraries/polyfills/.* @@ -48,28 +40,11 @@ module.file_ext=.js module.file_ext=.json module.file_ext=.ios.js -module.system=haste -module.system.haste.use_name_reducers=true -# keep the following in sync with server/haste/hasteImpl.js -# get basename -module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1' -# strip .js or .js.flow suffix -module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1' -# strip .ios suffix -module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1' -module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1' -module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1' -module.system.haste.paths.blacklist=.*/__tests__/.* -module.system.haste.paths.blacklist=.*/__mocks__/.* -module.system.haste.paths.whitelist=/Libraries/.* -module.system.haste.paths.whitelist=/RNTester/.* -module.system.haste.paths.whitelist=/IntegrationTests/.* -module.system.haste.paths.blacklist=/Libraries/react-native/react-native-implementation.js -module.system.haste.paths.blacklist=/Libraries/Animated/src/polyfills/.* - munge_underscores=true -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' +module.name_mapper='^react-native$' -> '/Libraries/react-native/react-native-implementation' +module.name_mapper='^react-native/\(.*\)$' -> '/\1' +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\)$' -> '/Libraries/Image/RelativeImageStub' suppress_type=$FlowIssue suppress_type=$FlowFixMe diff --git a/.flowconfig.android b/.flowconfig.android index 1d47c484ef..97f4f99ad0 100644 --- a/.flowconfig.android +++ b/.flowconfig.android @@ -11,14 +11,6 @@ ; Ignore "BUCK" generated dirs /\.buckd/ -; Ignore unexpected extra "@providesModule" -.*/node_modules/.*/node_modules/fbjs/.* - -; Ignore duplicate module providers -; For RN Apps installed via npm, "Libraries" folder is inside -; "node_modules/react-native" but in the source repo it is in the root -.*/Libraries/react-native/React.js - ; Ignore polyfills .*/Libraries/polyfills/.* @@ -48,28 +40,11 @@ module.file_ext=.js module.file_ext=.json module.file_ext=.android.js -module.system=haste -module.system.haste.use_name_reducers=true -# keep the following in sync with server/haste/hasteImpl.js -# get basename -module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1' -# strip .js or .js.flow suffix -module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1' -# strip .android suffix -module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1' -module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1' -module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1' -module.system.haste.paths.blacklist=.*/__tests__/.* -module.system.haste.paths.blacklist=.*/__mocks__/.* -module.system.haste.paths.whitelist=/Libraries/.* -module.system.haste.paths.whitelist=/RNTester/.* -module.system.haste.paths.whitelist=/IntegrationTests/.* -module.system.haste.paths.blacklist=/Libraries/react-native/react-native-implementation.js -module.system.haste.paths.blacklist=/Libraries/Animated/src/polyfills/.* - munge_underscores=true -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' +module.name_mapper='^react-native$' -> '/Libraries/react-native/react-native-implementation' +module.name_mapper='^react-native/\(.*\)$' -> '/\1' +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\)$' -> '/Libraries/Image/RelativeImageStub' suppress_type=$FlowIssue suppress_type=$FlowFixMe diff --git a/template/_flowconfig b/template/_flowconfig index 80fa55fc38..49091799f9 100644 --- a/template/_flowconfig +++ b/template/_flowconfig @@ -5,14 +5,6 @@ ; Ignore "BUCK" generated dirs /\.buckd/ -; Ignore unexpected extra "@providesModule" -.*/node_modules/.*/node_modules/fbjs/.* - -; Ignore duplicate module providers -; For RN Apps installed via npm, "Libraries" folder is inside -; "node_modules/react-native" but in the source repo it is in the root -node_modules/react-native/Libraries/react-native/React.js - ; Ignore polyfills node_modules/react-native/Libraries/polyfills/.* @@ -42,27 +34,11 @@ module.file_ext=.js module.file_ext=.json module.file_ext=.ios.js -module.system=haste -module.system.haste.use_name_reducers=true -# get basename -module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1' -# strip .js or .js.flow suffix -module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1' -# strip .ios suffix -module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1' -module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1' -module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1' -module.system.haste.paths.blacklist=.*/__tests__/.* -module.system.haste.paths.blacklist=.*/__mocks__/.* -module.system.haste.paths.whitelist=/node_modules/react-native/Libraries/.* -module.system.haste.paths.whitelist=/node_modules/react-native/RNTester/.* -module.system.haste.paths.whitelist=/node_modules/react-native/IntegrationTests/.* -module.system.haste.paths.blacklist=/node_modules/react-native/Libraries/react-native/react-native-implementation.js -module.system.haste.paths.blacklist=/node_modules/react-native/Libraries/Animated/src/polyfills/.* - munge_underscores=true -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' +module.name_mapper='^react-native$' -> '/Libraries/react-native/react-native-implementation' +module.name_mapper='^react-native/\(.*\)$' -> '/\1' +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\)$' -> '/Libraries/Image/RelativeImageStub' suppress_type=$FlowIssue suppress_type=$FlowFixMe