Elius94 / react-photo-sphere-viewer

Photosphere Viewer for React.JS
MIT License
65 stars 21 forks source link

[Support]: multiple three js bundles. #39

Closed PaleHazy closed 8 months ago

PaleHazy commented 10 months ago

What are you trying to do?

I am trying to figure out why multiple bundles of three js are being included in the build and I think I was able to track it down to a version mismatch in the peer dependencies of https://github.com/Elius94/psv-lens-flare-plugin.

I was wondering if you had some approaches to fix this, other than just keeping all the three versions the same

Code

No response

Sandbox Link

No response

Library Version

latest

What operating system are you using?

Windows

What browser are you using?

Chrome

Logs

No response

Elius94 commented 10 months ago

Hi! I don't know why it happens. In my Lensflare plugin you can see that three is a peer dependency.

https://github.com/Elius94/psv-lens-flare-plugin/blob/784a7b4ebd78de0f8a5a071d97f2a26ce9ba8207/package.json#L37C5-L37C5

So, I don't really know how to prevent this. Can you help me?

PaleHazy commented 10 months ago

I believe my initial assessment regarding the source of the dependency conflict might have been inaccurate.

One version is located here:

image

And another at the root of node_modules:

image

This duplication results in the inclusion of two distinct threejs builds in the final bundle.

Additionally, my application already incorporates a three instance, leading to the somewhat amusing situation of having three different three bundles

image

I observed that react-photo-sphere-viewer lists @photo-sphere-viewer as a direct dependency. When running the build from the repository, I noticed code references to the original package attempting imports from "../node_modules/....".

A potential solution could be to reclassify @photo-sphere-viewer and other similar imports as peer dependencies instead of direct dependencies. This approach might immediately resolve the conflict. However, it also poses the inconvenience of requiring users to manually install these dependencies.

Alternatively, could we explore modifying the code to support dynamic imports for all features? This might offer a more streamlined and flexible solution.

image

Lastly, it seems that some plugins are imported solely for re-export. In these cases, providing users the option to manually import these plugins from @photo-sphere-viewer could be a more efficient approach.

PaleHazy commented 10 months ago

also to mention, bumping all packages so that the three version are the same does result in ones single three bundle

Elius94 commented 8 months ago

It should be fixed in the 4.2.3-psv5.6.0 release. I'm interested to find a solution to prevent from including all plugins in the package. Do you have any idea for that? Thanks