0

i am trying to run node on files that import React Native components.

More specifically, i am trying to run my testing framework riteway with react-native.

The Problem

When transpiling react-native modules there are issues related to the react-native environment (missing variables, wrong imports, etc)

you can find some sample code in this project.

So i am wondering, is there a way to transpile react-native so that it can be used in other nodejs apps?

the command i launch

node -r ./babel-register-start.js app.test.js

babel-register-start.js

require('@babel/register')({
  ignore: [/node_modules\/(?!(react-native))/],
  presets: [
    ['@babel/preset-env', {loose: true}], 
    '@babel/preset-flow', 
    '@babel/preset-react', 
    ["module:metro-react-native-babel-preset", { "loose": true }]
  ],
});

global.__DEV__ = true;
4

0 回答 0