Module Loader
| Epic | https://github.com/flipbook-labs/flipbook/issues/472 |
Overview
Going to be refactoring the ModuleLoader package this quarter.
Collaborating with the folks that maintain Jest Roblox
Requirements
- Support for require-by-string
- Supported aliases will be
@selfand@game - Relative paths with
./,../,../../, etc. - No support for absolute paths like
/foo/bar - No support for complex paths like
foo/../bar
- Supported aliases will be
- Great error messages
- Great recovery from failures
- RobloxTS support 5. No walking back _G. If a module is changed, re-require the whole thing
- Improved story sandboxing
- Detect when a module changes so the user can re-require
- Preload modules in the cache
- [Stretch] Visualize dependency graph
Open Questions
- What would be a good way to test
loadmodulesupport from a user-level security context?
Implementation
TODO:
- Determine all the cases we need to support
- Take from test files to build out requirements
- Use
loadsamoduleas the base - Build out test cases based on v0.7.0 tests
- Release v1.0.0
Things to fix:
- All Foundation stories and storybooks are unavailable
- Seems like despite loadmodule being enabled it still isn't being used to load things
- Or there's something else going on. I feel like I've been here before
Investigations
Flipbook might be hitting the RobloxScript error because it might need to be an Asset plugin. That might be the core difference between Flipbook and Developer Storybook
Storyteller DataModel Querying
Looks like Storyteller's query is throwing a fit with the new loading strategy. Probably because each Clone is triggering it. Uh oh. I could probably patch this by batching when changes instances are processed
Maybe I need to take another look at query to see about slowing it down. This is the same problem as SceneUnderstanding. We need to sensibly parse the entire DataModel for the instances we care about.
Things to try:
- Budgeting work per frame
- Defer before processing as a means of batching 2. One example: Instance parented to DM, then a bunch of properties get changed. This would trigger an update for each occurrence. 3. With deferral we could wait some number of frames before processing, allowing instances to “settle” and be processed in one go. Sacrifices some time-to-complete so as not to harm FPS. And this time will likely be imperceptible to the user
- Add stress tests to make sure
querycan handle some crazy edge cases (like cloning) - [Stretch] Keep track of “hot” instances, where if an instance is receiving a bunch of changes to it we could start backing off for that instance, deferring it for processing later
I also want to bang out a flowchart for all the behavior so I can better track the work loop.