Skip to content

feat: Private property access#2594

Draft
aleksanderkatan wants to merge 13 commits into
feat/expand-property-access-in-externalsfrom
feat/private-property-access
Draft

feat: Private property access#2594
aleksanderkatan wants to merge 13 commits into
feat/expand-property-access-in-externalsfrom
feat/private-property-access

Conversation

@aleksanderkatan

@aleksanderkatan aleksanderkatan commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Blocked by #2425

Only the case with both "#prop" and #prop present breaks.

  it('...', () => {
    const cls = new (class {
      '#const' = tgpu.const(d.u32, 0);
      #const = tgpu.const(d.u32, 1);

      fn = () => {
        'use gpu';
        const a = this['#const'].$;
        const b = this.#const.$;
      };
    })();

    expect(tgpu.resolve([cls.fn])).toMatchInlineSnapshot(`
      "const item: u32 = 0u;

      fn fn_1() {
        const a = item;
        const b = item;
      }"
    `);
  });

@aleksanderkatan aleksanderkatan changed the base branch from main to feat/expand-property-access-in-externals June 9, 2026 08:39
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

pkg.pr.new

packages
Ready to be installed by your favorite package manager ⬇️

https://pkg.pr.new/software-mansion/TypeGPU/typegpu@f09b819841172d4b655841cdae9a86ac7a847445
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/cli@f09b819841172d4b655841cdae9a86ac7a847445
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/noise@f09b819841172d4b655841cdae9a86ac7a847445
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/react@f09b819841172d4b655841cdae9a86ac7a847445
https://pkg.pr.new/software-mansion/TypeGPU/unplugin-typegpu@f09b819841172d4b655841cdae9a86ac7a847445

benchmark
view benchmark

commit
view commit

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

Bundle size comparison (import * as ... in PR vs import * as ... in target):

🟢 Decreased ➖ Unchanged 🔴 Increased ❔ Unknown
0 320 0 0

import { ... } in PR vs import * as ... in PR (is the library tree-Shakeable?):

