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 19 commits into
base: master
Choose a base branch
from
Open

Feat rn split chunk #1887

wants to merge 19 commits into from

Conversation

CommanderXL
Copy link
Member

@CommanderXL CommanderXL commented Mar 7, 2025

  1. 对外暴露 rnConfig.asyncChunk 配置
  • loadAsyncFn:外部定义的加载异步 chunk 函数,接受一个 config 配置,返回一个 promise
  • timeout: 超时配置
  • publicPath -> 待和native讨论
  • fallback -> 分包页面加载失败,默认暂时页面
  • loading -> 分包页面加载中, 加载中页面配置
// vue.config.js
module.exports = defineConfig({
  pluginOptions: {
    mpx: {
      ...
      plugin: {
        rnConfig: {
          ...
          asyncChunk: {
            loadAsyncTemplate: `
                function (config) {
                  return loadAsyncChunk(config.url)
                }
            `,
            timeout: 10000 // 超时配置
          }
        }
      }
    }
  }
})
  1. 加载失败的兜底处理
  • 页面级别; -> 如果加载失败,展示默认兜底页面,提供重试加载机制出口;
  • 组件级别; -> 还是渲染 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