web-bundle: a root-relative import from a remote plugin fails in the browser
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 70/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- javascript
- 领域
- frontend
调研方向
从 apps/web-bundle/src/loader.js 开始,其中 loadRemoteModule 会跳过所有不是 ./ 或 ../ 的 specifier(即 isRelative 检查)。与 apps/cli/remote-loader.js 中的 Node 钩子进行比较,后者会相对于插件的 origin 解析根相对 specifier。完成的标准是:在浏览器中加载的插件里,像 /lib/x.js 这样的根相对导入会相对于模块的源 URL 进行解析,并通过 loadRemoteModule 加载;同时绝对的 https: specifier 保持不变,并且两个宿主的结果一致。
由索引模型根据 Issue 内容生成。
描述
What happens
A remote plugin loaded in the browser whose own source imports a root-relative specifier (import x from '/lib/x.js') fails to load. The same plugin loads on Node.
Why
loadRemoteModule in apps/web-bundle/src/loader.js rewrites only ./ and ../ specifiers to their children's blob URLs; anything else is left for the browser (if (!isRelative(spec)) return null). The module itself runs from a blob: URL, and a blob: base cannot resolve any relative reference:
new URL('/x.js', 'blob:http://localhost:8080/0b6e-uuid') // throws ERR_INVALID_URL
Node's hook (apps/cli/remote-loader.js) resolves a root-relative specifier against the plugin's origin, so the two hosts disagree.
Notes toward a fix
Treat a specifier starting with / (but not //) like a relative one: new URL(spec, url) against the module's source URL, then load it through loadRemoteModule. An absolute https: specifier must stay untouched, as now; that is what gives a CDN module its real URL as identity.
Found while reviewing #93.
- 主要语言
- TypeScript
- 星标
- 5
- 派生
- 2
- 平均合并
- 9 小时 5 分钟
- 30 天内合并 PR
- 11
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
MatAtBread/matbot 的其他 Issue
-
future-enhancement
难度 3/5 半天 新手友好度 66/100
MatAtBread/matbot#100 · 2 条评论 ·
维护者通常 1 天内回复
-
future-enhancement
难度 4/5 3-5 天 新手友好度 45/100
MatAtBread/matbot#65 ·
维护者通常 1 天内回复
查看 MatAtBread/matbot 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
awesome-dsh-plugin/awesome-dsh-plugin#9184 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
farion1231/cc-switch#8829 ·
维护者通常 1 天内回复
-
[core-client] Remove unused hand-maintained transport helpers after the definition-table cutover未关闭doc-audit enhancement
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100