Skip to content

feat: tree-shake unused extension free functions from export#8624

Open
malec-palec wants to merge 1 commit into
4ian:masterfrom
PlaytikaOSS:feat/dce
Open

feat: tree-shake unused extension free functions from export#8624
malec-palec wants to merge 1 commit into
4ian:masterfrom
PlaytikaOSS:feat/dce

Conversation

@malec-palec
Copy link
Copy Markdown
Contributor

  • Only include lifecycle function .js files (onFirstSceneLoaded, onSceneLoaded, etc.) as mandatory extension-wide includes.
  • Non-lifecycle free functions are now included only when actually referenced by event sheets.

Previously, using any single free function (or behavior/object) from an extension pulled ALL free function .js files into the build via extensionIncludeFiles. This was a conservative safety net that is redundant - the code generation pass already records transitive include dependencies per-function.

Why this is safe

  1. Transitive deps already handled - when function A's events call function B, the code generator adds B's include to A's metadata during the second-pass compilation.
  2. Lifecycle functions preserved - onFirstSceneLoaded, onScenePreEvents, etc. self-register via gdjs._registerCallback() at load time and are never referenced through event instructions; they remain in the mandatory include list.
  3. Behaviors/objects unaffected - their .js is included via their own metadata when the type is present in the project.
  4. Validated empirically - static analysis of multiple production projects confirmed that top-level free functions have no implicit invocation paths beyond event sheet instructions and lifecycle registration.

@malec-palec malec-palec marked this pull request as ready for review May 26, 2026 09:33
@malec-palec malec-palec requested a review from 4ian as a code owner May 26, 2026 09:33
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.

1 participant