Skip to content

Conversation

aleksanderkatan
Copy link
Contributor

Changes:
now the following works.

const myFun1 = () => {
  'kernel';
  return 0;
};
expect(getName(myFun1)).toBe('myFun1');

const myFun2 = function () {
  'kernel';
  return 0;
};
expect(getName(myFun2)).toBe('myFun2');

function myFun3() {
  'kernel';
  return 0;
}
expect(getName(myFun3)).toBe('myFun3');

@aleksanderkatan aleksanderkatan linked an issue Sep 23, 2025 that may be closed by this pull request
Copy link

github-actions bot commented Sep 23, 2025

pkg.pr.new

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

https://pkg.pr.new/software-mansion/TypeGPU/typegpu@4d8d70b8757780138758d070e2f68cf3bc1af9d8
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/noise@4d8d70b8757780138758d070e2f68cf3bc1af9d8
https://pkg.pr.new/software-mansion/TypeGPU/unplugin-typegpu@4d8d70b8757780138758d070e2f68cf3bc1af9d8

benchmark
view benchmark

commit
view commit

Copy link

@Copilot Copilot AI left a comment

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 implements auto-naming functionality for functions in the unplugin system. It enables automatic naming of arrow functions, function expressions, and function declarations that contain the 'kernel' directive.

  • Adds getFunctionName utility function to extract function names from AST nodes
  • Updates both Babel and Rollup transform pipelines to support function auto-naming
  • Enhances the global __TYPEGPU_AUTONAME__ handler to work with regular JavaScript functions

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/unplugin-typegpu/test/auto-naming.test.ts Adds comprehensive tests for function auto-naming in both Babel and Rollup transforms
packages/unplugin-typegpu/src/index.ts Updates Rollup transform to use new getFunctionName utility and apply auto-naming to functions
packages/unplugin-typegpu/src/common.ts Introduces getFunctionName utility function to extract function names from AST nodes
packages/unplugin-typegpu/src/babel.ts Updates Babel transform to handle function auto-naming with new transpileAndAutoname helper
packages/typegpu/tests/unplugin/autoname.test.ts Enables previously disabled tests for function auto-naming functionality
packages/typegpu/src/shared/meta.ts Updates global auto-name handler to support regular JavaScript functions via setName

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@aleksanderkatan aleksanderkatan marked this pull request as ready for review September 23, 2025 16:39
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@aleksanderkatan
Copy link
Contributor Author

The behavior has changed a little.
Now, if we create a shellless function that can be named, and then pass it into a shell, the shelled function will retain the name of the shellless function.

Copy link
Collaborator

@iwoplaza iwoplaza left a comment

Choose a reason for hiding this comment

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

👏 !Awesome! 👏

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: Autoname functions in unplugin
2 participants