Importing a subpath of a scoped runtime package, such as /runtime/v1/@opendatacapture/runtime-core/constants, resolves to a nonexistent .../index.js
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 84/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- node.js, typescript
- Ambito
- build-system
Direzione di ricerca
Leggi packages/instrument-bundler/AGENTS.md e controlla la logica di corrispondenza dei percorsi in packages/instrument-bundler/src/plugin.ts:23-26. Aggiungi o aggiorna i casi in packages/instrument-bundler/src/__tests__/plugin.test.ts per un subpath scoped, un subpath che termina in .js e il pacchetto scoped senza subpath, poi esegui quel test unitario. Il lavoro è completato quando i subpath vengono risolti con .js mentre solo il pacchetto senza subpath viene risolto in /index.js.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
The bundler rewrites any import of a subpath of a scoped runtime package to a URL that does not exist. For bare packages, the rule in plugin.ts appends /index.js to /runtime/v1/<pkg> and /runtime/v1/@scope/<pkg>. But its scope group is (@.*\/)?, and .* also matches /, so it swallows any number of path segments. /runtime/v1/@opendatacapture/runtime-core/constants therefore becomes /runtime/v1/@opendatacapture/runtime-core/constants/index.js instead of …/constants.js, and an import that already ends in .js gets /index.js appended after the .js. packages/instrument-bundler/AGENTS.md documents the opposite: only the bare package gets /index.js, and everything deeper gets .js. The import type-checks, because runtime/v1/dist/@opendatacapture/runtime-core/constants.d.ts exists. The bundle then fails to evaluate: on the API the subpath import does not resolve, and in the browser the module 404s. Today this affects FILE_TYPES from /runtime/v1/@opendatacapture/runtime-core/constants, and any future scoped package that ships a subpath.
Where
packages/instrument-bundler/src/plugin.ts:23-26:
} else if (/\/runtime\/v1\/(@.*\/)?[^/]+$/.test(args.path)) {
return { external: true, path: `${args.path}/index.js` };
} else if (args.path.startsWith('/runtime/v1/')) {
return { external: true, path: args.path.endsWith('.js') ? args.path : `${args.path}.js` };
Reproduce
- Bundle an instrument whose
index.tscontainsimport { FILE_TYPES } from '/runtime/v1/@opendatacapture/runtime-core/constants';.
Actual: the bundle contains __import("/runtime/v1/@opendatacapture/runtime-core/constants/index.js") (verified on main), which neither the API nor the browser can load. /runtime/v1/@opendatacapture/runtime-core/constants.js becomes …/constants.js/index.js.
Expected: __import("/runtime/v1/@opendatacapture/runtime-core/constants.js"), which is the file runtime/v1/dist serves.
Tests
packages/instrument-bundler/src/__tests__/plugin.test.ts: it('should append .js to a subpath of a scoped runtime package, so only the bare package resolves to index.js'). Cover @opendatacapture/runtime-core/constants, …/constants.js and the bare @opendatacapture/runtime-core.
e2e: none needed beyond the unit test, since no built-in instrument imports a scoped subpath yet.
Suggested fix
Stop the scope group at one segment and anchor the pattern: /^\/runtime\/v1\/(@[^/]+\/)?[^/]+$/.
- Lingua principale
- TypeScript
- Stelle
- 119
- Fork
- 19
- Merge medio
- 1g 2h
- PR unite (30g)
- 56
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di DouglasNeuroInformatics/OpenDataCapture
-
Area: Playground Bug Difficulty: Low Good First Issue Priority: Low
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
DouglasNeuroInformatics/OpenDataCapture#1805 ·
I maintainer di solito rispondono entro 1 giorno
-
Area: Instruments Bug Difficulty: Low Priority: Low
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
DouglasNeuroInformatics/OpenDataCapture#1801 ·
I maintainer di solito rispondono entro 1 giorno
-
Area: Instruments Bug Difficulty: Low Good First Issue Priority: Low
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
DouglasNeuroInformatics/OpenDataCapture#1800 ·
I maintainer di solito rispondono entro 1 giorno
-
Area: Instruments Bug Difficulty: Low Performance Priority: Medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
DouglasNeuroInformatics/OpenDataCapture#1795 ·
I maintainer di solito rispondono entro 1 giorno
-
Area: Outreach Bug Difficulty: Low Priority: Medium Security
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
DouglasNeuroInformatics/OpenDataCapture#1791 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di DouglasNeuroInformatics/OpenDataCapture
Issue simili
-
bug priority:low ready-for-dev
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
Automattic/data-liberation-agent#685 ·
I maintainer di solito rispondono entro 1 giorno
-
Business
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
txn2/mcp-data-platform#2063 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 77/100
Crosstalk-Solutions/project-nomad#1427 ·
I maintainer di solito rispondono entro 2 giorni