cornerstone3D
cornerstone3D copied to clipboard
[Bug] Warning for WSIViewport.js: Critical dependency: the request of a dependency is an expression
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.
And the line 274 from @cornerstonejs/core/dist/esm/RenderingEngine/WSIViewport.js
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,
}
};
- Make dist/index.html and call index.js into it.
- Run
npx webpack --mode development - 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)
me too same problem
are you using vite? i will fix this in the 2.x version
No, we use webpack.
I am using Webpack and facing same issue.
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.
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
- To get rid of the black overlay I used
client: {overlay: false}in mywebpack.config.js
module.exports = {
devServer: {
client: {overlay: false,},
}
}
Note, the warning still persists in the console
- I also added
module: { unknownContextCritical: false, }, though the warning still persists.
It seems to be resolved. Using v1.82.0