-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
AppBase refactored out of the Application to allow for tree-shaking #4082
Conversation
It would be great, if we would have access to components selection from the Editor. The builder would then assemble an application based on that configuration. |
Yes, in the longer term the plan is to certainly allow tree shaking in the Editor, likely in a form of some builder. The complexity we need to solve after this PR is the scripts - as those are not modules (for now anyways), and so we cannot easily find out what needs to be imported to the application. |
# Conflicts: # src/font/canvas-font.js # src/resources/container.js # src/scene/picker.js
Based on #3949
This is an initial refactoring of AppBase class out of the Application. There will be follow up PRs removing some additional functionality / imports from AppBase.
The situation before this PR: we have an Application module, which imports and instantiates every other module the application needs - even when the user's application does not need them, limiting the usefulness of tree shaking.
This PR extracts a BaseApp class from the Application, which holds and uses all other instances of classes as before, but does not instantiate them. This part is left in the Application.
This allows the user to instead of using Application with all dependencies, to simply use the AppBase, and decide what dependencies are needed.
As an example, at the moment this is what users do to create application, which imports all modules from the engine:
this PR allows to allocate AppBase, and import only what is needed:
The way this works is that user imports the module, and assigns a class constructor to the createParameters. This allows AppBase Internally to call new on that object to allocate the instance. This removes the need for the user to call the constructor at all. There are few advantages here:
example for this. We use this:
instead of
Basic testing to confirm we load less modules (using minimum app)