CQ.Ext is undefined in publish instance as i did not include widgets.js due to performance issue.
Is there any js file to import CQ.Ext function? I tried shared.js but it did not work.
Yes include of widget will add many library which is not required in publish & cause performance issue. Unfortunately that is the only way to get what you are looking. Other alternative is to build your own library.