Fix transformer test failures by improving Roblox static constructor detection #7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes 4 failing tests in the transformer's block analyzer that were incorrectly classifying static Roblox constructor calls as dynamic expressions.
Problem
The transformer's block analyzer was failing to properly detect common Roblox constructors like
UDim2.new(),Vector2.new(), andColor3.fromRGB()as static expressions. This caused several issues:dynamicPropsinstead ofstaticPropsConsider this JSX element that should be completely static:
The analyzer was incorrectly treating the
SizeandPositionprops as dynamic because it didn't recognizeUDim2.newandUDim2.fromScaleas static Roblox methods.Solution
Added a comprehensive fallback system for detecting static Roblox constructors and methods:
KNOWN_STATIC_ROBLOX_METHODSmapping for common Roblox types (UDim2, Vector2, Vector3, Color3, CFrame, etc.) and their static methodsisStaticRobloxCall()andisStaticRobloxNew()that first try the official static detector, then fall back to the known methods listTesting
All 59 tests now pass, including the 4 previously failing analyzer tests:
should identify static elements correctlyshould handle mixed static and dynamic propsshould not extract dependencies from static Roblox constructorsshould not recommend memoization for static componentsThe build also completes successfully with no compilation errors.
This fix ensures that the Million.js-style block memoization system correctly identifies static Roblox UI elements, leading to better optimization opportunities and more accurate dependency tracking.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.