Any option for ESM support in current release?
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- node.js, typescript
- Ambito
- api
Direzione di ricerca
Inizia riproducendo il comportamento segnalato con il progetto di esempio allegato, in particolare base.mts, classic.ts, commonjs.cts, esm.mts e implicit.ts, utilizzando le impostazioni di package.json e tsconfig.json descritte. Leggi le issues #3335 e #3337 insieme alla riproduzione; il lavoro è completo quando i progetti ESM attuali hanno un modo documentato e verificato per usare @googleapis/sheets, oppure quando il supporto richiesto è chiaramente definito.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I'm attempting to port a node TypeScript project to use the ESM support in newer versions of node and TypeScript.
TypeScript has muddied the water historically by supporting ESM style import/export syntax but still emitting CommonJS format modules for the node ecosystem. Moving things forward means increased consciousness of output format, understanding the format of libraries and falling back to dynamic imports when needed to pull in things that are only still available as CommonJS.
The only dependency that I'm running into a wall with for this project is @googleapis/sheets. It's written in TypeScript, but published as CommonJS with types bundled. That worked when my code was also CommonJS under the hood, but I can't figure out an equivalent way to reference what I need from it in ESM TypeScript.
Attached is an example project showing various approaches. Note the "type": "module" in package.json and the "module": "NodeNext" in tsconfig.json. The intent is to write TypeScript in ESM format, emit verbatim ESM and pull in CommonJS where necessary via import().
base.mts- A base class to force other modules to integrate with something in explicitly ESM format.classic.ts- How we would have used the sheets API historically. But this fails when we try to pull in base because using sheets forces us to CommonJS under the hood so we can't use pure ESM directly.TS1479: The current file is a CommonJS module whose imports will produce require calls; however, the referenced file is an ECMAScript module and cannot be imported with require . Consider writing a dynamic import( ./base.mjs )' call instead.commonjs.cts- The same scenario/problem as classic, just using CommonJS explicitly instead of TypeScript's sugared import/export syntax.esm.mts- An explicitly ESM module. This compiles because it's only dependent on sheets at the type level, and that all gets stripped out in the build. I'm not sure if it would work with more substantial integration since it would be producing ESM style imports for a CommonJS module which wouldn't resolve at runtime.implicit.ts- An implicitly ESM module because the package is ESM and because of the tsconfig. It's trying to use dynamic import but runs into problems because things like interfaces aren't part of the build structure and the classes can only be referenced withtypeof.
I see #3335 and #3337 to improve ESM support, but I'm interested in any workaround I'm overlooking with the current version that would make this usable in an ESM project. At this point sandboxing it as .cts and converting all the ESM imports it needs to dynamic imports seems most equivalent, but it's non-trivial because all of those then have to be dealt with as async.
- Lingua principale
- TypeScript
- Stelle
- 12.3k
- Fork
- 2k
- Merge medio
- 1g 19h
- PR unite (30g)
- 21
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un 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 googleapis/google-api-nodejs-client
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 32/100
googleapis/google-api-nodejs-client#3932 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Discovery Engine] streamAnswer is typed as one AnswerQueryResponse, but REST returns frame arraysAperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 64/100
googleapis/google-api-nodejs-client#3930 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 76/100
googleapis/google-api-nodejs-client#3927 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
size: l type: feature request
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
googleapis/google-api-nodejs-client#3926 ·
I maintainer di solito rispondono entro 1 giorno
-
type: feature request
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
googleapis/google-api-nodejs-client#3903 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di googleapis/google-api-nodejs-client
Issue simili
-
area/frontend good first issue kind/cooldown
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
voidzero-dev/oxc-angular-compiler#511 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
langchain-ai/deepagentsjs#898 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
anomalyco/models.dev#8509 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
bug documentation P2 UI/UX
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno