I'd like to publish an NPM package, but closed source. I'm well aware of private packages, but that's not what I am looking for. I'd like to publish an package that everyone can use, but not everyone can inspect the code from.
I want to first build my code as a closed-source library, and then publish it to npm. How can I achieve such a thing?
I looked into uglyfying my code first, but will that obfuscate it enough?
It would be really nice to just package it like pkg does, but that does not allow packaging as an npm module.
As far as I know there's no real way to do this in the way you want. Code can be de-uglified easily.
You can write the code in a separate language like C, then compile it and write a javascript wrapper around it using native modules.
You can also put a really restrictive license on it which is displayed on the npm website when people view your module. But the code can still be viewed and it would be up to you to go after any people that break your license.
But since javascript isn't a compiled language there's no easy way to do this at the moment.