question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

getSourceExts not being respected when bundling

See original GitHub issue

Do you want to request a feature or report a bug? Bug What is the current behavior? Metro appears to be not respecting the configuration defined in rn-cli.config.js

module.exports = {
  getSourceExts: () => {
    return ['jsx', 'mjs', 'js'];
  }
};

If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can yarn install and yarn test. Include the above rn-cli.config.js in a RN 0.57.0 project and attempt to leverage a JSX file for your App component.

What is the expected behavior? JSX file extensions should be in the appropriate search paths.

Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system.

  • Metro v0.45.2
  • RN 0.57.0
  • Yarn 1.9.4
  • OSX

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

5reactions
dlferrocommented, Sep 14, 2018

It appears that the config for sourceExts does not merge with the defaults specified in the Metro source.

module.exports = {
  resolver: {
    sourceExts: ['js', 'json', 'ts', 'tsx', 'jsx']
  }
};

This ended up working for me.

3reactions
ajcritescommented, Sep 14, 2018

I believe getSourceExts has changed. See https://github.com/react-native-community/react-native-releases/blob/master/CHANGELOG.md#updating-to-this-version which links to https://facebook.github.io/metro/docs/en/configuration

Instead, try:

module.exports = {
  resolver: {
    sourceExts: ['jsx', 'mjs', 'js'],
  }
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

Mandy's Tech Blog
Since React 16.8 came out earlier this week, I've been playing around with hooks ... The array of inputs is not passed as...
Read more >
react native – MagmaLabs Blog
Look no further! This introduction to Styled Components will give you your first approach to the library and showcase the power of JS...
Read more >
react-native-typescript-transformer - Bountysource
Namespaces; Imports with require. As a consequence, the project cannot compile on metro. It is not clear to me if I can avoid...
Read more >
2019-July.txt - CMake
The branch, master has been updated via ... If any of these arguments is not used, then the corresponding variables are set to...
Read more >
users/asn/cmake.git - cryptomilk git repositories
‑rw‑r‑‑r‑‑ CMakeLists.txt 2 ‑rw‑r‑‑r‑‑ CTestCustom.cmake.in 1 ‑rw‑r‑‑r‑‑ ChangeLog.manual 410 ‑rw‑r‑‑r‑‑ Docs/cmake‑help.vim 21
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found