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

Feat rn split chunk #1887

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Feat rn split chunk #1887

wants to merge 8 commits into from

Conversation

CommanderXL
Copy link
Member

  1. 对外暴露 rnConfig.asyncChunk 配置
  • loadAsyncFn:外部定义的加载异步 chunk 函数,接受3个参数:urlsuccessCbfailCb
  • timeout: 超时配置
  • publicPath -> 待和native讨论
// vue.config.js
module.exports = defineConfig({
  pluginOptions: {
    mpx: {
      ...
      plugin: {
        rnConfig: {
          ...
          asyncChunk: {
            loadAsyncFn: function(url, successCb, failCb) {  
              loadAsync(url)
                .then(successCb)
                .catch(failCb)
            },
            timeout: 10000 // 超时配置
          }
        }
      }
    }
  }
})
  1. 加载失败的兜底处理
  • 页面级别; -> 如果加载失败,不跳转,且触发 failSuccess
  • 组件级别; -> 还是渲染 placeholder

@hiyuki
Copy link
Collaborator

hiyuki commented Mar 7, 2025

loadAsyncTemplate:function(config){ const urlMap = {...} const chunkUrl = urlMap[config.url] return drn.loadAsyncChunk(chunkUrl, ...) }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants