Using ordinary modules for server code?

I’ve been toying with using ordinary modules (the kind that could work on both client and server) for code that I know I will only call from server modules. This seems to work as long as you don’t need to decorate the functions with @anvil.server.callable (and The Clean Architecture is telling me to separate the server.callable interface from the code anyhow). The benefit is that Anvil won’t automatically load such a module at every server call–as long as you only import the module inside the server functions using it.

There might be cons in terms of the Anvil IDE’s auto-completion and error tracebacks, though. And the initial load of the client side might also take a bit longer?

If load time is an issue, I would think the load cost for having extra client modules used only by the server would be less than importing everything every time any server function is called since the browser load is a 1 time cost and since the browser is already running, it ?wouldn’t? be as much of a cost as starting up a server every time.

2 Likes

That’s one tradeoff.

Another is that nosy users will be able to see that code, including all comments. They can’t tinker with the Server’s copy of it, of course.

2 Likes

Since reading this question yesterday was one of the reasons I even made this other post , I am going to plug it here:

2 Likes