Forget everything I said. About 50 bundles later (seriously) I’ve found the problem and it’s unrelated to anything else that’s been discussed.
In my localisation script (called lang.lua), I have a brief note explaining its usage:
--[[USAGE
local lang = require "utilities.lang.lang"
print(lang.txt(lang.text_id.DAMAGE, {damage_amount = 12, num_seconds = 3}))
]]
The issue is this require line in the comment and the incorrect (?) format of the block comments. I don’t know the inner workings of the engine, but I’m guessing that when building in the editor the line gets ignored as expected. In bundles, however, it isn’t ignored, and the resulting self-referencing require causes the game to shut down.
I note that these comment formats both successfully lead the line to be ignored:
--
--[[ --]]
But not this one, even though it works in the editor:
--[[ ]]
Programming in Lua is unclear, and seems to suggest both are options. The examples use --]] to terminate a block comment, but the description doesn’t:
Lua also offers block comments, which start with
--[[
and run until the corresponding]]
So potentially we have a couple of issues here:
-
Can/should a change be made so that --[] doesn’t cause issues like this;
-
If not, should an error be thrown when --[] is used; and
-
Should an error be thrown when a module tries to reference itself?
I should have known better - I have been burned by block comments before…