Home > Software design >  Build React Native app with webpack instead of metro
Build React Native app with webpack instead of metro

Time:03-26

My React Native app is part of a monorepo. All the "buildables" (api, backend, website) are written in TypeScript and built with Webpack.

All of them use inversify. Therefore, the configuration to make decorators work is kind of duplicated in both Webpack and Metro/Babel configuration. Plus, some things are not working the same and require additional babel plugins.

I've checked pretty much everywhere but did not find an answer :

What concretely prevents us from using Webpack to build a RN app and completely get rid of Metro/Babel ? (except dev tools like HMR, etc.)

CodePudding user response:

have you checked repack? it might help you if i'm understanding your problem correctly https://github.com/callstack/repack

CodePudding user response:

I've ended up splitting my build process in 2 parts :

  1. Webpack takes my index.tsx and builds an index.js via ts-loader (using a node target)
  2. Metro takes this index.js as entrypoint

Since it's already transpiled, no need to define complex mechanism for Metro to build TypeScript

  • Related