microsoft / microsoft/DefinitelyTyped-tools

`dts-gen` doesn't work with `cloudflare-video-element`: require() of ES Module not supported.

Open
#1,001 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
423
Forks
237
Avg merge
18h 18m
Merged PRs (30d)
11

Description

I tried generating for this project cloudflare-video-element but it failed with the following error. (I tried both project install and global install. The error is the same.)

dts-gen -m cloudflare-video-element
Unexpected crash! Please log a bug with the commandline you specified.
/opt/homebrew/lib/node_modules/dts-gen/dist/run.js:84
        result = guess.generateModuleDeclarationFile(args.module, require(args.module));
                                                                  ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /opt/homebrew/lib/node_modules/cloudflare-video-element/cloudflare-video-element.js from /opt/homebrew/lib/node_modules/dts-gen/dist/run.js not supported.
Instead change the require of cloudflare-video-element.js in /opt/homebrew/lib/node_modules/dts-gen/dist/run.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/opt/homebrew/lib/node_modules/dts-gen/dist/run.js:84:67) {
  code: 'ERR_REQUIRE_ESM'
}

Node.js v20.5.1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with dts-gen -m cloudflare-video-element on Node.js 20.5.1, then inspect dist/run.js around line 84 where the module is loaded with require(). Determine how declaration generation should handle this ES module and verify that the command completes successfully for the reported package.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.