Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

单页面时也会引入 react-navigation,体积过大 #14079

Closed
zhiqingchen opened this issue Jun 28, 2023 · 1 comment · Fixed by #14199
Closed

单页面时也会引入 react-navigation,体积过大 #14079

zhiqingchen opened this issue Jun 28, 2023 · 1 comment · Fixed by #14199
Assignees
Labels
F-react Framework - React T-rn Target - 编译到 React Native V-3 Version - 3.x

Comments

@zhiqingchen
Copy link
Member

相关平台

React Native

image

使用框架: React

复现步骤

Taro RN 不分不管是单页面应用还是多页面应用 都会引入react-navigation ,达到了400多KB, 包体增大,在android 手机端,加载js 过程中会有 100毫秒左右的时间差

期望结果

单页面不引入

实际结果

引入

环境信息

👽 Taro v3.6.6


  Taro CLI 3.6.6 environment info:
    System:
      OS: macOS 13.4
      Shell: 5.9 - /bin/zsh
    Binaries:
      Node: 18.13.0 - /usr/local/bin/node
      Yarn: 1.22.19 - ~/.yarn/bin/yarn
      npm: 8.19.3 - ~/.nvm/versions/node/v18.13.0/bin/npm
    npmPackages:
      @tarojs/cli: 3.6.5-canary.1 => 3.6.5-canary.1
      @tarojs/components: 3.6.5-canary.1 => 3.6.5-canary.1
      @tarojs/components-rn: 3.6.5-canary.1 => 3.6.5-canary.1
      @tarojs/helper: 3.6.5-canary.1 => 3.6.5-canary.1
      @tarojs/plugin-framework-react: 3.6.5-canary.1 => 3.6.5-canary.1
      @tarojs/plugin-html: 3.6.5-canary.1 => 3.6.5-canary.1
      @tarojs/plugin-mini-ci: 3.6.5-canary.1 => 3.6.5-canary.1
      @tarojs/plugin-platform-alipay: 3.6.5-canary.1 => 3.6.5-canary.1
      @tarojs/plugin-platform-h5: 3.6.5-canary.1 => 3.6.5-canary.1
      @tarojs/plugin-platform-jd: 3.6.5-canary.1 => 3.6.5-canary.1
      @tarojs/plugin-platform-qq: 3.6.5-canary.1 => 3.6.5-canary.1
      @tarojs/plugin-platform-swan: 3.6.5-canary.1 => 3.6.5-canary.1
      @tarojs/plugin-platform-tt: 3.6.5-canary.1 => 3.6.5-canary.1
      @tarojs/plugin-platform-weapp: 3.6.5-canary.1 => 3.6.5-canary.1
      @tarojs/react: 3.6.5-canary.1 => 3.6.5-canary.1
      @tarojs/rn-runner: 3.6.5-canary.1 => 3.6.5-canary.1
      @tarojs/runtime: 3.6.5-canary.1 => 3.6.5-canary.1
      @tarojs/shared: 3.6.5-canary.1 => 3.6.5-canary.1
      @tarojs/taro: 3.6.5-canary.1 => 3.6.5-canary.1
      @tarojs/taro-rn: 3.6.5-canary.1 => 3.6.5-canary.1
      @tarojs/webpack5-runner: 3.6.5-canary.1 => 3.6.5-canary.1
      babel-preset-taro: 3.6.5-canary.1 => 3.6.5-canary.1
      eslint-config-taro: 3.6.5-canary.1 => 3.6.5-canary.1
      expo: ~48.0.0 => 48.0.11
      react: ^18.2.0 => 18.2.0
      react-native: ^0.71.6 => 0.71.7
    npmGlobalPackages:
      typescript: 5.0.2
@yechunxi
Copy link
Collaborator

默认都会引入,在app.config 配置有一个开关打开,单页面就不会引入react-navigation, eg:

export default defineAppConfig({
  pages: [
    'pages/index/index'
 ],
  rn:{
    singleMode: true, // 默认是false
  }
})

如果pages的页面从一个到多个页面,需要重启下yarn start

zhiqingchen added a commit that referenced this issue Jul 21, 2023
* fix(rn): 单页面引入react-navigation导致体积过大问题(#14079)

* style: runtime-rn code format

* test(rn): update rn transformer snapshots

---------

Co-authored-by: tony chen <329604487@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-rn Target - 编译到 React Native V-3 Version - 3.x
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants