cyntler / react-doc-viewer

File viewer for React.
https://cyntler.github.io/react-doc-viewer
Apache License 2.0
373 stars 125 forks source link

When i try to build my react application then throw and error . (Module not found: Error: Can't resolve './DocViewer') #268

Closed Mohon45 closed 3 months ago

Mohon45 commented 3 months ago

Screenshot 2024-06-06 063033

Mohon45 commented 3 months ago

how to solve it?

smorton-planview commented 3 months ago

I am seeing the exact same issue with version 1.16.x and up. Prior versions didn't have this problem from what I can tell. The only way I got around this was to add the following into my webpack rules:

   "module":{
      "rules":[
         {
            "test":"/\\.m?js/",
            "resolve":{
               "fullySpecified":false
            }
         }
      ]
   }

I am not a webpack expert so I don't really know if this config is problematic or not. I am curious why this was not required in prior versions of the component.

Mohon45 commented 3 months ago

@smorton-planview where i can write in this rules? i mean which file

smorton-planview commented 3 months ago

That depends on where you store your webpack config. Sorry I cannot be of more help on this. Hopefully a fix is provided that doesn't require this.

cyntler commented 3 months ago

OMG. Generic modules and module types in JS are probably one of the worst things to develop. Eternal problems. Each framework handles this differently...

cyntler commented 3 months ago

This problem probably is related to Webpack... https://webpack.js.org/configuration/module/#resolvefullyspecified. I don't know currently how I should to fix it on the library level.

cyntler commented 3 months ago

@Mohon45 @smorton-planview Please check the latest version: 1.16.2. I migrated to Vite build/compilation system instead of pure TS.

smorton-planview commented 3 months ago

@cyntler I no longer see the build issues after upgrading to 1.16.2. Thanks!

cyntler commented 3 months ago

@cyntler I no longer see the build issues after upgrading to 1.16.2. Thanks!

Sounds great! Thanks for feedback!