Skip to content
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

Need a helpful warning if studio is imported but no initialized #21

Open
AriaMinaei opened this issue Sep 29, 2021 · 6 comments
Open

Need a helpful warning if studio is imported but no initialized #21

AriaMinaei opened this issue Sep 29, 2021 · 6 comments

Comments

@AriaMinaei
Copy link
Member

AriaMinaei commented Sep 29, 2021

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 but studio.initialize() is not called within a time period.

Thanks @RuiOrey for the report :)

@RuiOrey
Copy link

RuiOrey commented Sep 29, 2021

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.

@AriaMinaei
Copy link
Member Author

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.

@RuiOrey
Copy link

RuiOrey commented Sep 29, 2021

But shouldn't that only happen if we call studio.initialize() ?

@AriaMinaei
Copy link
Member Author

AriaMinaei commented Sep 30, 2021

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.

@loklaan
Copy link

loklaan commented Apr 9, 2023

@AriaMinaei this looks to be closed by this commit.

@OppositeX
Copy link

OppositeX commented Jul 25, 2024

this issue is still an issue when using cdn with the old 0.5v

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants