Support Lua style requires
Having support for requires similar to what standard Lua uses would be nice. I have an implementation that works well enough for my purposes here. This allows requires to be in the form of "fu.bar" to which is similar to "./fu/bar.lua" with how the loader currently works. It isn't doesn't work exactly like Lua's package loader, but is a starting point that can be improved if this is something fengari-loader is going to support.
Adding my (delayed) reply from IRC:
The issue is that webpack does automatic node-js style resolution. If we add in Lua style resolution it still then does the node-js resolution on top and turns things into unwanted results. I think the way to get Lua-style resolution is to modify your webpack config to add Lua search dirs and other Lua-y bits. Annoyingly it seems it has to go in the config, and can't be in a loader.
There's the additional issues of wanting to be able to require arbitrary JS libraries/files from Lua: if lua's require acts differently to JS's then this gets very confusing.
I'm trying to use the 'dependencies' option to work with a somewhat large code base (I assume dependencies are used to address this issue?)
Unfortunately I get "Can't resolve 'fengari-web'" when I try to define dependencies as a map of requires strings to files paths (which is how I assume it's to be used).
Is there an example of how dependencies are supposed to work?
Unfortunately I get "Can't resolve 'fengari-web'" when I try to define dependencies as a map of requires strings to files paths (which is how I assume it's to be used).
Do you have an example snippet that gives this error?
I think the more appropriate way to solve this issue is to separate a JS require from a Lua require. Their styles are far too different to mix the two and using JS imports to import Lua breaks basically any existing platform-independent Lua code people have.
I need to put together a test case, but in my issue was with using symlinks to my code base. Webpack is expanding and using the symlink's original path and that was breaking how require works.
Looks like if I add the webpack config:
resolve: {
symlinks: false
},
to module.exports, my issue is resolved.