Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Lua style requires #6

Open
losinggeneration opened this issue Jun 27, 2018 · 5 comments
Open

Support Lua style requires #6

losinggeneration opened this issue Jun 27, 2018 · 5 comments

Comments

@losinggeneration
Copy link

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.

@daurnimator
Copy link
Member

daurnimator commented Jul 4, 2018

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.

@tant42
Copy link

tant42 commented Jun 10, 2019

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?

@daurnimator
Copy link
Member

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?

@Lustyn
Copy link

Lustyn commented Jul 25, 2019

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.

@tant42
Copy link

tant42 commented Aug 29, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants