Allow modules to be bundled via local paths and globally (`expose`) at the same time

Fixes #1020 and potentially #935 (unverified). Added minimal test case and fix but open to revisiting it if there is a better approach.