Skip to content

feat: Expand property access in externals#2425

Draft
aleksanderkatan wants to merge 22 commits into
mainfrom
feat/expand-property-access-in-externals
Draft

feat: Expand property access in externals#2425
aleksanderkatan wants to merge 22 commits into
mainfrom
feat/expand-property-access-in-externals

Conversation

@aleksanderkatan

@aleksanderkatan aleksanderkatan commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

tinyest-for-wgsl now collects "expanded" externals (before, it would return ["ext"]):

const { externalNames } = transpileFn(
  p(`() => {
    const a = ext.p;
    const b = ext.q.a;
    const c = ext.q.b;

    const d = ext.r.a;
    const e = ext.r;

    const f = ext.s;
    const g = ext.s.a;

    const h = ext.t.fn().x;
    const i = ext.t.comp['computed'].x;

    const j = (ext).u;
  }`),
);

expect(externalNames).toMatchInlineSnapshot(`
  {
    "ext": {
      "p": "ext.p",
      "q": {
        "a": "ext.q.a",
        "b": "ext.q.b",
      },
      "r": "ext.r",
      "s": "ext.s",
      "t": {
        "comp": "ext.t.comp",
        "fn": "ext.t.fn",
      },
      "u": "ext.u",
    },
  }
`);

Unplugin then assigns new externals variant:

const code = `\
  const ext = {
    value: 7,
    config: {
      multiplier: 1,
      zero: 0,
    }
  };
  const fn = () => {
    'use gpu';
    const a = ext.value;
    const b = ext.config.multiplier;
    const c = ext.config.zero;
    const d = ext.config.multiplier;
  };
  console.log(fn);`;

expect(extractExternals(babelTransform(code))).toMatchInlineSnapshot(`
  "{
      ext: {
        value: () => ext.value,
        config: {
          multiplier: () => ext.config.multiplier,
          zero: () => ext.config.zero
        }
      }
    }"
`);

