callstack / callstack/super-app-example

How to loading bundles from cdn?

未关闭
#10 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
question
主要语言
Java
星标
40
派生
23
PR 合并指标
30 天内没有已合并 PR

描述

## Ask your Question
I followed your example, everything runs fine on localhost, but when I want to load bundle from cdn, it doesn't seem to work.
- I generated bundle by running command: `react-native webpack-bundle --entry-file=index.js --dev=false --platform='ios' --bundle-output ios/MiniApp.container.bundle`
- Bundle cdn: `https://cdn.jsdelivr.net/gh/tungnt93/test_bundle/MiniApp.container.bundle`
- host-app/index.js:
```
ScriptManager.shared.addResolver(async (scriptId, caller) => {
const resolveURL = Federated.createURLResolver({
containers: {
MiniApp: "https://cdn.jsdelivr.net/gh/tungnt93/test_bundle/[name][ext]"
},
});

const url = resolveURL(scriptId, caller);
if (url) {
return {
url,
query: {
platform: Platform.OS,
},
};
}
});
```
If i change containers to localhost, everything runs fine
```
const resolveURL = Federated.createURLResolver({
containers: {
MiniApp: "http://localhost:9000/[name][ext]"
},
});
```
This is the image of host-app/src/screens/MiniAppScreen.js when i load from cdn: [https://i.imgur.com/cX3B1Ut.png](url)
So I want to ask, is my bundle generating command correct? If so, does uploading it to jsdelivr work, or do i have to upload it to another cdn?
Thank you!

贡献指南

打开贡献指南

调研方向

从 host-app/index.js 中的 bundle 命令和 resolver 开始,然后将 CDN URL 与正常工作的 localhost resolver 进行比较。从 host-app/src/screens/MiniAppScreen.js 重现加载过程,并验证生成的 MiniApp.container.bundle 是否可通过 jsDelivr 访问和使用;当 MiniApp 从 CDN 加载时即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, react-native, webpack
领域
build-system, mobile
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。