The fix was to compile worker.ts to a .cjs file, because the worker was importing code from other typescript files.