Finally, fnCore.ts replaces the thunks with getters (this change was introduced in #2502), so that we don't needlessly complicate prop access.

Unfortunately, we lost the ability to autoname some of the externals:

const buf = /* op that returns a buffer without autonaming it */ (() => root.createUniform(d.u32))();

const fn = () {
  'use gpu';
  let a = buf.$;
}

before, buf would be in externals and would be autonamed. Now, the buf in externals is a fake: { 'buf': { '$': () => buf.$ } }, therefore it won't be named.

@aleksanderkatan aleksanderkatan linked an issue Apr 29, 2026 that may be closed by this pull request
@github-actions

github-actions Bot commented Apr 29, 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@d3bdf1733858b8374bc9cc615082656f1dfe6565
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/cli@d3bdf1733858b8374bc9cc615082656f1dfe6565
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/noise@d3bdf1733858b8374bc9cc615082656f1dfe6565
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/react@d3bdf1733858b8374bc9cc615082656f1dfe6565
https://pkg.pr.new/software-mansion/TypeGPU/unplugin-typegpu@d3bdf1733858b8374bc9cc615082656f1dfe6565

benchmark
view benchmark

commit
view commit

@github-actions

github-actions Bot commented Apr 29, 2026

Copy link
Copy Markdown

📊 Bundle Size Comparison

🟢 Decreased ➖ Unchanged 🔴 Increased ❔ Unknown
1 355 0 0

👀 Notable results

Static test results:

Test tsdown
functionWithUseGpu.ts 276 B ($${\color{green}-2.1\%}$$)

Dynamic test results:

No major changes.

📋 All results

Click to reveal the results table (355 entries).
Test tsdown
functionWithUseGpu.ts 276 B ($${\color{green}-2.1\%}$$)
dataImportEverything.ts 88.14 kB (➖)
dataImportOneDirect.ts 23.28 kB (➖)
dataImportOneStar.ts 23.28 kB (➖)
functionWithoutUseGpu.ts 24 B (➖)
importEntireLibrary.ts 287.23 kB (➖)
stdImportEverything.ts 104.29 kB (➖)
stdImportOneDirect.ts 46.93 kB (➖)
stdImportOneStar.ts 46.93 kB (➖)
tgpuImportEverything.ts 259.37 kB (➖)
tgpuImportOne.ts 259.38 kB (➖)
MissingBindGroupsError from typegpu.ts 1.35 kB (➖)
MissingSlotValueError from typegpu.ts 151 B (➖)
MissingVertexBuffersError from typegpu.ts 1.36 kB (➖)
NotUniformError from typegpu.ts 1.31 kB (➖)
ResolutionError from typegpu.ts 2.33 kB (➖)
ShaderGenerator from typegpu.ts 1.66 kB (➖)
Void from typegpudata.ts 734 B (➖)
WgslGenerator from typegpu.ts 112.92 kB (➖)
abs from typegpustd.ts 64.37 kB (➖)
acos from typegpustd.ts 64.37 kB (➖)
acosh from typegpustd.ts 64.37 kB (➖)
add from typegpustd.ts 46.92 kB (➖)
align from typegpudata.ts 24.97 kB (➖)
alignmentOf from typegpudata.ts 20.51 kB (➖)
allEq from typegpustd.ts 50.30 kB (➖)
all from typegpustd.ts 50.30 kB (➖)
and from typegpustd.ts 50.29 kB (➖)
any from typegpustd.ts 50.30 kB (➖)
arrayLength from typegpustd.ts 13.00 kB (➖)
arrayOf from typegpudata.ts 24.83 kB (➖)
asin from typegpustd.ts 64.37 kB (➖)
asinh from typegpustd.ts 64.37 kB (➖)
atan2 from typegpustd.ts 64.37 kB (➖)
atan from typegpustd.ts 64.37 kB (➖)
atanh from typegpustd.ts 64.37 kB (➖)
atomicAdd from typegpustd.ts 14.37 kB (➖)
atomicAnd from typegpustd.ts 14.37 kB (➖)
atomicLoad from typegpustd.ts 14.36 kB (➖)
atomicMax from typegpustd.ts 14.37 kB (➖)
atomicMin from typegpustd.ts 14.37 kB (➖)
atomicOr from typegpustd.ts 14.37 kB (➖)
atomicStore from typegpustd.ts 14.36 kB (➖)
atomicSub from typegpustd.ts 14.37 kB (➖)
atomicXor from typegpustd.ts 14.37 kB (➖)
atomic from typegpudata.ts 779 B (➖)
bitShiftLeft from typegpustd.ts 46.92 kB (➖)
bitShiftRight from typegpustd.ts 46.92 kB (➖)
bitcastU32toF32 from typegpustd.ts 42.75 kB (➖)
bitcastU32toI32 from typegpustd.ts 42.75 kB (➖)
bool from typegpudata.ts 11.54 kB (➖)
builtin from typegpudata.ts 27.29 kB (➖)
ceil from typegpustd.ts 64.37 kB (➖)
clamp from typegpustd.ts 64.37 kB (➖)
common from typegpu.ts 57.09 kB (➖)
comparisonSampler from typegpudata.ts 753 B (➖)
copy from typegpustd.ts 13 kB (➖)
cos from typegpustd.ts 64.37 kB (➖)
cosh from typegpustd.ts 64.37 kB (➖)
countLeadingZeros from typegpustd.ts 64.37 kB (➖)
countOneBits from typegpustd.ts 64.37 kB (➖)
countTrailingZeros from typegpustd.ts 64.37 kB (➖)
cross from typegpustd.ts 64.37 kB (➖)
d from typegpu.ts 85.82 kB (➖)
deepEqual from typegpudata.ts 2.19 kB (➖)
degrees from typegpustd.ts 64.37 kB (➖)
determinant from typegpustd.ts 64.37 kB (➖)
disarrayOf from typegpudata.ts 13.59 kB (➖)
discard from typegpustd.ts 12.76 kB (➖)
distance from typegpustd.ts 64.37 kB (➖)
div from typegpustd.ts 46.92 kB (➖)
dot4I8Packed from typegpustd.ts 64.37 kB (➖)
dot4U8Packed from typegpustd.ts 64.37 kB (➖)
dot from typegpustd.ts 64.37 kB (➖)
dpdxCoarse from typegpustd.ts 13.61 kB (➖)
dpdxFine from typegpustd.ts 13.61 kB (➖)
dpdx from typegpustd.ts 13.60 kB (➖)
dpdyCoarse from typegpustd.ts 13.61 kB (➖)
dpdyFine from typegpustd.ts 13.61 kB (➖)
dpdy from typegpustd.ts 13.61 kB (➖)
eq from typegpustd.ts 50.30 kB (➖)
exp2 from typegpustd.ts 64.37 kB (➖)
exp from typegpustd.ts 64.37 kB (➖)
extensionEnabled from typegpustd.ts 13.15 kB (➖)
extractBits from typegpustd.ts 64.37 kB (➖)
f16 from typegpudata.ts 11.54 kB (➖)
f32 from typegpudata.ts 11.54 kB (➖)
faceForward from typegpustd.ts 64.37 kB (➖)
firstLeadingBit from typegpustd.ts 64.37 kB (➖)
firstTrailingBit from typegpustd.ts 64.37 kB (➖)
float16 from typegpudata.ts 19.47 kB (➖)
float16x2 from typegpudata.ts 19.47 kB (➖)
float16x4 from typegpudata.ts 19.47 kB (➖)
float32 from typegpudata.ts 19.47 kB (➖)
float32x2 from typegpudata.ts 19.47 kB (➖)
float32x3 from typegpudata.ts 19.47 kB (➖)
float32x4 from typegpudata.ts 19.47 kB (➖)
floor from typegpustd.ts 64.37 kB (➖)
fma from typegpustd.ts 64.37 kB (➖)
formatToWGSLType from typegpudata.ts 19.46 kB (➖)
fract from typegpustd.ts 64.37 kB (➖)
frexp from typegpustd.ts 64.37 kB (➖)
fwidthCoarse from typegpustd.ts 13.61 kB (➖)
fwidthFine from typegpustd.ts 13.61 kB (➖)
fwidth from typegpustd.ts 13.61 kB (➖)
ge from typegpustd.ts 50.30 kB (➖)
getLongestContiguousPrefix from typegpudata.ts 23.30 kB (➖)
getTargetShaderLanguage from typegpustd.ts 13.10 kB (➖)
gt from typegpustd.ts 50.30 kB (➖)
i32 from typegpudata.ts 11.54 kB (➖)
identity2 from typegpustd.ts 25.55 kB (➖)
identity3 from typegpustd.ts 25.55 kB (➖)
identity4 from typegpustd.ts 25.55 kB (➖)
insertBits from typegpustd.ts 64.37 kB (➖)
interpolate from typegpudata.ts 24.98 kB (➖)
invariant from typegpudata.ts 25.35 kB (➖)
inverseSqrt from typegpustd.ts 64.37 kB (➖)
isAccessor from typegpu.ts 65 B (➖)
isAlignAttrib from typegpudata.ts 755 B (➖)
isAtomic from typegpudata.ts 755 B (➖)
isBeingTranspiled from typegpustd.ts 13.04 kB (➖)
isBufferShorthand from typegpu.ts 1.71 kB (➖)
isBuffer from typegpu.ts 87.25 kB (➖)
isBuiltinAttrib from typegpudata.ts 757 B (➖)
isBuiltin from typegpudata.ts 23.23 kB (➖)
isCloseTo from typegpustd.ts 50.30 kB (➖)
isComparisonSampler from typegpu.ts 61.70 kB (➖)
isContiguous from typegpudata.ts 23.29 kB (➖)
isData from typegpudata.ts 1.81 kB (➖)
isDecorated from typegpudata.ts 758 B (➖)
isDisarray from typegpudata.ts 1.11 kB (➖)
isInterpolateAttrib from typegpudata.ts 761 B (➖)
isLazy from typegpu.ts 61 B (➖)
isLocationAttrib from typegpudata.ts 758 B (➖)
isLooseData from typegpudata.ts 1.16 kB (➖)
isLooseDecorated from typegpudata.ts 1.12 kB (➖)
isMutableAccessor from typegpu.ts 73 B (➖)
isPackedData from typegpudata.ts 19.53 kB (➖)
isPtr from typegpudata.ts 752 B (➖)
isSampler from typegpu.ts 61.68 kB (➖)
isSizeAttrib from typegpudata.ts 754 B (➖)
isSlot from typegpu.ts 61 B (➖)
isTexture from typegpu.ts 61.68 kB (➖)
isTgpuComputeFn from typegpu.ts 69 B (➖)
isTgpuFn from typegpu.ts 765 B (➖)
isTgpuFragmentFn from typegpu.ts 70 B (➖)
isTgpuVertexFn from typegpu.ts 68 B (➖)
isUnstruct from typegpudata.ts 1.11 kB (➖)
isUsableAsRender from typegpu.ts 55 B (➖)
isUsableAsSampled from typegpu.ts 56 B (➖)
isUsableAsStorage from typegpu.ts 56 B (➖)
isUsableAsUniform from typegpu.ts 61.67 kB (➖)
isUsableAsVertex from typegpu.ts 87.24 kB (➖)
isVariable from typegpu.ts 63.39 kB (➖)
isWgslArray from typegpudata.ts 754 B (➖)
isWgslData from typegpudata.ts 1.31 kB (➖)
isWgslStruct from typegpudata.ts 755 B (➖)
ldexp from typegpustd.ts 64.37 kB (➖)
le from typegpustd.ts 50.30 kB (➖)
length from typegpustd.ts 64.37 kB (➖)
location from typegpudata.ts 24.97 kB (➖)
log2 from typegpustd.ts 64.37 kB (➖)
log from typegpustd.ts 64.37 kB (➖)
lt from typegpustd.ts 50.30 kB (➖)
mat2x2f from typegpudata.ts 25.55 kB (➖)
mat3x3f from typegpudata.ts 25.55 kB (➖)
mat4x4f from typegpudata.ts 25.55 kB (➖)
matToArray from typegpudata.ts 25.68 kB (➖)
max from typegpustd.ts 64.37 kB (➖)
memoryLayoutOf from typegpudata.ts 40.60 kB (➖)
min from typegpustd.ts 64.37 kB (➖)
mix from typegpustd.ts 64.37 kB (➖)
mod from typegpustd.ts 46.92 kB (➖)
modf from typegpustd.ts 64.37 kB (➖)
mul from typegpustd.ts 46.92 kB (➖)
ne from typegpustd.ts 50.30 kB (➖)
neg from typegpustd.ts 46.92 kB (➖)
normalize from typegpustd.ts 64.37 kB (➖)
not from typegpustd.ts 50.30 kB (➖)
or from typegpustd.ts 50.29 kB (➖)
pack2x16float from typegpustd.ts 34.51 kB (➖)
pack4x8unorm from typegpustd.ts 34.51 kB (➖)
packedFormats from typegpudata.ts 19.49 kB (➖)
patchArrayBuffer from typegpu.ts 49.75 kB (➖)
pow from typegpustd.ts 64.37 kB (➖)
ptrFn from typegpudata.ts 859 B (➖)
ptrHandle from typegpudata.ts 851 B (➖)
ptrPrivate from typegpudata.ts 858 B (➖)
ptrStorage from typegpudata.ts 856 B (➖)
ptrUniform from typegpudata.ts 852 B (➖)
ptrWorkgroup from typegpudata.ts 860 B (➖)
quantizeToF16 from typegpustd.ts 64.37 kB (➖)
radians from typegpustd.ts 64.37 kB (➖)
range from typegpustd.ts 13.42 kB (➖)
readFromArrayBuffer from typegpu.ts 50.34 kB (➖)
ref from typegpudata.ts 4.79 kB (➖)
reflect from typegpustd.ts 64.37 kB (➖)
refract from typegpustd.ts 64.37 kB (➖)
reverseBits from typegpustd.ts 64.37 kB (➖)
rotateX4 from typegpustd.ts 47.68 kB (➖)
rotateY4 from typegpustd.ts 47.69 kB (➖)
rotateZ4 from typegpustd.ts 47.69 kB (➖)
rotationX4 from typegpustd.ts 25.55 kB (➖)
rotationY4 from typegpustd.ts 25.55 kB (➖)
rotationZ4 from typegpustd.ts 25.55 kB (➖)
round from typegpustd.ts 64.37 kB (➖)
sampler from typegpudata.ts 742 B (➖)
saturate from typegpustd.ts 64.37 kB (➖)
scale4 from typegpustd.ts 47.68 kB (➖)
scaling4 from typegpustd.ts 25.55 kB (➖)
select from typegpustd.ts 50.30 kB (➖)
sign from typegpustd.ts 64.37 kB (➖)
sin from typegpustd.ts 64.37 kB (➖)
sinh from typegpustd.ts 64.37 kB (➖)
sint16 from typegpudata.ts 19.47 kB (➖)
sint16x2 from typegpudata.ts 19.47 kB (➖)
sint16x4 from typegpudata.ts 19.47 kB (➖)
sint32 from typegpudata.ts 19.47 kB (➖)
sint32x2 from typegpudata.ts 19.47 kB (➖)
sint32x3 from typegpudata.ts 19.47 kB (➖)
sint32x4 from typegpudata.ts 19.47 kB (➖)
sint8 from typegpudata.ts 19.47 kB (➖)
sint8x2 from typegpudata.ts 19.47 kB (➖)
sint8x4 from typegpudata.ts 19.47 kB (➖)
sizeOf from typegpudata.ts 23.28 kB (➖)
size from typegpudata.ts 24.97 kB (➖)
smoothstep from typegpustd.ts 64.37 kB (➖)
snorm16 from typegpudata.ts 19.47 kB (➖)
snorm16x2 from typegpudata.ts 19.47 kB (➖)
snorm16x4 from typegpudata.ts 19.47 kB (➖)
snorm8 from typegpudata.ts 19.47 kB (➖)
snorm8x2 from typegpudata.ts 19.47 kB (➖)
snorm8x4 from typegpudata.ts 19.47 kB (➖)
sqrt from typegpustd.ts 64.37 kB (➖)
std from typegpu.ts 101.45 kB (➖)
step from typegpustd.ts 64.37 kB (➖)
storageBarrier from typegpustd.ts 14.37 kB (➖)
struct from typegpudata.ts 3.42 kB (➖)
sub from typegpustd.ts 46.92 kB (➖)
subgroupAdd from typegpustd.ts 22.54 kB (➖)
subgroupAll from typegpustd.ts 22.55 kB (➖)
subgroupAnd from typegpustd.ts 22.55 kB (➖)
subgroupAny from typegpustd.ts 22.55 kB (➖)
subgroupBallot from typegpustd.ts 22.55 kB (➖)
subgroupBroadcastFirst from typegpustd.ts 22.55 kB (➖)
subgroupBroadcast from typegpustd.ts 22.55 kB (➖)
subgroupElect from typegpustd.ts 22.55 kB (➖)
subgroupExclusiveAdd from typegpustd.ts 22.55 kB (➖)
subgroupExclusiveMul from typegpustd.ts 22.55 kB (➖)
subgroupInclusiveAdd from typegpustd.ts 22.55 kB (➖)
subgroupInclusiveMul from typegpustd.ts 22.55 kB (➖)
subgroupMax from typegpustd.ts 22.55 kB (➖)
subgroupMin from typegpustd.ts 22.55 kB (➖)
subgroupMul from typegpustd.ts 22.55 kB (➖)
subgroupOr from typegpustd.ts 22.55 kB (➖)
subgroupShuffleDown from typegpustd.ts 22.55 kB (➖)
subgroupShuffleUp from typegpustd.ts 22.55 kB (➖)
subgroupShuffleXor from typegpustd.ts 22.55 kB (➖)
subgroupShuffle from typegpustd.ts 22.55 kB (➖)
subgroupXor from typegpustd.ts 22.55 kB (➖)
tan from typegpustd.ts 64.37 kB (➖)
tanh from typegpustd.ts 64.37 kB (➖)
texture1d from typegpudata.ts 12.00 kB (➖)
texture2dArray from typegpudata.ts 12.02 kB (➖)
texture2d from typegpudata.ts 12.00 kB (➖)
texture3d from typegpudata.ts 12.00 kB (➖)
textureBarrier from typegpustd.ts 14.36 kB (➖)
textureCubeArray from typegpudata.ts 12.02 kB (➖)
textureCube from typegpudata.ts 12.00 kB (➖)
textureDepth2dArray from typegpudata.ts 12.01 kB (➖)
textureDepth2d from typegpudata.ts 11.99 kB (➖)
textureDepthCubeArray from typegpudata.ts 12.01 kB (➖)
textureDepthCube from typegpudata.ts 11.99 kB (➖)
textureDepthMultisampled2d from typegpudata.ts 12.01 kB (➖)
textureDimensions from typegpustd.ts 24.30 kB (➖)
textureExternal from typegpudata.ts 873 B (➖)
textureGather from typegpustd.ts 24.30 kB (➖)
textureLoad from typegpustd.ts 24.31 kB (➖)
textureMultisampled2d from typegpudata.ts 12.02 kB (➖)
textureSampleBaseClampToEdge from typegpustd.ts 24.31 kB (➖)
textureSampleBias from typegpustd.ts 24.31 kB (➖)
textureSampleCompareLevel from typegpustd.ts 24.31 kB (➖)
textureSampleCompare from typegpustd.ts 24.31 kB (➖)
textureSampleGrad from typegpustd.ts 24.31 kB (➖)
textureSampleLevel from typegpustd.ts 24.31 kB (➖)
textureSample from typegpustd.ts 24.31 kB (➖)
textureStorage1d from typegpudata.ts 1.01 kB (➖)
textureStorage2dArray from typegpudata.ts 1.03 kB (➖)
textureStorage2d from typegpudata.ts 1.01 kB (➖)
textureStorage3d from typegpudata.ts 1.01 kB (➖)
textureStore from typegpustd.ts 24.31 kB (➖)
tgpu.accessor from typegpu.ts 259.37 kB (➖)
tgpu.bindGroupLayout from typegpu.ts 259.38 kB (➖)
tgpu.comptime from typegpu.ts 259.37 kB (➖)
tgpu.computeFn from typegpu.ts 259.38 kB (➖)
tgpu.const from typegpu.ts 259.37 kB (➖)
tgpu.fn from typegpu.ts 259.37 kB (➖)
tgpu.fragmentFn from typegpu.ts 259.38 kB (➖)
tgpu.initFromDevice from typegpu.ts 259.38 kB (➖)
tgpu.init from typegpu.ts 259.37 kB (➖)
tgpu.lazy from typegpu.ts 259.37 kB (➖)
tgpu.mutableAccessor from typegpu.ts 259.38 kB (➖)
tgpu.privateVar from typegpu.ts 259.38 kB (➖)
tgpu.resolveWithContext from typegpu.ts 259.38 kB (➖)
tgpu.resolve from typegpu.ts 259.37 kB (➖)
tgpu.slot from typegpu.ts 259.37 kB (➖)
tgpu.unroll from typegpu.ts 259.37 kB (➖)
tgpu.vertexFn from typegpu.ts 259.37 kB (➖)
tgpu.vertexLayout from typegpu.ts 259.38 kB (➖)
tgpu.workgroupVar from typegpu.ts 259.38 kB (➖)
tgpu from typegpu.ts 259.37 kB (➖)
translate4 from typegpustd.ts 47.68 kB (➖)
translation4 from typegpustd.ts 25.55 kB (➖)
transpose from typegpustd.ts 64.37 kB (➖)
trunc from typegpustd.ts 64.37 kB (➖)
u16 from typegpudata.ts 11.57 kB (➖)
u32 from typegpudata.ts 11.54 kB (➖)
uint16 from typegpudata.ts 19.47 kB (➖)
uint16x2 from typegpudata.ts 19.47 kB (➖)
uint16x4 from typegpudata.ts 19.47 kB (➖)
uint32 from typegpudata.ts 19.47 kB (➖)
uint32x2 from typegpudata.ts 19.47 kB (➖)
uint32x3 from typegpudata.ts 19.47 kB (➖)
uint32x4 from typegpudata.ts 19.47 kB (➖)
uint8 from typegpudata.ts 19.46 kB (➖)
uint8x2 from typegpudata.ts 19.47 kB (➖)
uint8x4 from typegpudata.ts 19.47 kB (➖)
unorm10 10 10 2 from typegpudata.ts 19.47 kB (➖)
unorm16 from typegpudata.ts 19.47 kB (➖)
unorm16x2 from typegpudata.ts 19.47 kB (➖)
unorm16x4 from typegpudata.ts 19.47 kB (➖)
unorm8 from typegpudata.ts 19.47 kB (➖)
unorm8x2 from typegpudata.ts 19.47 kB (➖)
unorm8x4 bgra from typegpudata.ts 19.47 kB (➖)
unorm8x4 from typegpudata.ts 19.47 kB (➖)
unpack2x16float from typegpustd.ts 34.51 kB (➖)
unpack4x8unorm from typegpustd.ts 34.51 kB (➖)
unstruct from typegpudata.ts 1.55 kB (➖)
vec2b from typegpudata.ts 17.97 kB (➖)
vec2f from typegpudata.ts 17.97 kB (➖)
vec2h from typegpudata.ts 17.97 kB (➖)
vec2i from typegpudata.ts 17.97 kB (➖)
vec2u from typegpudata.ts 17.97 kB (➖)
vec3b from typegpudata.ts 17.97 kB (➖)
vec3f from typegpudata.ts 17.97 kB (➖)
vec3h from typegpudata.ts 17.97 kB (➖)
vec3i from typegpudata.ts 17.97 kB (➖)
vec3u from typegpudata.ts 17.97 kB (➖)
vec4b from typegpudata.ts 17.97 kB (➖)
vec4f from typegpudata.ts 17.97 kB (➖)
vec4h from typegpudata.ts 17.97 kB (➖)
vec4i from typegpudata.ts 17.97 kB (➖)
vec4u from typegpudata.ts 17.97 kB (➖)
workgroupBarrier from typegpustd.ts 14.37 kB (➖)
writeToArrayBuffer from typegpu.ts 49.55 kB (➖)

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 Apr 29, 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.79, 1.66, 3.52, 6.15, 7.31, 11.06, 19.80, 22.90]
  line [0.87, 1.72, 3.89, 5.78, 6.82, 10.43, 19.66, 22.38]
  line [0.88, 1.72, 3.90, 5.84, 6.67, 8.46, 18.16, 22.27]
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.26, 0.47, 0.68, 0.81, 1.02, 1.06, 1.29, 1.42]
  line [0.34, 0.54, 0.68, 0.79, 1.03, 1.08, 1.33, 1.47]
  line [0.27, 0.50, 0.70, 0.84, 1.07, 1.16, 1.36, 1.48]
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.87, 2.02, 3.37, 5.78, 10.91, 22.75, 52.68, 106.75]
  line [0.77, 1.92, 3.59, 5.76, 11.05, 22.58, 49.18, 99.42]
  line [0.83, 1.80, 3.59, 5.75, 10.83, 22.54, 48.57, 100.44]
