web-bundle: remote plugin imports are found by regex, so a computed import() is missed
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- javascript, node.js, typescript
- Domain
- frontend
Research direction
Start in apps/web-bundle/src/loader.js, where SPEC_RE finds imports and rewrites relative ones to blob URLs, then compare with apps/cli/remote-loader.js, whose header explains why resolving as the module system requests avoids the regex's failure modes. Reproduce a computed import(variable) of a sibling file in the browser and an import text inside a string or comment. Done means the browser loads both cases as Node does, but the fix needs a design choice between a real parse with sucrase and a service worker, so confirm the approach with the maintainer first.
Written by the indexing model from the issue text.
Description
What happens
In the browser, a remote plugin's computed dynamic import (import(variable)) of one of its own files fails, and an import inside a string, comment or template literal can be rewritten. The same plugin works on Node.
Why
apps/web-bundle/src/loader.js finds imports with a regex (SPEC_RE) and rewrites the relative ones to blob URLs before the module runs. A computed specifier is invisible to it and is left to resolve against the module's blob: URL, which cannot resolve a relative reference. The regex also cannot tell an import from the same text inside a string or comment.
Node stopped predicting the graph this way: apps/cli/remote-loader.js resolves each import as the module system actually requests it, and its header gives the regex scan's failure modes as the reason.
Notes toward a fix
The browser has no resolve hook for blob modules, so the options are a real parse (sucrase is already loaded for type stripping and can give import positions) plus a runtime helper for computed specifiers, or a service worker serving the plugin under its real URL so the browser resolves natively. The second would also fix root-relative imports and import.meta.url, at the cost of the in-memory, no-service-worker design.
Found while reviewing #93.
- Dominant language
- TypeScript
- Stars
- 5
- Forks
- 2
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 12
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
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
MatAtBread/matbot#95 ·
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
-
http: let a header value come from the Vault, so a keyed API needs no secret in the conversationOpenenhancement
Difficulty 4/5 3-5 days Newbie friendliness 22/100
MatAtBread/matbot#104 ·
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
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
MatAtBread/matbot#65 ·
Maintainers usually reply within 1 day
All issues in MatAtBread/matbot
Similar issues
-
area:ui effort:S enhancement priority:P2
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
QuantumNous/new-api#7839 ·
Maintainers usually reply within 1 day
-
good first issue maintenance
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
dark-princezz/stellar-hooks#1010 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
interledger/rhyza#352 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day