Click to reveal the results table (297 entries).
Test tsdown
d_Void.ts 87.65 kB ($${\color{red}+12128.5\%}$$)
d_sampler.ts 87.66 kB ($${\color{red}+11997.0\%}$$)
d_isPtr.ts 87.65 kB ($${\color{red}+11835.9\%}$$)
d_comparisonSampler.ts 87.67 kB ($${\color{red}+11821.6\%}$$)
d_isSizeAttrib.ts 87.66 kB ($${\color{red}+11805.2\%}$$)
d_isWgslArray.ts 87.66 kB ($${\color{red}+11805.0\%}$$)
d_isAlignAttrib.ts 87.66 kB ($${\color{red}+11789.5\%}$$)
d_isWgslStruct.ts 87.66 kB ($${\color{red}+11789.4\%}$$)
d_isAtomic.ts 87.66 kB ($${\color{red}+11788.9\%}$$)
d_isBuiltinAttrib.ts 87.66 kB ($${\color{red}+11758.4\%}$$)
d_isLocationAttrib.ts 87.67 kB ($${\color{red}+11742.9\%}$$)
d_isDecorated.ts 87.66 kB ($${\color{red}+11742.2\%}$$)
d_isInterpolateAttrib.ts 87.67 kB ($${\color{red}+11696.6\%}$$)
d_atomic.ts 87.66 kB ($${\color{red}+11422.3\%}$$)
d_ptrHandle.ts 87.66 kB ($${\color{red}+10447.8\%}$$)
d_ptrUniform.ts 87.66 kB ($${\color{red}+10435.6\%}$$)
d_ptrStorage.ts 87.66 kB ($${\color{red}+10386.3\%}$$)
d_ptrPrivate.ts 87.66 kB ($${\color{red}+10361.9\%}$$)
d_ptrFn.ts 87.65 kB ($${\color{red}+10349.1\%}$$)
d_ptrWorkgroup.ts 87.66 kB ($${\color{red}+10337.8\%}$$)
d_textureExternal.ts 87.66 kB ($${\color{red}+10182.7\%}$$)
d_textureStorage1d.ts 87.67 kB ($${\color{red}+8556.6\%}$$)
d_textureStorage2d.ts 87.67 kB ($${\color{red}+8556.6\%}$$)
d_textureStorage3d.ts 87.67 kB ($${\color{red}+8556.6\%}$$)
d_textureStorage2dArray.ts 87.67 kB ($${\color{red}+8409.4\%}$$)
d_isDisarray.ts 87.66 kB ($${\color{red}+7780.9\%}$$)
d_isUnstruct.ts 87.66 kB ($${\color{red}+7780.9\%}$$)
d_isLooseDecorated.ts 87.67 kB ($${\color{red}+7733.2\%}$$)
d_isLooseData.ts 87.66 kB ($${\color{red}+7468.6\%}$$)
d_isWgslData.ts 87.66 kB ($${\color{red}+6588.7\%}$$)
d_unstruct.ts 87.66 kB ($${\color{red}+5563.2\%}$$)
d_isData.ts 87.66 kB ($${\color{red}+4749.2\%}$$)
d_deepEqual.ts 87.66 kB ($${\color{red}+3898.3\%}$$)
d_struct.ts 87.66 kB ($${\color{red}+2331.8\%}$$)
d_ref.ts 87.65 kB ($${\color{red}+1730.6\%}$$)
std_discard.ts 105.47 kB ($${\color{red}+637.5\%}$$)
std_isBeingTranspiled.ts 105.48 kB ($${\color{red}+626.9\%}$$)
std_copy.ts 105.47 kB ($${\color{red}+625.2\%}$$)
std_arrayLength.ts 105.48 kB ($${\color{red}+625.0\%}$$)
std_getTargetShaderLanguage.ts 105.49 kB ($${\color{red}+623.7\%}$$)
std_extensionEnabled.ts 105.48 kB ($${\color{red}+621.1\%}$$)
std_range.ts 105.47 kB ($${\color{red}+608.1\%}$$)
std_dpdx.ts 105.47 kB ($${\color{red}+591.1\%}$$)
std_fwidthCoarse.ts 105.48 kB ($${\color{red}+590.9\%}$$)
std_dpdxCoarse.ts 105.47 kB ($${\color{red}+590.8\%}$$)
std_dpdyCoarse.ts 105.47 kB ($${\color{red}+590.8\%}$$)
std_fwidthFine.ts 105.47 kB ($${\color{red}+590.8\%}$$)
std_dpdxFine.ts 105.47 kB ($${\color{red}+590.8\%}$$)
std_dpdyFine.ts 105.47 kB ($${\color{red}+590.8\%}$$)
std_fwidth.ts 105.47 kB ($${\color{red}+590.8\%}$$)
std_dpdy.ts 105.47 kB ($${\color{red}+590.8\%}$$)
d_bool.ts 87.65 kB ($${\color{red}+573.3\%}$$)
d_f16.ts 87.65 kB ($${\color{red}+573.3\%}$$)
d_f32.ts 87.65 kB ($${\color{red}+573.3\%}$$)
d_i32.ts 87.65 kB ($${\color{red}+573.3\%}$$)
d_u32.ts 87.65 kB ($${\color{red}+573.3\%}$$)
d_u16.ts 87.65 kB ($${\color{red}+572.1\%}$$)
std_atomicLoad.ts 105.47 kB ($${\color{red}+556.7\%}$$)
std_textureBarrier.ts 105.48 kB ($${\color{red}+556.4\%}$$)
std_atomicStore.ts 105.48 kB ($${\color{red}+556.4\%}$$)
std_workgroupBarrier.ts 105.48 kB ($${\color{red}+556.2\%}$$)
std_storageBarrier.ts 105.48 kB ($${\color{red}+556.2\%}$$)
std_atomicAdd.ts 105.47 kB ($${\color{red}+556.2\%}$$)
std_atomicAnd.ts 105.47 kB ($${\color{red}+556.2\%}$$)
std_atomicMax.ts 105.47 kB ($${\color{red}+556.2\%}$$)
std_atomicMin.ts 105.47 kB ($${\color{red}+556.2\%}$$)
std_atomicSub.ts 105.47 kB ($${\color{red}+556.2\%}$$)
std_atomicXor.ts 105.47 kB ($${\color{red}+556.2\%}$$)
std_atomicOr.ts 105.47 kB ($${\color{red}+556.2\%}$$)
d_textureDepth2d.ts 87.66 kB ($${\color{red}+551.2\%}$$)
d_textureDepthCube.ts 87.67 kB ($${\color{red}+550.9\%}$$)
d_texture1d.ts 87.66 kB ($${\color{red}+550.6\%}$$)
d_texture2d.ts 87.66 kB ($${\color{red}+550.6\%}$$)
d_texture3d.ts 87.66 kB ($${\color{red}+550.6\%}$$)
d_textureDepth2dArray.ts 87.67 kB ($${\color{red}+550.4\%}$$)
d_textureCube.ts 87.66 kB ($${\color{red}+550.4\%}$$)
d_textureDepthCubeArray.ts 87.67 kB ($${\color{red}+550.1\%}$$)
d_textureDepthMultisampled2d.ts 87.67 kB ($${\color{red}+550.1\%}$$)
d_texture2dArray.ts 87.66 kB ($${\color{red}+549.8\%}$$)
d_textureCubeArray.ts 87.67 kB ($${\color{red}+549.6\%}$$)
d_textureMultisampled2d.ts 87.67 kB ($${\color{red}+549.5\%}$$)
d_disarrayOf.ts 87.66 kB ($${\color{red}+482.0\%}$$)
d_vec2b.ts 87.65 kB ($${\color{red}+350.7\%}$$)
d_vec2f.ts 87.65 kB ($${\color{red}+350.7\%}$$)
d_vec2h.ts 87.65 kB ($${\color{red}+350.7\%}$$)
d_vec2i.ts 87.65 kB ($${\color{red}+350.7\%}$$)
d_vec2u.ts 87.65 kB ($${\color{red}+350.7\%}$$)
d_vec3b.ts 87.65 kB ($${\color{red}+350.7\%}$$)
d_vec3f.ts 87.65 kB ($${\color{red}+350.7\%}$$)
d_vec3h.ts 87.65 kB ($${\color{red}+350.7\%}$$)
d_vec3i.ts 87.65 kB ($${\color{red}+350.7\%}$$)
d_vec3u.ts 87.65 kB ($${\color{red}+350.7\%}$$)
d_vec4b.ts 87.65 kB ($${\color{red}+350.7\%}$$)
d_vec4f.ts 87.65 kB ($${\color{red}+350.7\%}$$)
d_vec4h.ts 87.65 kB ($${\color{red}+350.7\%}$$)
d_vec4i.ts 87.65 kB ($${\color{red}+350.7\%}$$)
d_vec4u.ts 87.65 kB ($${\color{red}+350.7\%}$$)
std_subgroupAdd.ts 105.48 kB ($${\color{red}+332.5\%}$$)
std_subgroupBroadcastFirst.ts 105.49 kB ($${\color{red}+332.4\%}$$)
std_subgroupExclusiveAdd.ts 105.48 kB ($${\color{red}+332.4\%}$$)
std_subgroupExclusiveMul.ts 105.48 kB ($${\color{red}+332.4\%}$$)
std_subgroupInclusiveAdd.ts 105.48 kB ($${\color{red}+332.4\%}$$)
std_subgroupInclusiveMul.ts 105.48 kB ($${\color{red}+332.4\%}$$)
std_subgroupShuffleDown.ts 105.48 kB ($${\color{red}+332.4\%}$$)
std_subgroupShuffleXor.ts 105.48 kB ($${\color{red}+332.4\%}$$)
std_subgroupBroadcast.ts 105.48 kB ($${\color{red}+332.4\%}$$)
std_subgroupShuffleUp.ts 105.48 kB ($${\color{red}+332.4\%}$$)
std_subgroupShuffle.ts 105.48 kB ($${\color{red}+332.4\%}$$)
std_subgroupBallot.ts 105.48 kB ($${\color{red}+332.4\%}$$)
std_subgroupElect.ts 105.48 kB ($${\color{red}+332.4\%}$$)
std_subgroupAll.ts 105.48 kB ($${\color{red}+332.4\%}$$)
std_subgroupAnd.ts 105.48 kB ($${\color{red}+332.4\%}$$)
std_subgroupAny.ts 105.48 kB ($${\color{red}+332.4\%}$$)
std_subgroupMax.ts 105.48 kB ($${\color{red}+332.4\%}$$)
std_subgroupMin.ts 105.48 kB ($${\color{red}+332.4\%}$$)
std_subgroupMul.ts 105.48 kB ($${\color{red}+332.4\%}$$)
std_subgroupXor.ts 105.48 kB ($${\color{red}+332.4\%}$$)
std_subgroupOr.ts 105.47 kB ($${\color{red}+332.4\%}$$)
d_formatToWGSLType.ts 87.67 kB ($${\color{red}+318.6\%}$$)
d_uint8.ts 87.65 kB ($${\color{red}+318.5\%}$$)
d_unorm10_10_10_2.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_unorm8x4_bgra.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_float16x2.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_float16x4.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_float32x2.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_float32x3.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_float32x4.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_snorm16x2.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_snorm16x4.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_unorm16x2.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_unorm16x4.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_sint16x2.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_sint16x4.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_sint32x2.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_sint32x3.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_sint32x4.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_snorm8x2.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_snorm8x4.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_uint16x2.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_uint16x4.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_uint32x2.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_uint32x3.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_uint32x4.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_unorm8x2.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_unorm8x4.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_float16.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_float32.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_sint8x2.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_sint8x4.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_snorm16.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_uint8x2.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_uint8x4.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_unorm16.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_sint16.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_sint32.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_snorm8.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_uint16.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_uint32.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_unorm8.ts 87.66 kB ($${\color{red}+318.4\%}$$)
d_sint8.ts 87.65 kB ($${\color{red}+318.4\%}$$)
d_packedFormats.ts 87.66 kB ($${\color{red}+318.1\%}$$)
d_isPackedData.ts 87.66 kB ($${\color{red}+317.2\%}$$)
std_textureDimensions.ts 105.48 kB ($${\color{red}+305.7\%}$$)
std_textureGather.ts 105.48 kB ($${\color{red}+305.7\%}$$)
std_textureSampleBaseClampToEdge.ts 105.49 kB ($${\color{red}+305.7\%}$$)
std_textureSampleCompareLevel.ts 105.49 kB ($${\color{red}+305.7\%}$$)
std_textureSampleCompare.ts 105.48 kB ($${\color{red}+305.6\%}$$)
std_textureSampleLevel.ts 105.48 kB ($${\color{red}+305.6\%}$$)
std_textureSampleBias.ts 105.48 kB ($${\color{red}+305.6\%}$$)
std_textureSampleGrad.ts 105.48 kB ($${\color{red}+305.6\%}$$)
std_textureSample.ts 105.48 kB ($${\color{red}+305.6\%}$$)
std_textureStore.ts 105.48 kB ($${\color{red}+305.6\%}$$)
std_textureLoad.ts 105.48 kB ($${\color{red}+305.6\%}$$)
d_alignmentOf.ts 87.66 kB ($${\color{red}+300.4\%}$$)
std_translation4.ts 105.48 kB ($${\color{red}+288.3\%}$$)
std_rotationX4.ts 105.47 kB ($${\color{red}+288.3\%}$$)
std_rotationY4.ts 105.47 kB ($${\color{red}+288.3\%}$$)
std_rotationZ4.ts 105.47 kB ($${\color{red}+288.3\%}$$)
std_identity2.ts 105.47 kB ($${\color{red}+288.3\%}$$)
std_identity3.ts 105.47 kB ($${\color{red}+288.3\%}$$)
std_identity4.ts 105.47 kB ($${\color{red}+288.3\%}$$)
std_scaling4.ts 105.47 kB ($${\color{red}+288.3\%}$$)
d_isBuiltin.ts 87.66 kB ($${\color{red}+256.1\%}$$)
d_sizeOf.ts 87.66 kB ($${\color{red}+255.4\%}$$)
d_isContiguous.ts 87.66 kB ($${\color{red}+255.3\%}$$)
d_getLongestContiguousPrefix.ts 87.67 kB ($${\color{red}+255.2\%}$$)
d_arrayOf.ts 87.66 kB ($${\color{red}+234.4\%}$$)
d_size.ts 87.65 kB ($${\color{red}+232.6\%}$$)
d_align.ts 87.65 kB ($${\color{red}+232.6\%}$$)
d_location.ts 87.66 kB ($${\color{red}+232.6\%}$$)
d_interpolate.ts 87.66 kB ($${\color{red}+232.5\%}$$)
d_invariant.ts 87.66 kB ($${\color{red}+227.9\%}$$)
d_mat4x4f.ts 87.66 kB ($${\color{red}+222.7\%}$$)
d_mat2x2f.ts 87.66 kB ($${\color{red}+222.7\%}$$)
d_mat3x3f.ts 87.66 kB ($${\color{red}+222.7\%}$$)
d_matToArray.ts 87.66 kB ($${\color{red}+221.2\%}$$)
d_builtin.ts 87.66 kB ($${\color{red}+205.7\%}$$)
std_unpack2x16float.ts 105.48 kB ($${\color{red}+192.2\%}$$)
std_unpack4x8unorm.ts 105.48 kB ($${\color{red}+192.2\%}$$)
std_pack2x16float.ts 105.48 kB ($${\color{red}+192.2\%}$$)
std_pack4x8unorm.ts 105.48 kB ($${\color{red}+192.2\%}$$)
std_bitcastU32toF32.ts 105.48 kB ($${\color{red}+137.6\%}$$)
std_bitcastU32toI32.ts 105.48 kB ($${\color{red}+137.6\%}$$)
std_neg.ts 105.47 kB ($${\color{red}+116.8\%}$$)
std_bitShiftRight.ts 105.48 kB ($${\color{red}+116.8\%}$$)
std_bitShiftLeft.ts 105.48 kB ($${\color{red}+116.8\%}$$)
std_add.ts 105.47 kB ($${\color{red}+116.8\%}$$)
std_div.ts 105.47 kB ($${\color{red}+116.8\%}$$)
std_mod.ts 105.47 kB ($${\color{red}+116.8\%}$$)
std_mul.ts 105.47 kB ($${\color{red}+116.8\%}$$)
std_sub.ts 105.47 kB ($${\color{red}+116.8\%}$$)
std_translate4.ts 105.47 kB ($${\color{red}+113.1\%}$$)
std_rotateX4.ts 105.47 kB ($${\color{red}+113.1\%}$$)
std_scale4.ts 105.47 kB ($${\color{red}+113.1\%}$$)
std_rotateY4.ts 105.47 kB ($${\color{red}+113.1\%}$$)
std_rotateZ4.ts 105.47 kB ($${\color{red}+113.1\%}$$)
d_memoryLayoutOf.ts 87.66 kB ($${\color{red}+108.8\%}$$)
std_and.ts 105.47 kB ($${\color{red}+101.9\%}$$)
std_or.ts 105.47 kB ($${\color{red}+101.9\%}$$)
std_select.ts 105.47 kB ($${\color{red}+101.9\%}$$)
std_allEq.ts 105.47 kB ($${\color{red}+101.9\%}$$)
std_all.ts 105.47 kB ($${\color{red}+101.9\%}$$)
std_not.ts 105.47 kB ($${\color{red}+101.9\%}$$)
std_eq.ts 105.47 kB ($${\color{red}+101.9\%}$$)
std_lt.ts 105.47 kB ($${\color{red}+101.9\%}$$)
std_ne.ts 105.47 kB ($${\color{red}+101.9\%}$$)
std_isCloseTo.ts 105.47 kB ($${\color{red}+101.9\%}$$)
std_any.ts 105.47 kB ($${\color{red}+101.9\%}$$)
std_ge.ts 105.47 kB ($${\color{red}+101.9\%}$$)
std_gt.ts 105.47 kB ($${\color{red}+101.9\%}$$)
std_le.ts 105.47 kB ($${\color{red}+101.9\%}$$)
std_dot4U8Packed.ts 105.48 kB ($${\color{red}+57.0\%}$$)
std_length.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_countTrailingZeros.ts 105.48 kB ($${\color{red}+57.0\%}$$)
std_distance.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_dot.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_countLeadingZeros.ts 105.48 kB ($${\color{red}+57.0\%}$$)
std_firstTrailingBit.ts 105.48 kB ($${\color{red}+57.0\%}$$)
std_firstLeadingBit.ts 105.48 kB ($${\color{red}+57.0\%}$$)
std_fract.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_frexp.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_modf.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_quantizeToF16.ts 105.48 kB ($${\color{red}+57.0\%}$$)
std_mix.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_countOneBits.ts 105.48 kB ($${\color{red}+57.0\%}$$)
std_dot4I8Packed.ts 105.48 kB ($${\color{red}+57.0\%}$$)
std_determinant.ts 105.48 kB ($${\color{red}+57.0\%}$$)
std_extractBits.ts 105.48 kB ($${\color{red}+57.0\%}$$)
std_faceForward.ts 105.48 kB ($${\color{red}+57.0\%}$$)
std_inverseSqrt.ts 105.48 kB ($${\color{red}+57.0\%}$$)
std_reverseBits.ts 105.48 kB ($${\color{red}+57.0\%}$$)
std_insertBits.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_smoothstep.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_normalize.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_transpose.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_saturate.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_degrees.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_radians.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_reflect.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_refract.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_acosh.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_asinh.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_atan2.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_atanh.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_clamp.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_cross.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_floor.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_ldexp.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_round.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_trunc.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_acos.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_asin.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_atan.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_ceil.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_cosh.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_exp2.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_log2.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_sign.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_sinh.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_sqrt.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_step.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_tanh.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_abs.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_cos.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_exp.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_fma.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_log.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_max.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_min.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_pow.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_sin.ts 105.47 kB ($${\color{red}+57.0\%}$$)
std_tan.ts 105.47 kB ($${\color{red}+57.0\%}$$)
common_fullScreenTriangle.ts 57.15 kB ($${\color{red}+41.5\%}$$)
common_writeSoA.ts 57.14 kB ($${\color{red}+38.5\%}$$)
STATIC_allImports.ts 289.38 kB ($${\color{green}-1.7\%}$$)
STATIC_d.ts 87.65 kB ($${\color{green}-2.6\%}$$)
STATIC_std.ts 105.46 kB ($${\color{green}-2.6\%}$$)

