This effect of the Module object (or the exports object in MODULARIZE) containing all kinds of fields - imports, configurations, internal functions and exports, is something that is well recognized. In MINIMAL_RUNTIME the Module object is being deleted, and there are separate imports and exports objects that will be used (though exports support has not actually been implemented there yet), and configuration items and internal functions will not be populated out to the exports object. The exports object is though to only contain items that user explicitly declares to need to be exported.
pe 15. helmik. 2019 klo 17.06 Hostile Fork ([email protected]) kirjoitti: > > I'm making a library that was built with ENVIRONMENT=web, and now am trying > ENVIRONMENT=node. > > For the browser, I'd named the library's functions things like > `mylibEntryPoint()` before. But the pattern in Node is that people say: > > var mylib = require('mylib') > > So `mylib.mylibEntryPoint()` seems redundant. Better would be > `mylib.EntryPoint()`, or `mylib.entryPoint()`. > > But when mylib is actually a `Module = {...}` coming from emscripten, the > resulting object comes with quite a number of fields, which one can see with: > > console.dir(mylib) > > There's a fair bit in there, including basic lowercase words (quit, buffer, > arguments) and uppercase ones (HEAP8, ENV, FS), along with plausibly generic > mixed case things (createContext, addFunction, readBinary). > > So that seems to run the risk of a conflict. Even if something is not taken > today, it might be in the future. > > A safe(r) thing to do might be to have this go in two steps: > > var mylib_node = require('mylib-node') > var mylib = mylib_node.ActualLibrary > > But even then, one would have to choose the names (and whether getting from > one to the other should be a function or a member--I'm not javascripty-enough > that the "right" thing to do in such situations ever seems obvious. :-/) > > Is there prior art or thinking on this topic? > > Best, > --Brian > http://hostilefork.com > > -- > You received this message because you are subscribed to the Google Groups > "emscripten-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
