web-bundle: a redirected remote module resolves its imports against the requested URL
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript, typescript
- Domain
- frontend
Research direction
Start in loadRemoteModule in apps/web-bundle/src/loader.js, where child imports are resolved with new URL(spec, url) against the requested URL rather than the response. Check the remoteCache lookup and the fetch response, and confirm how the .ts fallback is handled. Done means relative imports resolve against the final response URL and the cache is keyed by that URL, so a redirect and its target load once.
Written by the indexing model from the issue text.
Description
What happens
If a remote plugin's module is served by redirect, the browser resolves that module's relative imports against the URL that was requested rather than the one that answered, so they fetch the wrong paths.
Why
loadRemoteModule in apps/web-bundle/src/loader.js resolves children with new URL(spec, url), where url is the URL it asked for (or its .ts fallback), never res.url. A redirect is common on CDNs, e.g. unpkg answers https://unpkg.com/lit@3?module from https://unpkg.com/[email protected]/index.js?module=, and ./x.js from that file belongs under [email protected]/, not at the host root.
remoteCache is also keyed by the requested URL, so two URLs that redirect to one module load it twice.
Notes toward a fix
Resolve children against res.url, and key the cache by it, so a redirect and its target share one module. This matches how the browser treats a module it loads natively, and how Node resolves a URL import on the remote-url-identity branch.
Raw GitHub, the usual plugin host, does not redirect file requests, so this mostly affects plugins served from a CDN.
Found while reviewing #93.
- Dominant language
- TypeScript
- Stars
- 5
- Forks
- 2
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 11
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from MatAtBread/matbot
-
Difficulty 1/5 Under an hour Newbie friendliness 74/100
MatAtBread/matbot#99 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
MatAtBread/matbot#94 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 Half a day Newbie friendliness 66/100
MatAtBread/matbot#100 · 1 comment ·
Maintainers usually reply within 1 day
-
plugin add/remove: nothing records what an install created, so the undo and the uninstall both guessPossibly taken @MatAtBread claimed this today. Openbug
Difficulty 5/5 Over a week Newbie friendliness 12/100
MatAtBread/matbot#98 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 35/100
MatAtBread/matbot#96 ·
Maintainers usually reply within 1 day
All issues in MatAtBread/matbot
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
status:approved type:bug
Difficulty 1/5 Under an hour Newbie friendliness 70/100
egdev6/quorb#109 · 1 comment ·
Maintainers usually reply within 1 day
-
stage:4
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
ilan-pinto/roaring-lions#598 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Frontmatter next to `src:` is applied to every imported slide, not only the first (undocumented)Open
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day