react-native-community / cli

The React Native Community CLI - command line tools to help you build RN apps
MIT License
2.41k stars 905 forks source link

fix: `loadConfig()` failing with "missing loader for extension" #2549

Closed tido64 closed 2 weeks ago

tido64 commented 2 weeks ago

Summary:

loadConfig() failing with "missing loader for extension":

Error: Missing loader for extension "react-native.config.mjs".
    at #validateConfig (/~/node_modules/cosmiconfig/dist/ExplorerBase.js:37:23)
    at new ExplorerBase (/~/node_modules/cosmiconfig/dist/ExplorerBase.js:25:29)
    at new ExplorerSync (/~/node_modules/cosmiconfig/dist/ExplorerSync.js:16:1)
    at cosmiconfigSync (/~/node_modules/cosmiconfig/dist/index.js:138:26)
    at readConfigFromDisk (/~/node_modules/@react-native-community/cli-config/build/readConfigFromDisk.js:65:55)

Test Plan:

This is enough to trigger the error:

node -p 'require("@react-native-community/cli").loadConfig({})'

Checklist

tido64 commented 2 weeks ago

cc @szymonrybczak

szymonrybczak commented 2 weeks ago

I wonder if we should add tests against loadConfig() function (reuse our old tests) 🤔