cornerstone3D icon indicating copy to clipboard operation
cornerstone3D copied to clipboard

[Bug] Warning for WSIViewport.js: Critical dependency: the request of a dependency is an expression

Open prerakmody opened this issue 1 year ago • 6 comments

Describe the Bug

Hi, I get the following warning when running @cornerstone/core (1.78.0) on a local machine with node.

WARNING in ./node_modules/@cornerstonejs/core/dist/esm/RenderingEngine/WSIViewport.js 274:14-42
Critical dependency: the request of a dependency is an expression

Also, check image below. image

And the line 274 from @cornerstonejs/core/dist/esm/RenderingEngine/WSIViewport.js image

Although this does not block my script from running, it is quite annoying (I need to keep hitting the cross on the top-right everytime).

I did not see find any reference to this on the cornerstone3D repo's issues tab. Maybe this is something worth looking into.

Steps to Reproduce

To reproduce one can use the package.json and webpack.config.js below:

{
  "dependencies": {
    "@cornerstonejs/calculate-suv": "^1.1.0",
    "@cornerstonejs/core": "^1.78.0",
    "@cornerstonejs/dicom-image-loader": "^1.77.13",
    "@cornerstonejs/nifti-volume-loader": "^1.77.13",
    "@cornerstonejs/streaming-image-volume-loader": "^1.77.13",
    "@cornerstonejs/tools": "^1.77.13",
    "dcmjs": "^0.33.0",
    "dicom-parser": "^1.8.21",
    "dicomweb-client": "^0.10.4",
    "webpack": "^5.92.0",
    "webpack-cli": "^5.1.4",
    "webpack-dev-server": "^5.0.4"
  },

  "scripts": {
    "start": "webpack serve --open --mode development",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "devDependencies": {
    "css-loader": "^6.9.1",
    "style-loader": "^3.3.4",
    "webpack": "^5.90.0",
    "webpack-cli": "^5.1.4",
    "webpack-dev-server": "^4.15.1"
  },
  "description": ""
}
const path = require('path');

module.exports = {
  entry: './src/index3D.js',
  output: {
    filename: 'main.js',
    path: path.resolve(__dirname, 'dist'),
  },
  devtool: 'inline-source-map',
  devServer: {
    static: path.join(__dirname, 'dist'),
    compress: true,
    port: 8080,
    headers: {
      "Access-Control-Allow-Origin": "*",
      "Cross-Origin-Embedder-Policy": "require-corp",
      "Cross-Origin-Opener-Policy": "same-origin",     
    },
    hot: true,
  }
};
  1. Make dist/index.html and call index.js into it.
  2. Run npx webpack --mode development
  3. Run npm start

The current behavior

I get a warning from WSIViewport.js saying: Critical dependency: the request of a dependency is an expression

The expected behavior

The warning in WSIViewport.js should not show up. I also tried this on a jsfiddle, but it did not show the warning.

OS

macOS 14.2

Node version

20.8.0

Browser

Brave Browser (v 1.65.126)

prerakmody avatar Jun 14 '24 17:06 prerakmody

me too same problem

jlopes90 avatar Jun 16 '24 13:06 jlopes90

are you using vite? i will fix this in the 2.x version

sedghi avatar Jun 21 '24 15:06 sedghi

No, we use webpack.

jlopes90 avatar Jun 21 '24 15:06 jlopes90

I am using Webpack and facing same issue.

idemopacs avatar Jun 24 '24 09:06 idemopacs

What are you doing that it comes out as an error? The webpack builds that I'm working with all show it as a warning, not an error: @ohif/app: WARNING in ../../../../cornerstone3D-beta/packages/core/dist/esm/RenderingEngine/WSIViewport.js 446:8-44 @ohif/app: Critical dependency: the request of a dependency is an expression @ohif/app: @ ../../../../cornerstone3D-beta/packages/core/dist/esm/index.js 11:0-56 30:0-999 @ohif/app: @ ../../../extensions/cornerstone-dynamic-volume/src/index.ts @ohif/app: @ ./pluginImports.js @ohif/app: @ ./index.js 19:0-89 33:4-21 34:4-16

Try adding to the webpack module: { unknownContextCritical: false, }

Also, you may not be able to build/run with Webpack 5.92.0 - try forcing it on 5.89.0 as there is a bug in 5.90 and later causing static values to be not compiled properly.

wayfarer3130 avatar Jun 24 '24 16:06 wayfarer3130

Hi, I have now updated the title of this to include the word "warning" and not "error", since that is what I was really facing (as also seen in the snapshots).

Other points

  1. To get rid of the black overlay I used client: {overlay: false} in my webpack.config.js
module.exports = {
    devServer: {
        client: {overlay: false,},
    }
}

Note, the warning still persists in the console

  1. I also added module: { unknownContextCritical: false, }, though the warning still persists.

prerakmody avatar Jun 25 '24 11:06 prerakmody

It seems to be resolved. Using v1.82.0

jlopes90 avatar Jul 09 '24 14:07 jlopes90