nodejs / nodejs/node

Support clearing Node.js cache for package.json

Aperta
#54,924 10 commenti 2 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

feature request loaders never-stale
Lingua principale
JavaScript
Stelle
122k
Fork
37.3k
Merge medio
4g 2h
PR unite (30g)
283

Descrizione

What is the problem this feature will solve?

When a long-running Node.js process is active and a package.json file is modified (for example, by adding "type": "module"), Node.js does not detect this change. It continues treating the package as CommonJS, which results in an error like Unexpected token 'export' when attempting to use ES modules.

This is crucial for us at bit, where we run a background process called “bit server” that manages the local development workspace. Among its tasks is creating new web components, which initially have a package.json without "type": "module". If the component is later determined to be ESM, the package.json is updated accordingly. (Explaining why this can’t be handled differently is beyond the scope of this feature request).

What is the feature you are proposing to solve the problem?

I propose adding an API that allows clearing the cached information related to the package.json of a specific module (or optionally clearing the cache for all modules). Either option would solve the issue.

What alternatives have you considered?

Restarting the Node.js process, but this results in a poor user experience.

Guida per i contributori

Apri la guida per i contributori

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.

Direzione di ricerca

Nell’issue non sono indicati né un file né un test. Inizia tracciando dove Node.js memorizza nella cache i metadati del modulo di package.json, quindi definisci un’API per cancellare la cache di un modulo e, facoltativamente, di tutti i moduli; il lavoro è completato quando le modifiche al tipo di pacchetto vengono riconosciute senza riavviare il processo.

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

Valutazione

Stack tecnologico
javascript, node.js
Ambito
backend
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.