我的 react-native expo 应用程序的已编译 typescript js 文件在哪里? [英] Where are the compiled typescript js files for my react-native expo application?

查看:14
本文介绍了我的 react-native expo 应用程序的已编译 typescript js 文件在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚使用 expo init 创建了一个默认的 typescript expo 项目,它在主目录中有一个简单的 App.tsx 文件.我能够对文件进行更改并将这些更改反映在我的应用程序中,但我似乎无法在任何地方找到相应的输出文件:App.js 文件,我觉得这很混乱.

I just created one of the default typescript expo projects with expo init, and it has a simple App.tsx file in the main directory. I'm able to make changes to the file and have those changes reflected in my app, but I can't seem to find the corresponding output file:App.js file anywhere, which I find very confusing.

在提供的 tsconfig.json 中挖掘后,它有一个明确标记为 "noEmit": true, 的选项,它会在编译期间关闭所有输出文件,这不会对我来说没什么意义.

After digging in the provided tsconfig.json, it has an option clearly labeled "noEmit": true, which turns off any output files during the compilation, which doesn't make a whole lot of sense to me.

打字稿输出文件在哪里保存/观看?

推荐答案

React Native 使用 Metro 捆绑 javascript/typescript 文件.生成的文件被缓存,并存储在某种无法直接读取的哈希目录结构中.

React Native use Metro to bundle javascript/typescript files. The file generated are cached, and stored in some kind of hashed directory structure which can't be read directly.

您可以将这些选项添加到 metro.config.js 以重定向缓存文件夹

You can add those options into metro.config.js to redirect the cache folder

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')
    })
  ]
};

这篇关于我的 react-native expo 应用程序的已编译 typescript js 文件在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