Clarification around registerJSModule #4346
-
There's not much to read in the official docs so I've thought that maybe it's worth asking in here before going mental about implementing the same in other runtimes and/or in PyScript ... we've noticed that in polyscript when we register polyscript as a module and it has its own field attached, we can then use that field to import stuff from it: from polyscript.field import whatever This works "by surprise" because in Python one cannot use dictionaries to import stuff from them but in this case polyscript is a dictionary and the only special thing about that field is that it's a Proxy that indeed resolves stuff lazily. Are we correct in assuming that registered JS modules in Pyodide act as if these were containing submodules per each filed or ... in case this is not an undesired bug, what is the thinking behind this "feature", if meant? Thanks in advance for any sort of clarification around this topic! /cc @hoodmane |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
Yes this is the intended behavior. We should update the docs to be more clear about it. I think the perspective we took was as follows:
So I don't expect we'll ever want to change this. It's a bit weird but there's no other approach which is better. |
Beta Was this translation helpful? Give feedback.
Yes this is the intended behavior. We should update the docs to be more clear about it.
I think the perspective we took was as follows:
from js.document import addEventListener
but there's no way to know ahead of time thatdocument
should be treated as a submoduleSo I don't expect we'll ever want to change this. It's a bit weir…