I thought that bundle will only include things necessary for the script to be bundeled.

Yes, but that's because of how linkers work with static libs (they choose only what's necessary and discard the rest). The script itself includes all the static libs wuth -a --all.

What do now? How can I remove it?

Instead of passing --all you pass only the libs that you need.

Shouldn't these libs be added automatically? Or am I wrong here?

The script adds a few common windows libs to the cmdline as you can see in the output, but it doesn't add everything (Windows has thousands of libs). You can add these with the -d switch (type mgit bundle to see all the switches).

Yes, it's possible but you need to parse the PE/ELF/MACH file formats to get the binary dependency tree. Such feature could be added to https://luapower.com/luapower which already does a lot of metadata extraction and then the bundle script would just use that information.

(I'm not sure it's worth the effort though, I mean when you make an app, you know what libs you use, the --all switch is mostly useful to check for errors and conflicts between libs as you found out yourself)

Yes, you have to include the .lua modules too. The full list of dependencies is on the website, and you can also use the luapower command to get them.

I understand that you're trying to get to an exe as quick as possible so that you can validate that the thing works and seeing that you have to know exactly what you need to put in is frustrating. But the thing is that bundling is really a late step in the dev process -- by the time you need to bundle your app, you'll know your dependencies very intimately.

Ok, found it out. The problem was that the main module given after the -M switch (without .lua extension), needs to be included in the -m list of Lua modules (with .lua extension) that get compiled into the EXE.