fix: Make the makeResolvable $internal marker writable - #2799
Open
reczkok wants to merge 1 commit into
Open
Conversation
makeResolvable $internal marker writable
There was a problem hiding this comment.
Pull request overview
Fixes a React Native (Metro/Babel) module-load crash by ensuring the $internal symbol marker added by makeResolvable does not become a non-writable inherited property that blocks instance assignments.
Changes:
- Marks the
$internalsymbol property aswritable: truewhen defined viaObject.definePropertyinmakeResolvable.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
pkg.pr.new packages benchmark commit |
Contributor
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
packages/typegpu/src/tgsl/makeResolvable.ts: addedwritable: trueto the$internalmarker descriptor so that class constructors can assign instance-specific$internaldata without hitting a read-only prototype property on Babel/Metro (React Native) transpilations.
Kimi K2 (free via Pullfrog for OSS) | 𝕏
Bundle size comparison (
|
| 🟢 Decreased | ➖ Unchanged | 🔴 Increased (max 0.00%) | ❔ Unknown |
|---|---|---|---|
| 0 | 301 | 21 | 0 |
import { ... } in PR vs import * as ... in PR (is the library tree-Shakeable?):
| Test | tsdown |
|---|---|
| tgpu_init.ts | 260.45 kB ( |
| tgpu_initFromDevice.ts | 259.92 kB ( |
| tgpu_resolve.ts | 166.90 kB ( |
| tgpu_resolveWithContext.ts | 166.83 kB ( |
| tgpu_bindGroupLayout.ts | 71.53 kB ( |
| tgpu_mutableAccessor.ts | 67.92 kB ( |
| tgpu_accessor.ts | 67.92 kB ( |
| tgpu_privateVar.ts | 66.66 kB ( |
| tgpu_workgroupVar.ts | 66.66 kB ( |
| tgpu_const.ts | 66.14 kB ( |
| tgpu_lazy.ts | 66.02 kB ( |
| tgpu_fn.ts | 38.45 kB ( |
| tgpu_fragmentFn.ts | 38.45 kB ( |
| tgpu_vertexFn.ts | 38.27 kB ( |
| tgpu_computeFn.ts | 37.97 kB ( |
| tgpu_vertexLayout.ts | 27.08 kB ( |
| tgpu_comptime.ts | 14.77 kB ( |
| tgpu_unroll.ts | 1.66 kB ( |
| tgpu_slot.ts | 1.54 kB ( |
If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu.
Resolution Time Benchmark---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Random Branching (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.96, 1.97, 4.01, 6.75, 8.01, 12.90, 22.95, 25.11]
line [1.02, 2.01, 3.89, 6.65, 7.85, 10.97, 21.32, 25.52]
line [0.97, 2.02, 4.56, 6.88, 8.05, 11.84, 22.05, 24.59]
---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Linear Recursion (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.33, 0.55, 0.72, 0.79, 1.08, 1.15, 1.36, 1.60]
line [0.30, 0.50, 0.68, 0.79, 1.06, 1.17, 1.43, 1.55]
line [0.28, 0.50, 0.70, 0.89, 1.15, 1.22, 1.46, 1.66]
---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Full Tree (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.80, 2.05, 3.51, 7.22, 12.66, 25.19, 55.46, 110.73]
line [0.78, 2.01, 3.87, 6.50, 11.92, 24.95, 56.08, 110.40]
line [0.91, 2.24, 4.62, 6.31, 12.49, 25.96, 57.01, 113.44]
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Running current main on React Native crashes at module load with
TypeError: Cannot assign to read-only property Symbol(typegpu:$internal)the moment anything creates a bind group layout.makeResolvablemarks class prototypes withObject.defineProperty(proto, $internal, { value: true })-writabledefaults to false. Classes likeTgpuLaidOutBufferImpldeclare the field and assign it in the constructor:Whether that assignment survives depends on who compiles it. Vitest (oxc) keeps the field declaration as a native class field:
Babel (Metro) strips the uninitialized field entirely: