Prevent Automatic import of anvil.server on some modules

Every now and then, some of my modules which do not and cannot rely on Anvil modules (ie web worker scripts) throw an error because it seems anvil has added import anvil.server automatically. Is there a way to prevent this behaviour?

I have not been able to pin down when or why this happens but suspect it is something to do with an update to the Anvil IDE causing the automatic imports to rerun?

This seems to be happening to us today

@mapgar could you provide a little more information on what you’re seeing? I’m not aware of auto imports happening if you’ve turned off that setting in your look and feel dialog.

(Note you always get that import when creating a new server module. But that’s nothing new)

We had a ton of files changed by Anvil to include the following line at the top:

import anvil.server

We did not add it, but anvil added it to about 20 of our client code modules

What look and feel dialog? Maybe the wrong setting there that is what is causing the problem for us.

see the docs above

If you turn off auto-imports this won’t happen.

When auto-imports are on (default), it does look like adding a server module will add the import anvil.server everywhere. This is probably overkill, so we’ll look to do this only on the first time you create a server module.

1 Like

Thanks! Does this have to be set individually for each person working on the project?

Yes it’s a user setting.

1 Like