-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
Importing from "svelthree.mjs" throws an Error in some use cases #1
Comments
Just stumbled (while working on WebXR interaction) that we're exporting 'SvelthreeInteraction' although this only being used by components internally (not meant to be used as a component). Removing it might fix the issue (did it already), but I'm too much into WebXR to test it right now. |
This is no problem of svelthree, I am the creator of svelte-materialify and when I run some of my examples in the REPL, they show errors similar to this, but not locally, It seems that this has something to do with precompiled js files. |
I've just tested the assumed fix and yes, it seems fixed now! 🥳 --> no errors when importing from svelthree.mjs (locally). So it was actually a simple bundling problem: I was additionally exporting an "internal" component which was already being included because other components import it. Great! Will keep this open until next release / tested under real circumstances, means if importing from https://unpkg.com/svelthree@latest/dist/svelthree.mjs works as expected. |
☝️ if you need to import from the bundled version 👉 'svelthree.mjs' (not source) and this bug is bugging you, until next release, you could try to apply the fix described above on your local installation and bundle the library (svelthree.mjs) by yourself. Keep svelthreeing! More exciting features coming soon! 🚀 |
Removing SvelthreeInteraction.svelte from exports fixes issue #1
Currently there's an issue bound to library bundling (dist/svelthree.mjs):
When importing from
https://unpkg.com/svelthree@latest/dist/svelthree.mjs
some examples on svelthree.dev/examples "break":means the amount of 3d-objects will not be reduced and an Error is thrown.
☝️ standard local development workflow: installing the library, importing from "svelthree" (means from /src) and publishing / building is not affected by this issue! (there is no Error being thrown)
How to reproduce
REPL
Go to svelthree.dev-example Reactive multiple Mesh group creation (debug version)
This example loads an unminified dev-version of svelthree.mjs including console.info messages and source maps.
Open Chrome Dev Tools
recomended: disable "Info"-level messages & clear REPL console messages
Increase the amount of objects via slider
Try to the decrease the number of objects via slider -> an Error will be thrown:
At this point you could say the Error is bound to REPL, but if you test svethree.mjs locally ...
LOCALLY
npm i
,npm run dev
http://localhost:5000
looking at
svelthree.mjs:217
, the Error happens in this function:on line
outros.c.push(() => {
... putting a breakpoint here and running the same procedure again + going one step back in the Call Stack, you can see the Error happens when Svelte it trying to
transition_out
theslot
and the the two child components inside the Mesh component:Solving Attempt (partially successful)
I managed to prevent the error in the Reactive multiple Mesh creation example by removing conditional rendering of the slot and the child components of the Mesh component + X (see commit Refactor Mesh) and already believed that was it, but then I noticed the Error is still being thrown with grouped Mesh objects.
Next Thought
My next thought was I should 'simply' try to somehow disable transitioning, as svelthree is not using transitions at all. Beside the fact I didn't find any way to do this, I then noticed the problem only occurs if we import from 'svelthree.mjs', importing from 'svelthree' (src) is working like a charm, no errors. 🤷♂️
Conclusion
👉 So the problem must be bound to bundling of svelthree.mjs / general setup.
I've compared both 'svelthree.mjs' (ES) and the working 'bundle.js' (importing from 'svelthree', ES) of the example but didn't notice any anomalies and cannot explain why this specific error get's thrown when importing from 'svelthree.mjs', but not when building from source, means importing from 'svelthree'.
Any hints / help on this issue would be much appreciated! 👍😎
Thanks! ✊
Possible Fix
The text was updated successfully, but these errors were encountered: