rafeca / metro-sample-app

Super simple web app built by metro
29 stars 8 forks source link

How to transpile dependencies with babel. #6

Open dalcib opened 6 years ago

dalcib commented 6 years ago

@rafeca, thanks for this metro-sample-app.

I'm trying to use it with react-native-web, I am using the following metro.config.js

module.exports = {
  extraNodeModules: {
    'react-native': 'node_modules/react-native-web'
  }
};

In order to get the extension .web.js to work in dev mode, I also changed the dev.html to:

...
<script src="http://localhost:8082/src/index.bundle?platform=web"></script>

adding ?platform=web at the and of the link.

The problem is when I import some react-native-xxx package, as react-native-vecttor-icons, for example, that is not compiled to ES5, or, for example, use ClassProperties, an error occurs. In react-native-cli, these modules are transpiled automatically with babel. Wich configuration should I use to get the same behavior in a web project?

dalcib commented 6 years ago

@rafeca ?