|
Hi, I’m trying to figure out a way to pre-compute ‘require’
dependencies for a given module. In Python there’s a ‘ModuleFinder’
library that can calculate the set of modules used by a given Python script. I’d
like to implement something similar for Lua. I have a lua runtime in my main
thread. Scripts may come in from any number of background threads. When I load
the scripts from disk in each thread I’d like to include the script
dependencies along with it. My first thought is to have a separate Lua_state in each thread
and create a custom loader that would accumulate the ‘require’
dependencies. Is this the right approach to this problem? Alternatively
I thought about a modified luac that would generate bytecode for a module and
all of its dependencies. I’m thinking this might be a better
approach in the long term. Has anyone implemented something to calculate these
dependencies who can share some thoughts? Thanks, -Aaron |