-
Notifications
You must be signed in to change notification settings - Fork 637
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
sourceExts and assetExts missing from resolver #1010
Comments
Can you confirm which
|
The repo above is as vanilla it can be, using I did all the changes then tried to adapt the snippet above into the default config, then I started getting issues and consequently started to debug the issue. I also couldn't find a mention of things moving around (possibly overlooked), hence the creation of this issue. |
I tried to replace But I've checked that |
This should work, via Recommended alternative If you're customising const {assetExts, sourceExts} = require('metro-config/defaults/defaults'); Advanced alternative You should also be able to export a function that will provide access to Metro's base config (matching the installed version of Metro). Please note that you must still merge this with const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
module.exports = function (baseConfig) {
const defaultConfig = mergeConfig(baseConfig, getDefaultConfig(__dirname));
const {resolver: {assetExts, sourceExts}} = defaultConfig;
return mergeConfig(
defaultConfig,
{
resolver: {
assetExts: assetExts.filter(ext => ext !== 'svg'),
sourceExts: [...sourceExts, 'scss', 'css', 'svg'],
},
}
);
}; Separately, I think this is a gotcha with facebook/react-native#36777, particularly as we named the main function
|
Noting facebook/react-native#38069 as another datapoint for the user expectation that I think there's reasonable merit to switch (back) to merging the base config within This is counterweighted by the correctness win of our current approach: by specifying the minimum additional config for React Native, we inherit the underlying defaults from Metro that match the current Metro version. (@kelset this might be an add-on we want to include for 0.72.1) |
just a quick headsup, current ETA for 0.72.1 is this Thursday; if a commit about this won't land before that, it will have to wait for 0.72.2 |
Summary: Reverts facebook#36777. This is motivated by reducing user friction when the widespread assumption is for `react-native/metro-config` to export a complete Metro config, as with Expo/rnx-kit, and like previously understood uses of `metro-config`. See facebook/metro#1010 (comment) for further notes. Fixes: - facebook/metro#1010 - facebook#38069 - kristerkari/react-native-svg-transformer#276 Note that we do not intend for `react-native/metro-config` to directly export `assetExts` etc — these can be accessed on the `resolver` property from the full config object. Changelog: [General][Changed] `react-native/metro-config` now includes all base config values from `metro-config` Differential Revision: D47055973 fbshipit-source-id: 78b59d925be72aa42b4b9d901c6f8d174f2dbae0
+1. That sounds like the most practical forward fix for RN 72. Stamped internally. |
Summary: Pull Request resolved: facebook#38092 Reverts facebook#36777. This is motivated by reducing user friction when the widespread assumption is for `react-native/metro-config` to export a complete Metro config, as with Expo/rnx-kit, and like previously understood uses of `metro-config`. See facebook/metro#1010 (comment) for further notes. Fixes: - facebook/metro#1010 - facebook#38069 - kristerkari/react-native-svg-transformer#276 Note that we do not intend for `react-native/metro-config` to directly export `assetExts` etc — these can be accessed on the `resolver` property from the full config object. Changelog: [General][Changed] `react-native/metro-config` now includes all base config values from `metro-config` Reviewed By: robhogan Differential Revision: D47055973 fbshipit-source-id: eedc4698e651645ada46a013d3945a16965bff22
Summary: Pull Request resolved: #38092 Reverts #36777. This is motivated by reducing user friction when the widespread assumption is for `react-native/metro-config` to export a complete Metro config, as with Expo/rnx-kit, and like previously understood uses of `metro-config`. See facebook/metro#1010 (comment) for further notes. Fixes: - facebook/metro#1010 - #38069 - kristerkari/react-native-svg-transformer#276 Note that we do not intend for `react-native/metro-config` to directly export `assetExts` etc — these can be accessed on the `resolver` property from the full config object. Changelog: [General][Changed] `react-native/metro-config` now includes all base config values from `metro-config` Reviewed By: robhogan Differential Revision: D47055973 fbshipit-source-id: 5ad23cc9700397110de5c0e81c7d76299761ef0a
Summary: Pull Request resolved: #38092 Reverts #36777. This is motivated by reducing user friction when the widespread assumption is for `react-native/metro-config` to export a complete Metro config, as with Expo/rnx-kit, and like previously understood uses of `metro-config`. See facebook/metro#1010 (comment) for further notes. Fixes: - facebook/metro#1010 - #38069 - kristerkari/react-native-svg-transformer#276 Note that we do not intend for `react-native/metro-config` to directly export `assetExts` etc — these can be accessed on the `resolver` property from the full config object. Changelog: [General][Changed] `react-native/metro-config` now includes all base config values from `metro-config` Reviewed By: robhogan Differential Revision: D47055973 fbshipit-source-id: 5ad23cc9700397110de5c0e81c7d76299761ef0a
This is being cherry picked into the upcoming React Native 0.72.1 release. Please make sure to upgrade |
This works on RN 0.72.3 `
|
Do you want to request a feature or report a bug?
A bug
What is the current behavior?
sourceExts
andassetExts
are missing fromgetDefaultConfig(__dirname).resolver
. I'm using them to parse scss and svg files like suchIf the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can
yarn install
andyarn test
.Repo
yarn install && yarn start
What is the expected behavior?
Currently
sourceExts
andassetExts
are missing fromgetDefaultConfig(__dirname).resolver
as it would on the log after starting the projectPlease provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system.
The text was updated successfully, but these errors were encountered: