google-ai-edge / mediapipe

Cross-platform, customizable ML solutions for live and streaming media.
https://ai.google.dev/edge/mediapipe
Apache License 2.0
27.42k stars 5.15k forks source link

@mediapipe/tasks-vision include types exports in package.json #4659

Closed KostisP closed 1 year ago

KostisP commented 1 year ago

Have I written custom code (as opposed to using a stock example script provided in MediaPipe)

No

OS Platform and Distribution

javascript

MediaPipe Tasks SDK version

No response

Task name (e.g. Image classification, Gesture recognition etc.)

all

Programming Language and version (e.g. C++, Python, Java)

javascript 0.3.10

Describe the actual behavior

Typescript cannot find a declaration file for @mediapipe/tasks-vision module.

Describe the expected behaviour

`"types": "./vision.d.ts" ` should be added under exports in package.json

`
"exports": {
    "import":  "./vision_bundle.mjs",
    "require": "./vision_bundle.cjs",
    "default":  "./vision_bundle.mjs",
    "types": "./vision.d.ts" 
  }
`

Standalone code/steps you may have used to try to get what you need

import { FaceLandmarker } from '@mediapipe/tasks-vision';

Other info / Complete Logs

No response

zoeleu commented 1 year ago

Just now faced this issue.

kiochan commented 1 year ago

@KostisP Here is a temporary solution for this issue.

In your tsconfig change moduleResolution to node. This solution will force typescript compiler to read types from the root of package.json file.

{
  "compilerOptions": {
    "moduleResolution": "node",
  }
}
schmidt-sebastian commented 1 year ago

Will add this. Should be part of next release.

google-ml-butler[bot] commented 1 year ago

Are you satisfied with the resolution of your issue? Yes No

sunapi386 commented 1 year ago

Take a look at this issue https://stackoverflow.com/questions/66096260/why-am-i-getting-referenceerror-self-is-not-defined-when-i-import-a-client-side

In short, the error occurs because the library requires Web APIs to work, which are not available when Next.js pre-renders the page on the server-side.

zoeleu commented 1 year ago

Take a look at this issue https://stackoverflow.com/questions/66096260/why-am-i-getting-referenceerror-self-is-not-defined-when-i-import-a-client-side

In short, the error occurs because the library requires Web APIs to work, which are not available when Next.js pre-renders the page on the server-side.

No. I faced this issue outside of Next.js.