While searching about the difference, I came across these definitions:
Compiling is the general term for taking source code written in one language
Ex: TypeScript ( a Microsoft superset of JavaScript with type safe checking) transpiles to JavaScript code which can run on different types of browsers.
https://en.wikipedia.org/wiki/Microsoft_TypeScript "Microsoft TypeScript is an open-source programming language developed and maintained by Microsoft. It is a strict syntactical superset of JavaScript, and adds optional static typing to the language.
TypeScript is designed for development of large applications and transcompiles to JavaScript.[5] As TypeScript is a superset of JavaScript, existing JavaScript programs are also valid TypeScript programs. TypeScript may be used to develop JavaScript applications for both client-side and server-side (Node.js) execution."