Files
babel/scripts/integration-tests/e2e-react-native.sh

48 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
#==============================================================================#
# SETUP #
#==============================================================================#
# Start in scripts/integration-tests/ even if run from root directory
cd "$(dirname "$0")" || exit
root="$PWD"
source utils/local-registry.sh
source utils/cleanup.sh
# Echo every command being executed
set -x
#==============================================================================#
# ENVIRONMENT #
#==============================================================================#
node -v
npm --version
yarn --version
#==============================================================================#
# TEST #
#==============================================================================#
startLocalRegistry "$root"/verdaccio-config.yml
# Create a React Native project
cd /tmp
npx react-native init rnbabel
cd rnbabel
if [ "$BABEL_8_BREAKING" = true ] ; then
# metro-react-native-babel-preset unconditionally enables the Flow plugin, even on TS files.
# https://github.com/facebook/metro/blob/2c16fa67/packages/metro-react-native-babel-preset/src/configs/main.js#L25
npx replace '(?=\[require\("@babel/plugin-syntax-flow")' '//' node_modules/metro-react-native-babel-preset/src/configs/main.js
# https://github.com/facebook/metro/blob/2c16fa67/packages/metro-react-native-babel-preset/src/configs/main.js#L169
npx replace '(?=plugins:.*?flow-strip-types)' 'exclude: [isTypeScriptSource, isTSXSource],' node_modules/metro-react-native-babel-preset/src/configs/main.js
fi
# Build the project
npx react-native bundle --entry-file index.js --bundle-output output.js
cleanup