Advice on removing lua global variables

Back in nakama version 2.12 I think, there was a change to the server config that made lua global varialbes read-only by default. At the time we had global variables, so set the config so they were still allowed. But we’re now getting to that and hopefully eliminating them. We have lua modules that we require in other lua nakama modules and we’ve implemented this way:
M = {}
M.someFunction ()
return M
Would that break if global variables are read only? We do have some global properties that we can work around, but we’re just wondering if our lua module implementation is breaking too. Thanks.

is it more memory efficient to do something like this?

local function someFunction ()
end
return {someFunction = someFunction}

would that improve memory use in the nakama context?

@oscargoldman The change made in Nakama to enable read_only_globals by default enables us to clone the VM instances inside the pool and share the initial VM state ahead of any execution done within an RPC function call (or before/after hooks, etc). This optimization overall reduces the amount of duplicate datastructures constructed in-memory in each VM allocated.

In your code examples the first one should become:

local M = {}
M.someFunction ()
return M

The second example should be (which is what you showed):

local function someFunction ()
   -- some code
end
return {someFunction = someFunction}