-
Notifications
You must be signed in to change notification settings - Fork 905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Drop @react-native/metro-config dep for RN 0.72 config fallback #1899
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import type {InputConfigT} from 'metro-config'; | ||
import path from 'path'; | ||
import type {ConfigLoadingContext} from './loadMetroConfig'; | ||
|
||
/** | ||
* This module reproduces defaults from the @react-native/metro-config package, | ||
* used in ./loadMetroConfig.js to provide a soft upgrade process when upgrading | ||
* to React Native 0.72. | ||
* | ||
* These values will be used when: | ||
* - RN CLI 11.x or greater is present in a project (from React Native 0.72). | ||
* - The project has not yet followed the upgrade instructions to update | ||
* metro.config.js to extend '@react-native/metro-config'. | ||
* | ||
* Until we remove this file in a future release, updates should be made both | ||
* here and in '@react-native/metro-config'. (Note: Updates to these values are | ||
* generally rare.) | ||
* | ||
* TODO(@huntie): Remove this file in a future React Native release. | ||
*/ | ||
|
||
/** | ||
* @deprecated (React Native 0.72.0) Defaults should be updated here and in | ||
* https://github.com/facebook/react-native/tree/main/package/metro-config/index.js | ||
*/ | ||
const INTERNAL_CALLSITES_REGEX = new RegExp( | ||
[ | ||
'/Libraries/Renderer/implementations/.+\\.js$', | ||
'/Libraries/BatchedBridge/MessageQueue\\.js$', | ||
'/Libraries/YellowBox/.+\\.js$', | ||
'/Libraries/LogBox/.+\\.js$', | ||
'/Libraries/Core/Timers/.+\\.js$', | ||
'/Libraries/WebSocket/.+\\.js$', | ||
'/Libraries/vendor/.+\\.js$', | ||
'/node_modules/react-devtools-core/.+\\.js$', | ||
'/node_modules/react-refresh/.+\\.js$', | ||
'/node_modules/scheduler/.+\\.js$', | ||
'/node_modules/event-target-shim/.+\\.js$', | ||
'/node_modules/invariant/.+\\.js$', | ||
'/node_modules/react-native/index.js$', | ||
'/metro-runtime/.+\\.js$', | ||
'^\\[native code\\]$', | ||
].join('|'), | ||
); | ||
|
||
/** | ||
* Get the static Metro config defaults for a React Native project. | ||
* | ||
* @deprecated (React Native 0.72.0) Defaults should be updated here and in | ||
* https://github.com/facebook/react-native/tree/main/package/metro-config/index.js | ||
*/ | ||
export default function getDefaultMetroConfig( | ||
ctx: ConfigLoadingContext, | ||
): InputConfigT { | ||
return { | ||
resolver: { | ||
resolverMainFields: ['react-native', 'browser', 'main'], | ||
unstable_conditionNames: ['require', 'react-native'], | ||
}, | ||
serializer: { | ||
getPolyfills: () => | ||
require(path.join(ctx.reactNativePath, 'rn-get-polyfills'))(), | ||
Comment on lines
+61
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Deviates from |
||
}, | ||
server: { | ||
port: Number(process.env.RCT_METRO_PORT) || 8081, | ||
}, | ||
symbolicator: { | ||
customizeFrame: (frame: {file?: string}) => { | ||
const collapse = Boolean( | ||
frame.file && INTERNAL_CALLSITES_REGEX.test(frame.file), | ||
); | ||
return {collapse}; | ||
}, | ||
}, | ||
transformer: { | ||
allowOptionalDependencies: true, | ||
assetRegistryPath: 'react-native/Libraries/Image/AssetRegistry', | ||
asyncRequireModulePath: require.resolve( | ||
'metro-runtime/src/modules/asyncRequire', | ||
), | ||
babelTransformerPath: require.resolve( | ||
'metro-react-native-babel-transformer', | ||
), | ||
}, | ||
watchFolders: [], | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2673,21 +2673,6 @@ | |
resolved "https://registry.yarnpkg.com/@react-native-community/eslint-plugin/-/eslint-plugin-1.1.0.tgz#e42b1bef12d2415411519fd528e64b593b1363dc" | ||
integrity sha512-W/J0fNYVO01tioHjvYWQ9m6RgndVtbElzYozBq1ZPrHO/iCzlqoySHl4gO/fpCl9QEFjvJfjPgtPMTMlsoq5DQ== | ||
|
||
"@react-native/js-polyfills@^0.73.0": | ||
version "0.73.0" | ||
resolved "https://registry.yarnpkg.com/@react-native/js-polyfills/-/js-polyfills-0.73.0.tgz#d1becae77740c705392122684a55b373e610ab63" | ||
integrity sha512-3/+q+l86xvV8xjx29On9/Dn0eWjo5MHYuuALHqyOlQIs3vLk/rQB4rn4izObiurhH3utXxqVnbOk+TB9yJo4ng== | ||
|
||
"@react-native/metro-config@^0.73.0": | ||
version "0.73.0" | ||
resolved "https://registry.yarnpkg.com/@react-native/metro-config/-/metro-config-0.73.0.tgz#7601d2f4ba2252a4e359f8fda21008daf5f31eb2" | ||
integrity sha512-b+q8Ot6nxPE2PXEua20Q0vhXYpVtVjUaTX/hv+7mL5hLzKeIWq/bIxF04GLWT93BBjGSlL0xaZ7iGIQNN75Hog== | ||
dependencies: | ||
"@react-native/js-polyfills" "^0.73.0" | ||
metro-config "0.76.0" | ||
metro-react-native-babel-transformer "0.76.0" | ||
metro-runtime "0.76.0" | ||
|
||
Comment on lines
-2676
to
-2690
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All dependencies on packages published from |
||
"@sinonjs/commons@^1.7.0": | ||
version "1.7.1" | ||
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.7.1.tgz#da5fd19a5f71177a53778073978873964f49acf1" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restored (https://github.com/react-native-community/cli/pull/1875/files#diff-8218c5d0d266cb441ba7888833fc1aa54be26645ad47cf87253183504904fdd9L17-L19).