cornerstonejs / cornerstoneWADOImageLoader

[DEPRECATED] DICOM WADO Image Loader for the cornerstone library
MIT License
284 stars 265 forks source link

Can't resolve `fs` in cornerstone-wado-image-loader in 3.0.0 #273

Open mikehazell opened 5 years ago

mikehazell commented 5 years ago

Getting this error when building my app.

ERROR in /Users/.../ProjectName/node_modules/cornerstone-wado-image-loader/dist/cornerstoneWADOImageLoader.min.js
Module not found: Error: Can't resolve 'fs' in '/Users/.../ProjectName/node_modules/cornerstone-wado-image-loader/dist'

I'm am using Next.js which has a default webpack config. Luckily this issue can be resolved on my end by adding to following to the webpack config.

// next.config.js
export {
  webpack(config) {
    config.externals = { fs: 'commonjs fs' };
    return config;
  }
}

Can this be resolved in the package?

dannyrb commented 5 years ago

👋 Hi @mikehazell, long time no see.

Can this be resolved in the package?

I'm not sure. I see that we have it in our own config here:

I'm not 100% sure what's causing the issue. Some of the decoders for this library are imported "as is". It's possible we're not trimming some node specific imports from them, Pako, or something in the WebWorker space.

If we can identify the cause, I might be able to prioritize getting a solution in place.

Meta-Maxim commented 5 years ago

I started having a similar issue after updating to 3.0.0, it's caused by some of the codecs requiring fs: charLS-FixedMemory-browser.js openJPEG-FixedMemory.js

fs may be used by their dependencies, I just noticed that those codecs had a require("fs") in the final bundle.

sedenardi commented 5 years ago

I was able to fix this by adding node: { fs: 'empty' } to my webpack config. Thanks for the tip guys.

fomin-max commented 4 years ago

I was able to fix this by adding node: { fs: 'empty' } to my webpack config. Thanks for the tip guys.

+1 this decision helped for me too, thanks

sp1805 commented 4 years ago

I was able to fix this by adding node: { fs: 'empty' } to my webpack config. Thanks for the tip guys.

I did the same, but no luck , I am still getting the error

adamwdennis commented 4 years ago

I am also getting this error.

desprit commented 4 years ago

Didn't work for me. I have node: { fs: 'empty' } but still get that error.

elimb commented 4 years ago

I had the same issue in my angular project. resolved with "fs": false in browser entry in package.json

desprit commented 4 years ago

I'm using cornerstone with storybooks. And this is mainly storybooks that's causing problem. Long story short: https://stackoverflow.com/a/64246289/3459479

facuescobar commented 4 years ago

Hi!

I was getting the same error with 'fs' and 'path'

Module not found: Error: Can't resolve 'fs' in '/Users/.../dev/.../node_modules/cornerstone-wado-image-loader/dist'
...

Module not found: Error: Can't resolve 'path' in '/Users/.../dev/.../node_modules/cornerstone-wado-image-loader/dist'

I was able to fix this error by adding the following code to my webpack.config.js

resolve: {
    fallback: { fs: false, path: false },
},

hope this helps!