Adonis icon indicating copy to clipboard operation
Adonis copied to clipboard

Remove all tampering with the env (setfenv, getfenv)

Open SuperCater opened this issue 2 months ago • 7 comments

What part of Adonis is this related to?

Other

What are you suggesting?

Preface

Adonis has for a long timed used setfenv and getfenv for adding variables to module factory functions but these cause performance issues that we should seek to resolve.

Reasons to remove

Both setfenv, and getfenv have since been deprecated by Roblox and disable Luau optimizations, they're also just considered bad practice now. It also offers no ability of type checking.

Downsides

This will break the following things if fully removed

  • Any old plugins that relied on ENV
  • Any custom UI modules that relied on the ENV.

Solution

Just use the Vargs table passed to the module returns. Any method needed could be attached to the server/client table.

Each module will need to be updated to support not having a custom env.

  • [ ] Server Modules/core
  • [ ] Client Modules/core
  • [ ] All UI Modules
  • [ ] Service table
  • [ ] Plugins

In regards to the downside, i believe it would be justified to

Give an Adonis alert that plugins will break if they rely on the env as a heads up before adding this change (hopefully with an ETA of when it will be done) Maybe add support in the loader to load specific versions for people who arent ready to upgrade yet? This would require mapping each Adonis version to its Roblox version i believe.

SuperCater avatar May 02 '24 23:05 SuperCater