我正在尝试Hermes
在一个新项目中启用,但尽管我已启用它,android/app/build.gradle
但它并未启用。如文档中所述,我无法Engine: Hermes
在应用程序中看到文本。我正在使用WebStorm 2019.2
项目模板。
应用程序.js:
// imports
const App = () => {
return (
<Fragment>
<StatusBar barStyle="dark-content"/>
<SafeAreaView>
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={styles.scrollView}>
<Header/>
{global.HermesInternal == null ? null : (
<View style={styles.engine}>
<Text style={styles.footer}>Engine: Hermes</Text>
</View>
)}
// rest of the default ui omitted
</ScrollView>
</SafeAreaView>
</Fragment>
);
};
export default App;
babel.cofig.js:
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
};
Metro.config.js:
module.exports = {
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: false
}
})
}
};
包.js:
{
"name": "hermes",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"react": "16.8.6",
"react-native": "0.60.4"
},
"devDependencies": {
"@babel/core": "^7.5.5",
"@babel/runtime": "^7.5.5",
"@react-native-community/eslint-config": "^0.0.5",
"babel-jest": "^24.8.0",
"eslint": "^6.1.0",
"jest": "^24.8.0",
"metro-react-native-babel-preset": "^0.55.0",
"react-test-renderer": "16.8.6"
},
"jest": {
"preset": "react-native"
}
}
您可以从这里签出和测试项目。
更新:
我已经设法Hermes
在升级到RN v0.62.2
. 这是我当前的设置和依赖项:
- 包.json
- 项目级build.gradle
- 模块级build.gradle