Any option for ESM support in current release?
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- node.js, typescript
- Lĩnh vực
- api
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện hành vi đã được báo cáo với dự án mẫu đính kèm, đặc biệt là base.mts, classic.ts, commonjs.cts, esm.mts và implicit.ts, bằng cách sử dụng các thiết lập package.json và tsconfig.json được mô tả. Đọc các issue #3335 và #3337 cùng với phần tái hiện; công việc hoàn tất khi các dự án ESM hiện tại có một cách được ghi chép và xác minh để sử dụng @googleapis/sheets, hoặc khi phạm vi hỗ trợ cần thiết được xác định rõ ràng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- TypeScript
- Star
- 12.3k
- Fork
- 2k
- Merge trung bình
- 1 ngày 19 giờ
- Pull request đã merge (30 ngày)
- 21
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của googleapis/google-api-nodejs-client
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 32/100
googleapis/google-api-nodejs-client#3932 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Discovery Engine] streamAnswer is typed as one AnswerQueryResponse, but REST returns frame arraysĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 64/100
googleapis/google-api-nodejs-client#3930 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 76/100
googleapis/google-api-nodejs-client#3927 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
size: l type: feature request
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
googleapis/google-api-nodejs-client#3926 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
type: feature request
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
googleapis/google-api-nodejs-client#3903 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của googleapis/google-api-nodejs-client
Issue tương tự
-
bug via-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
pingdotgg/t3code#14452 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
solana-foundation/program-examples#747 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 9 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
remotion-dev/remotion#11847 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
openwatersio/slackwater#355 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
melgarafael/DeskcommCRM#1998 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày