-
Notifications
You must be signed in to change notification settings - Fork 3.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
Remove use of RegisterClass #15671
base: master
Are you sure you want to change the base?
Remove use of RegisterClass #15671
Conversation
Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). |
@@ -1,6 +1,6 @@ | |||
import { NodeGeometryBlock } from "../nodeGeometryBlock"; | |||
import type { NodeGeometryConnectionPoint } from "../nodeGeometryBlockConnectionPoint"; | |||
import { RegisterClass } from "../../../Misc/typeStore"; | |||
import {} from "../../../Misc/typeStore"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be removed I guess :-)
if (!_DiscoveredTypes) { | ||
_DiscoveredTypes = {}; | ||
// Use require.context to import all modules | ||
const requireModule = require.context( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this not webpack specific ? cause this would basically fail for anybody bundling without Webpack ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is THE question:) hence why I wanted @ryantrem to check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can pull your branch and test it out with the viewer (which uses rollup) to be sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I commented about it. We can't use require.context if we want to stay esm friendly
Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). |
require.context is not ecma standard, and is webpack specific. adding this will make our package not work in browser anymore. Let's find a better way instead of that. The idea of require.context is to be a synchronous import, but this is bundler specific (webpack in this case). |
This will be changed as part of the changes I am making. there was a thought to shorten the names of the classes to save a few bytes, but this is not the right place to minimize input :-) |
Hey this is basically my question. Rollup and parcel have no equivalent so if we want to be side effects free what are our options regarding RegisterClass within the framework? |
typeStore (e.g. |
It is internal to allow us to parse from serialized data (as the class will store its type so we can rebuild it at parse time). The question is then: how do you replace the feature? |
Ok folks! another new monster :)
I removed the need for side-effects for a LOT OF classes by replacing RegisterClass with the use of require.context
@ryantrem: please make sure that it is not a problem for the Viewer
@RaananW: I did not do the change for the FlowGraph because for some reasons that I do not know you are using FGxxx in the key for RegisterClass
The main class:
https://github.com/BabylonJS/Babylon.js/pull/15671/files#diff-6a2ff5432bcbb1632f27a94f714a7a50f7b3c4cac5d35bd7b7f8570746752e12