【问题标题】:Where are the compiled typescript js files for my react-native expo application?我的 react-native expo 应用程序的已编译 typescript js 文件在哪里?
【发布时间】:2020-06-07 02:26:37
【问题描述】:
我刚刚使用expo init 创建了一个默认的typescript expo 项目,它在主目录中有一个简单的App.tsx 文件。我可以对文件进行更改并将这些更改反映在我的应用程序中,但我似乎无法在任何地方找到相应的输出文件:App.js 文件,我觉得这很混乱。
在挖掘提供的tsconfig.json 后,它有一个明确标记为"noEmit": true, 的选项,它会在编译期间关闭任何输出文件,这对我来说没有多大意义。
正在保存/观看的打字稿输出文件在哪里?
【问题讨论】:
标签:
typescript
react-native
expo
【解决方案1】:
React Native 使用 Metro 来捆绑 javascript/typescript 文件。生成的文件被缓存,并存储在某种无法直接读取的哈希目录结构中。
您可以将这些选项添加到metro.config.js 以重定向缓存文件夹
const path = require('path');
const { FileStore } = require('metro-cache');
module.exports = {
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: true,
},
}),
},
cacheStores: [
new FileStore({
root: path.join(__dirname, 'metro-cache')
})
]
};