Closed Inkdpixels closed 6 years ago
Same question
Modules are cached after the first time they are loaded in node. The documentation states this explicitly:
The simplest getComponent would be to use require. One drawback here is that your components would be cached between requests and thus could leak memory and/or data. Another drawback is that the files would have to exist relative to where this require is being used.
@liang3404814 Sure but the docs also state that devMode: true
disables cluster mode and reloads each component every time it is requested
. As I said, maybe I got it all wrong and there is a solution built in (maybe without using require as you stated), but AFAIK devMode is not used besides the cluster setup, so either
:)
Whoops! This is carried over from before this library was open sourced when we had a feature like that. This is no longer useful because you can define your own custom behavior in getComponent
and even return a Promise from it if you need to asynchronously fetch the file from somewhere. Hypernova also ships with a VM you can use to load remote code.
I just tried out the hypernova stack and found that the
devMode
does not reload the component on each request as documented.Example
hypernova.js
app.js
server.js
What happens
When requesting
localhost:8080
you will be greeted as configured byHello Stranger
but when changing the returned string of the App, e.g. intoHello foo bar ${props.name}
the supernova server still renders the old cached component and returnsHello stranger
again.What should happen
When passing a truthy
devMode
option to hypernova, the server should invalidate the Node caches on each request.I also searched for references of
devMode
in the server code, but haven't found anything except for the cluster setup.Maybe I just missed something, but to me it seems this functionality isn't implemented or was removed in a recent commit?