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?