Resolve `npm:`/`jsr:` versions from the installed tree for Deno-based presets

Aperta
#4,618 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
45/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
deno, typescript

Direzione di ricerca

Inizia da src/build/plugins/externals.ts in corrispondenza del logging esistente di TracedPackage.versions e da src/build/plugins.ts in corrispondenza del controllo di nitro.options.node; confronta il modo in cui i preset deno_deploy e bunny configurano questi percorsi. Chiarisci la configurazione opt-in e il comportamento delle dipendenze transitive, quindi verifica che vengano emesse le versioni dirette installate per i preset Deno pertinenti.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

externals preset:deno
Describe the feature

While fixing something on the Bunny preset (#4025) I've made the Deno-based presets keep npm: and jsr: specifiers external, so import { escape } from "npm:[email protected]" survives the bundle and gets resolved by the runtime instead of failing to resolve at build time.

That part works, but pinning the version is currently entirely on the user. What I would actually like is to mark a package as external and have Nitro emit the version that is installed, so a plain import { decodeJwt } from "unjwt" comes out as npm:[email protected] even when package.json says ^0.7.0.

The clearest win is on Bunny, where the script is a single file with a 10MB cap, so keeping deps out of the bundle actually matters. Tho it would apply to deno_server and deno_deploy just as well, for custom implementations and runtimes.

Most of the machinery seems to already be there: nf3 hands us the exact resolved versions per package (TracedPackage.versions), and we already consume that hook in
externals.ts only to log them.

Two things I got stuck on though:

  1. the trace only runs when nitro.options.node is true, and the presets that would want this (deno_deploy, bunny) set node: false. So the version resolution would need to be independent from the file-copying path
  2. it only pins the direct dependency. Deno then resolves the transitive ones from the registry on its side, so it is a partial pin and not really a lockfile equivalent. I am not sure whether that is acceptable or if it defeats the point

I also have no strong opinion on the config surface, an opt-in list of packages feels right but that is about as far as I got.

Additional information
  • Would you be willing to help implement this feature?
Lingua principale
TypeScript
Stelle
11.5k
Fork
968
Merge medio
4g 9h
PR unite (30g)
64

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

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 nitrojs/nitro

Tutte le issue di nitrojs/nitro

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.