Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
prerakmody opened this issue Jun 14, 2024 · 7 comments

Comments

@prerakmody
Copy link

prerakmody commented Jun 14, 2024

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)

@jlopes90
Copy link
Contributor

me too same problem

@sedghi
Copy link
Member

sedghi commented Jun 21, 2024

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

@jlopes90
Copy link
Contributor

No, we use webpack.

@idemopacs
Copy link

I am using Webpack and facing same issue.

@wayfarer3130
Copy link
Collaborator

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.

@prerakmody prerakmody changed the title [Bug] Error for WSIViewport.js: Critical dependency: the request of a dependency is an expression [Bug] Warning for WSIViewport.js: Critical dependency: the request of a dependency is an expression Jun 25, 2024
@prerakmody
Copy link
Author

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.

@jlopes90
Copy link
Contributor

jlopes90 commented Jul 9, 2024

It seems to be resolved. Using v1.82.0

@sedghi sedghi closed this as completed Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants