Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Importing a subpath of a scoped runtime package, such as /runtime/v1/@opendatacapture/runtime-core/constants, resolves to a nonexistent .../index.js

Aperta Adatta ai principianti
#1,799 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

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

Area: Instruments Bug Difficulty: Low Good First Issue Priority: Low

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

  1. Bundle an instrument whose index.ts contains import { 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

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di DouglasNeuroInformatics/OpenDataCapture

Tutte le issue di DouglasNeuroInformatics/OpenDataCapture

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.