Now the options are:
- Don't write this code. It's not strictly necessary, and the program works fine without it.
- Write this code exclusively for your project.
- Write this code on your own time, package it as a library, publish it under a commercial-use-friendly license such as BSD, and fold it into the work project.
But on the other hand, creating a open-source library would probably raise the quality of the result. Even if the employer ends up as the only user, the act of creating a separate library would force you to make a better API and cleaner code than if the code was tightly integrated with your project. If the library gains additional users, there may even be useful code contributions.
As an external library, now there is one place for bugfixes and improvements.
And because the library is developed on your own time (as it would have to be, for legal reasons), the employer gets a solution to their problem for free.
Now to see what my manager thinks of this.