For our own files, this is equivalent to changing the target .lua module to return a large string of all the Lua code, then calling require and passing that to load, so it doesn't let us do anything new, but I really don't want to write the code in a large multi-line string.
Why:
I have a test framework in my mod for running tests. I can run tests both outside Factorio, in normal lua5.2, and inside Factorio. It's nice to be able to run the tests in the real runtime. But some of my tests need to control Factorio globals, such as "game" or "script", and I do so by using loadfile with a custom environment. I could try to mess with _G but that's a lot riskier, and not really a good Lua practice, at least in 5.2. Those tests currently can't run inside Factorio and I'd like to fix that.
Thank you for your consideration
