move toBasicObject call to `compile` interface