If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu.

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

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.97, 1.96, 4.54, 6.77, 8.14, 13.03, 23.92, 25.43]
  line [1.00, 2.07, 4.34, 6.84, 8.65, 14.73, 24.72, 27.06]
  line [0.97, 1.93, 4.13, 6.66, 8.37, 11.18, 24.31, 25.28]
Loading
---
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.31, 0.52, 0.68, 0.85, 1.13, 1.17, 1.44, 1.55]
  line [0.33, 0.56, 0.72, 0.90, 1.22, 1.24, 1.53, 1.66]
  line [0.33, 0.62, 0.77, 0.92, 1.20, 1.28, 1.61, 1.69]
Loading
---
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.99, 2.41, 4.14, 6.98, 12.34, 26.43, 58.00, 118.34]
  line [0.85, 2.17, 3.89, 7.00, 12.85, 28.32, 60.01, 120.44]
  line [1.00, 2.16, 4.36, 6.91, 13.99, 27.46, 59.58, 123.47]
Loading

@aleksanderkatan aleksanderkatan linked an issue Jun 9, 2026 that may be closed by this pull request

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support across the TypeGPU toolchain (parser → unplugin metadata → runtime resolution → linting) for accessing class private fields (e.g. this.#prop) from 'use gpu' functions, and updates tests to cover the new syntax.

Changes:

  • Teach tinyest-for-wgsl to parse/transpile private identifiers and include them in external-name extraction.
  • Update unplugin-typegpu externals serialization + auto-naming to handle class private properties and #... keys.
  • Relax ESLint rule coverage to allow private identifiers in 'use gpu' functions and add related tests.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/unplugin-typegpu/test/nested-externals.test.ts Adds regression tests ensuring externals gathering supports this.#prop for Babel/Rollup transforms.
packages/unplugin-typegpu/test/auto-naming.test.ts Adds auto-naming coverage for class private fields (named + anonymous classes) in Babel/Rollup transforms.
packages/unplugin-typegpu/src/core/factory.ts Quotes #... externals keys when generating metadata code strings.
packages/unplugin-typegpu/src/core/common.ts Enables auto-naming for ClassPrivateProperty and adds requiresQuotation() helper.
packages/unplugin-typegpu/src/babel.ts Quotes #... externals keys when generating Babel AST metadata nodes.
packages/typegpu/tests/externalPropAccess.test.ts Adds runtime resolution tests for private property access and '#'-containing property names.
packages/tinyest-for-wgsl/tests/parsers.test.ts Adds parser test asserting this.#v becomes an external name under "this"."#v".
packages/tinyest-for-wgsl/src/parsers.ts Adds transpilers for PrivateName / PrivateIdentifier.
packages/tinyest-for-wgsl/src/externals.ts Extends prop-access chain extraction to include private member names.
packages/eslint-plugin/tests/rules/noUnsupportedSyntax.test.ts Updates rule tests to treat private identifiers as valid in 'use gpu' scope.
packages/eslint-plugin/src/rules/noUnsupportedSyntax.ts Stops reporting PrivateIdentifier as unsupported syntax inside 'use gpu'.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/unplugin-typegpu/src/babel.ts Outdated
Comment thread packages/unplugin-typegpu/src/core/factory.ts Outdated
Comment thread packages/eslint-plugin/tests/rules/noUnsupportedSyntax.test.ts
Comment thread packages/typegpu/tests/externalPropAccess.test.ts
@aleksanderkatan aleksanderkatan marked this pull request as ready for review June 9, 2026 10:59
@aleksanderkatan aleksanderkatan marked this pull request as draft June 10, 2026 13:57
@aleksanderkatan

Copy link
Copy Markdown
Contributor Author

@pullfrog review

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The Rollup externals test isn't actually testing the Rollup path, and the combined public/private #prop case silently resolves the wrong resource. Both need addressing before merge.

Reviewed changes — this PR enables JavaScript private class properties as TypeGPU externals, adds auto-naming for ClassPrivateProperty, and removes the lint rule that unconditionally banned private identifiers.

  • Lift the blanket PrivateIdentifier lint ban in packages/eslint-plugin/src/rules/noUnsupportedSyntax.ts so this.#prop access is allowed.
  • Track #prop chains in packages/tinyest-for-wgsl/src/externals.ts by handling both Babel PrivateName and acorn PrivateIdentifier.
  • Auto-name private class fields in packages/unplugin-typegpu/src/core/common.ts via a new ClassPrivateProperty visitor and matching extractLabelledExpression branch.
  • Add test coverage for private property access across tinyest-for-wgsl, typegpu, and unplugin-typegpu.

Collision between private #prop and string-key "#prop"

A class that defines both a public '#prop' and a private #prop currently routes both this['#prop'].$ and this.#prop.$ through the same this.#prop external key. The runtime object-based external replacement then resolves the public property value, so the private field value is silently dropped. This matches the limitation noted in the PR body; please either fix the key encoding or add a tracking issue/TODO so the limitation is visible to users and future maintainers.

Technical details
# Collision between private `#prop` and string-key `"#prop"`

## Affected sites
- packages/tinyest-for-wgsl/src/externals.ts:32-35 — private names are encoded as `this.#prop`, identical to the runtime object-property replacement path used for `this["#prop"]`.
- packages/typegpu/src/core/resolve/externals.ts:104-129 — object external replacement uses `externalName\\.(?<prop>...)` and matches `this.#prop` for `this` externals.

## Required outcome
- `this.#prop` (private field) and `this["#prop"]` (public string key) resolve to distinct resources when both are present.

## Suggested approach
Consider encoding private names with a distinct prefix or namespace (e.g., `this.private.#prop`) and teaching the resolver to map that prefix back to the private-field accessor. Alternatively, document the limitation and add a failing/todo test linking to an issue.

## Open questions for the human
- Is the combined case expected to be fixed in this PR, or is there a follow-up issue already planned? Please link it in a code comment so the next agent doesn't re-discover it.

Pullfrog  | Fix all ➔Fix 👍s ➔View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

});

it('works for ROLLUP', async () => {
expect(extractExternals(babelTransform(code))).toMatchInlineSnapshot(`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ROLLUP test calls babelTransform, so it doesn't exercise the Rollup plugin path and the inline snapshot only reflects Babel's formatting. Use await rollupTransform(code) here and update the snapshot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Support private property access in TypeGPU functions

2 participants