gluon icon indicating copy to clipboard operation
gluon copied to clipboard

Runtime error on WASM

Open Boscop opened this issue 3 years ago • 3 comments

When I try to use gluon on Wasm (in a web frontend using trunk serve), I get this runtime error:

Uncaught TypeError: Failed to resolve module specifier "env". Relative references must start with either "/", "./", or "../".

I'm using the latest version with these features:

gluon = { git = "https://github.com/gluon-lang/gluon", default-features = false, features = ["random"] }
gluon_codegen = { git = "https://github.com/gluon-lang/gluon" }

(When I don't call the function that uses gluon, the frontend works fine without errors.)

Any idea why it's not working? :)

Boscop avatar Oct 27 '22 16:10 Boscop

Btw, a related question: How can I add gluon modules that should be are available for import, such that I specify them as string (.glu file content + module name), not as real filename? In my use case the modules only exist as Strings in RAM (e.g. when running in the Wasm frontend), not as files on the file system. So I'd like to import them from RAM, is it possible somehow? :)

Boscop avatar Oct 27 '22 16:10 Boscop

Calling load_script will register the script under the given file name which you can then import by refering to the module name (my/file.glu -> my.file etc)

Marwes avatar Oct 28 '22 13:10 Marwes

No idea why WASM isn't working, never tested it throughly so something may have broken.

Marwes avatar Oct 28 '22 13:10 Marwes