最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

typescript - How can I view the javascript bundle code in React Native? - Stack Overflow

programmeradmin4浏览0评论

I have a React Native 0.57.8 project that uses TypeScript and Babel 7.

I would like to see the javascript code that is in the bundle so I can see what TypeScript and Babel have modified. Specifically, I am trying to see how TS and Babel handle default parameters for a class constructor.

I am aware the TS will add this.parameter = parameter to a class constructor body if the constructor parameters are given a modifier such as public, private, or readonly, but I don't know if this.parameter = parameter is added to the beginning of the constructor body, or end of the constructor body.

Is there a way I can view the javascript output that TS and Babel create?

I have a React Native 0.57.8 project that uses TypeScript and Babel 7.

I would like to see the javascript code that is in the bundle so I can see what TypeScript and Babel have modified. Specifically, I am trying to see how TS and Babel handle default parameters for a class constructor.

I am aware the TS will add this.parameter = parameter to a class constructor body if the constructor parameters are given a modifier such as public, private, or readonly, but I don't know if this.parameter = parameter is added to the beginning of the constructor body, or end of the constructor body.

Is there a way I can view the javascript output that TS and Babel create?

Share Improve this question edited Feb 11, 2019 at 23:21 Rasanjana N 1,4001 gold badge13 silver badges32 bronze badges asked Feb 11, 2019 at 22:06 Jarod LegaultJarod Legault 1851 silver badge11 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 17

You can generate the bundle yourself and then inspect it.

Either visit the Metro Bundler url when it's running on a terminal, e.g. http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false.

(This might require a full generation if it's not cached already, so it can take a while).

Or just generate a static file through the mand line:

// iOS
npx react-native bundle --entry-file=index.js --bundle-output='./bundle.js' --dev=false --platform='ios' --assets-dest='./ios' --reset-cache
// Android
npx react-native bundle --entry-file=index.js --bundle-output='./bundle.js' --dev=false --platform='android' --assets-dest='./android/app/src/main/res' --reset-cache
发布评论

评论列表(0)

  1. 暂无评论