Skip to content

treeshake: prepare for otp - #716

Open
jgonet wants to merge 2 commits into
mainfrom
jgonet/push-txtwnklxrxol
Open

treeshake: prepare for otp#716
jgonet wants to merge 2 commits into
mainfrom
jgonet/push-txtwnklxrxol

Conversation

@jgonet

@jgonet jgonet commented Jul 29, 2026

Copy link
Copy Markdown
Member
  • avoids adding helper when it's not needed.
  • sidesteps the problem of otp packager not handling builtin apps by providing behaviour information from host (this has its drawbacks, maybe we should redesign packager in the future).

jgonet added 2 commits July 30, 2026 00:20
We should avoid copying them when we don't use it; OTP packager script
works on premise that all apps gathered can resolve to actual apps in the project.
Treeshaker doesn't see apps outside of passed ones. OTP packager omits
builtin apps for now, so core behaviours (such as gen_server) are
not tracked.

We take them from the host; OTP packager already checks for major version
compat between BEAM coming from Popcorn and host one.
@jgonet
jgonet requested a review from mat-hek July 29, 2026 22:25
do: callbacks

defp behaviour_callbacks(nil, _module, behaviour) do
with {:module, ^behaviour} <- Code.ensure_loaded(behaviour),

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.

Don't we scan all the beam files that can be loaded? If not, we probably should

Comment on lines +220 to +221
stub_functions = Map.get(opts, :stub_removed_functions, false)
stub_modules = Map.get(opts, :stub_removed_modules, false)

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.

Now we set the default here and in the shaker. Let's do that once, in parse_opts

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.

2 participants