diff --git a/packages/tgpu-gen/gen.mjs b/packages/tgpu-gen/gen.mjs index 19f00641..8ef9d1c6 100644 --- a/packages/tgpu-gen/gen.mjs +++ b/packages/tgpu-gen/gen.mjs @@ -23,6 +23,7 @@ const LENGTH_VAR = 'arrayLength'; * @prop {boolean} toTs * @prop {'commonjs' | 'esmodule'} moduleSyntax * @prop {'keep' | 'overwrite'} [existingFileStrategy] + * @prop {boolean} experimentalFunctions * @prop {Set} [declaredIdentifiers] * @prop {{tgpu?: boolean, data?: boolean }} [usedImports] */ @@ -106,6 +107,7 @@ export function generate( outputPath: '', toTs: true, moduleSyntax: 'esmodule', + experimentalFunctions: true, }, ) { const reflect = new WgslReflect(wgsl); @@ -116,12 +118,16 @@ export function generate( reflect.getBindGroups(), options, ); - const functions = generateFunctions(reflect.functions, wgsl, options); + + const functions = options.experimentalFunctions + ? generateFunctions(reflect.functions, wgsl, options) + : null; + const imports = generateImports(options); const exports_ = generateExports(options); return `/* generated via tgpu-gen by TypeGPU */ -${[imports, structs, aliases, bindGroupLayouts, functions, exports_].filter((generated) => generated.trim() !== '').join('\n')} +${[imports, structs, aliases, bindGroupLayouts, functions, exports_].filter((generated) => generated && generated.trim() !== '').join('\n')} `; } diff --git a/packages/tgpu-gen/tgpu-gen.mjs b/packages/tgpu-gen/tgpu-gen.mjs index 13df7598..41b215fd 100755 --- a/packages/tgpu-gen/tgpu-gen.mjs +++ b/packages/tgpu-gen/tgpu-gen.mjs @@ -21,6 +21,7 @@ const args = arg({ '--overwrite': Boolean, '--keep': Boolean, '--watch': Boolean, + '--experimental-functions': Boolean, '-v': '--version', '-h': '--help', @@ -177,6 +178,7 @@ const execute = async () => { outputPath, toTs, moduleSyntax, + experimentalFunctions: args['--experimental-functions'] ?? false, }).catch((error) => { error.file = file; throw error;