Open AriaMinaei opened 2 years ago
You're welcome @AriaMinaei ! Anyways, even if it is imported without being initialized, should it not impact the loading and play of sequences, right? Seems there is some sort of code that is executed that breaks loading a json file and playing it.
Well if studio is present, all state loading is deferred to it. Otherwise, we'll have a situation where the state jumps from one that is provided to core, to one that studio has saved in localStorage.
But shouldn't that only happen if we call studio.initialize()
?
I see what you mean. The word "initialize" implies that, if not called, then it shouldn't affect anything. So @theatre/core
would work as if @theatre/studio
is not present.
The reason it doesn't work that way is that there is no use in having @theatre/studio
in the bundle if it isn't initialized. The reason I implemented initialize()
was to give us a chance to configure the studio before it renders. So, if the studio is in the bundle but not initialized, then it's just taking up bundle space.
That's why I thought it's better to just warn the user if they're not calling initialize()
right away.
@AriaMinaei this looks to be closed by this commit.
Since tree-shaking in different build systems is not bullet proof, there are situations where the user intends for
@theatre/studio
to not be included in the bundle but it still ends up in there. We can help the user avoid this situation by emitting a warning if the studio is imported butstudio.initialize()
is not called within a time period.Thanks @RuiOrey for the report :)