fengari-lua / fengari-web

Provides everything you need to run Fengari in the browser.
MIT License
244 stars 19 forks source link

How can I handle require()? #43

Open FrancoisMentec opened 4 years ago

FrancoisMentec commented 4 years ago

When I try to load this file (https://github.com/LocalIdentity/PathOfBuilding/blob/master/Modules/Common.lua) I'm getting this error :

uncaught exception http://localhost:3000/PathOfBuilding/Modules/Common.lua:23: module 'lcurl.safe' not found:
    no field package.preload['lcurl.safe']
    no file './lua/5.3/lcurl/safe.lua'
    no file './lua/5.3/lcurl/safe/init.lua'
    no file './lcurl/safe.lua'
    no file './lcurl/safe/init.lua'
    no file './lua/5.3/lcurl/safe.js'
    no file './lua/5.3/loadall.js'
    no file './lcurl/safe.js'
    no file './lua/5.3/lcurl.js'
    no file './lua/5.3/loadall.js'
    no file './lcurl.js'
w @ fengari-web.js:8
I @ fengari-web.js:8
(anonymous) @ fengari-web.js:8
C @ fengari-web.js:8
MutationObserver.observe.childList @ fengari-web.js:8

I followed the Getting started from your website https://fengari.io/, but replaced "/my-script.lua" with the file I linked previously. The error come from require, the script I try to run want to load some external library, how can I handle that? Is there a function to tell fengari that a script tag corresponds to a specific extension? Also, I know nothing about Lua, I just want to run a project written in Lua in a browser extension and your project looks like what I need.

daurnimator commented 4 years ago

Your script tries to load the lcurl.safe library: you would need to provide this library somehow (or some compatibility layer for it).