cornerstonejs / cornerstone3D

Cornerstone is a set of JavaScript libraries that can be used to build web-based medical imaging applications. It provides a framework to build radiology applications such as the OHIF Viewer.
https://cornerstonejs.org
MIT License
473 stars 249 forks source link

[Bug] Could not find a declaration file for module '@cornerstonejs/dicom-image-loader' in Angular 17 #1155

Open ArnaudAgixis opened 3 months ago

ArnaudAgixis commented 3 months ago

Describe the Bug

When I try to reproduce an example that use dicom-image-loader like this one : DICOM P10 from local file system, the package is not found. I try to install it with npm and yarn. I install the lastest versions. "@cornerstonejs/core": "^1.66.6", "@cornerstonejs/dicom-image-loader": "^1.66.6", "@cornerstonejs/streaming-image-volume-loader": "^1.66.6", "@cornerstonejs/tools": "^1.66.6", All the packages are correctly installed inside the node_modules, or seems to be.

Steps to Reproduce

  1. Setup your new angular 17 project
  2. add with npm or yarn, cornerstone
  3. then cornerstone dicom image loader
  4. import cornerstoneDICOMImageLoader from '@cornerstonejs/dicom-image-loader'; inside a ts file of a component

The current behavior

Could not find a declaration file for module '@cornerstonejs/dicom-image-loader'. 'c:/Users/user/testAppCornerstone3D/node_modules/@cornerstonejs/dicom-image-loader/dist/cornerstoneDICOMImageLoader.bundle.min.js' implicitly has an 'any' type. Try npm i --save-dev @types/cornerstonejs__dicom-image-loader if it exists or add a new declaration (.d.ts) file containing declare module '@cornerstonejs/dicom-image-loader';ts(7016)

The expected behavior

to be able to import @cornerstonejs/dicom-image-loader

OS

Windows 10

Node version

v20.11.1

Browser

Firefox 123.0.1

RadteamBaoDA commented 3 months ago

I'm using angular 17 like you and i can import this library like this. image and add cornerstone config in services file without any error image

sedghi commented 3 months ago

it is odd, search in the cornerstone github, there are some discussions for related issues in vite

ArnaudAgixis commented 3 months ago

I have tried your solution and still have the problem

tonitomystery commented 3 months ago

try copying the cornerstoneDICOMImageLoader.bundle.min.js found in node_modules/@cornerstonejs/dicom-image-loader/dist , to the path src/assets, then including it in the project's index.html

sedghi commented 2 weeks ago

I'm working on cornerstone3D 2.x and have made progress in removing circular dependencies and publishing the types for the DICOM image loader. I'm trying to make it work with Vite, but there are numerous issues with Vite in dev mode, which are not directly related to Cornerstone. Multiple mentions of Vite problems with import.meta.url, web workers, and WebAssembly can be found on the Vite GitHub repository:

https://github.com/vitejs/vite/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+import.meta.url

I have started a template project for Vite, React, and cornerstone3D beta 2.x here. I appreciate your help in making it work.

https://github.com/cornerstonejs/vite-react-cornerstone3d