From 1b479314dc08f2a2e2f76438971f32fcf431ee89 Mon Sep 17 00:00:00 2001 From: Alex Hunt Date: Wed, 27 Jul 2022 06:20:26 -0700 Subject: [PATCH] Add 'jsx' to resolver.sourceExts defaults Summary: Widens the default config value for `resolver.sourceExts` to include `.jsx` file extensions. This mirrors us already supporting both `.ts` and `.tsx` out of the box, and [aligns with create-react-app](https://github.com/facebook/create-react-app/blob/f34d88e30c7d8be7181f728d1abc4fd8d5cd07d3/packages/react-scripts/config/webpack.config.js#L356). Changelog: **[Breaking]** With a default config, any `.jsx` files will now be resolved before `.json`, `.ts`, `.tsx` Reviewed By: robhogan Differential Revision: D37881467 fbshipit-source-id: cb16eb9b190e9f3f5666fd48b11a12feba8a53f1 --- .../src/__tests__/__snapshots__/loadConfig-test.js.snap | 4 ++++ packages/metro-config/src/defaults/defaults.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/metro-config/src/__tests__/__snapshots__/loadConfig-test.js.snap b/packages/metro-config/src/__tests__/__snapshots__/loadConfig-test.js.snap index ac7c971d42..64a5607f48 100644 --- a/packages/metro-config/src/__tests__/__snapshots__/loadConfig-test.js.snap +++ b/packages/metro-config/src/__tests__/__snapshots__/loadConfig-test.js.snap @@ -68,6 +68,7 @@ Object { ], "sourceExts": Array [ "js", + "jsx", "json", "ts", "tsx", @@ -224,6 +225,7 @@ Object { ], "sourceExts": Array [ "js", + "jsx", "json", "ts", "tsx", @@ -380,6 +382,7 @@ Object { ], "sourceExts": Array [ "js", + "jsx", "json", "ts", "tsx", @@ -536,6 +539,7 @@ Object { ], "sourceExts": Array [ "js", + "jsx", "json", "ts", "tsx", diff --git a/packages/metro-config/src/defaults/defaults.js b/packages/metro-config/src/defaults/defaults.js index 35edba5b9e..fccd5e4e60 100644 --- a/packages/metro-config/src/defaults/defaults.js +++ b/packages/metro-config/src/defaults/defaults.js @@ -50,7 +50,7 @@ exports.assetExts = [ exports.assetResolutions = ['1', '1.5', '2', '3', '4']; -exports.sourceExts = ['js', 'json', 'ts', 'tsx']; +exports.sourceExts = ['js', 'jsx', 'json', 'ts', 'tsx']; exports.moduleSystem = (require.resolve( 'metro-runtime/src/polyfills/require.js',