Loading

@aleksanderkatan aleksanderkatan force-pushed the feat/expand-property-access-in-externals branch from e29acd4 to d6e4f7e Compare May 28, 2026 11:47
@aleksanderkatan aleksanderkatan requested a review from Copilot June 8, 2026 09:52

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

This PR updates the “externals” pipeline end-to-end so tinyest-for-wgsl can collect an expanded external tree (including nested property access), and unplugin-typegpu can embed that richer externals structure into function metadata (bumping metadata format to v2). It also adds/updates unit tests and snapshot fixtures across tinyest-for-wgsl, unplugin-typegpu, typegpu, and the docs example tests to reflect the new metadata/external extraction behavior.

Changes:

  • Extend tinyest-for-wgsl externals collection from a flat list into a nested external tree derived from property access chains.
  • Update unplugin-typegpu metadata embedding to store backwards-compatible AST + new externals structure, and bump METADATA_FORMAT_VERSION to 2.
  • Add new coverage tests (e.g. nested externals) and update many snapshots across packages/docs.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/unplugin-typegpu/test/use-gpu-directive.test.ts Update snapshots for metadata v2 and new externals object shape.
packages/unplugin-typegpu/test/typescript-syntax.test.ts Update snapshots for metadata v2 / externals object.
packages/unplugin-typegpu/test/tgsl-transpiling.test.ts Update snapshots to reflect nested externals emission and metadata v2.
packages/unplugin-typegpu/test/parser-options.test.ts Update snapshots for metadata v2 / externals object.
packages/unplugin-typegpu/test/nested-externals.test.ts New tests validating nested externals extraction in Babel/Rollup transforms.
packages/unplugin-typegpu/test/auto-naming.test.ts Update snapshots for metadata v2 and externals object shape.
packages/unplugin-typegpu/test/aliasing.test.ts Update snapshots for metadata v2 / externals object.
packages/unplugin-typegpu/src/core/factory.ts Emit externals as a nested object tree (string-based emitter) and embed backwards-compatible AST.
packages/unplugin-typegpu/src/core/common.ts Bump metadata format to v2 and add makeAstBackwardsCompatible.
packages/unplugin-typegpu/src/babel.ts Emit externals as nested AST nodes for Babel plugin output; embed backwards-compatible AST.
packages/typegpu/tests/unplugin/autoname.test.ts Update expected metadata v2 output and externals shape.
packages/typegpu/tests/ref.test.ts Update error message snapshot related to invalid ref usage.
packages/typegpu/tests/externalPropAccess.test.ts New tests validating external property access resolution paths.
packages/typegpu/src/core/function/fnTypes.ts Remove obsolete TranspilationResult type (now owned by tinyest-for-wgsl).
packages/tinyest-for-wgsl/tests/parsers.test.ts Update externals expectations from arrays to nested object trees; add complex-tree test.
packages/tinyest-for-wgsl/src/types.ts Introduce shared types for externals tree + transpilation context/result.
packages/tinyest-for-wgsl/src/parsers.ts Track ancestor chain and build nested externals via new helper.
packages/tinyest-for-wgsl/src/index.ts Export new Externals type.
packages/tinyest-for-wgsl/src/externals.ts New externals-tree builder from ancestor/member-expression chains.
apps/typegpu-docs/tests/individual-example-tests/spinning-triangle.test.ts Update shader snapshot output affected by metadata/externals changes.
apps/typegpu-docs/tests/individual-example-tests/shifting-gradient.test.ts Update shader snapshot output affected by metadata/externals changes.

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

Comment thread packages/tinyest-for-wgsl/src/externals.ts
Comment thread packages/tinyest-for-wgsl/src/externals.ts
Comment thread packages/unplugin-typegpu/test/nested-externals.test.ts
@aleksanderkatan aleksanderkatan marked this pull request as ready for review June 8, 2026 15:02
@aleksanderkatan

Copy link
Copy Markdown
Contributor Author

FLAT

@aleksanderkatan aleksanderkatan marked this pull request as draft June 9, 2026 13:51
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: Expand property access when generating externals

3 participants