ports/webassembly: import of a preloaded Emscripten FS fails on Node
Checks
-
I agree to follow the MicroPython Code of Conduct to ensure a safe and respectful space for everyone.
-
I've searched for existing issues matching this bug, and didn't find any.
Port, board and/or hardware
webassembly
MicroPython version
MicroPython v1.23.0-preview.324.g6634fea23.dirty on 2024-04-22; JS with Emscripten
(I've added more modules to the manifest)
Reproduction
- build webassembly port pyscript -> OK
- open repl via
node build-pyscript/micropython.mjs-> OK - micropython.mjs can be used on HTML pages as described in the readme file -> OK
so far so good - however... I want to "freeze" existing micropython files in an emscripten FS. For this I'm using the --preload-file argument in the makefile like this:
$(Q)emcc $(LDFLAGS) -o $@ $(OBJ) $(JSFLAGS) --preload-file <directory_with_python_files>
this works as expected in the browser and I can successfully import it via mp.pyimport(xxxx)
But I can't run the node repl with that micropython.mjs anymore. When trying to start the REPL I'm getting the following error:
<img width="872" alt="image" src="https://github.com/micropython/micropython/assets/5887072/5155d12f-1939-4fd4-a0c3-562ef621148f">
Expected behaviour
When building with --preload-file I'd expect that the REPL still starts and I can import the preloaded files
Observed behaviour
The above error appears (no REPL)
Additional Information
No, I've provided everything above.
ports/webassembly: import into node fails
Checks
-
I agree to follow the MicroPython Code of Conduct to ensure a safe and respectful space for everyone.
-
I've searched for existing issues matching this bug, and didn't find any.
Port, board and/or hardware
macOS, Node V20.11, Emscripten Port
MicroPython version
MicroPython v1.23.0-preview.324.g6634fea23.dirty on 2024-04-23; JS with Emscripten
Reproduction
fischmar@MACNP7L4XQC6C build-pyscript % node
Welcome to Node.js v20.11.1.
Type ".help" for more information.
> const mp_mjs = await import("./micropython.mjs");
Uncaught:
TypeError [ERR_INVALID_ARG_TYPE]: The "paths[0]" argument must be of type string. Received undefined
at validateString (node:internal/validators:162:11)
at Module.resolve (node:path:1101:7) {
code: 'ERR_INVALID_ARG_TYPE'
}
Expected behaviour
Import in node does not cause a fault.
Issuing node micropython.mjs correctly gives me the repl, so the mjs file seems to be ok.
Or maybe I'm missing something here? I was following the readme, section here:
const mp_mjs = await import("micropython.mjs");
const mp = await mp_mjs.loadMicroPython();
mp.runPython("print('hello world')");
Observed behaviour
see above
Additional Information
No, I've provided everything above.