I keep a list of files I've changed, including mods. When I decide to update the game or mods I use notepad++'s compare plugin to see if there are differences between files from new update and my current files. Then, I make the same changes to files of updated version too. This way I only change specific parts of code without touching any other changes made by developer. It takes some time but sadly this is the most efficient way I know of.
Just make a custom mod file and hijack whatever function you are editing. Base game files get loaded first and mods load after, so if the game updates and the base games .js file updates your mod remains untouched and working and over write base game changes because they loaded after.
Just make a .js file with this as the first lines. And name the file Custom.js
// #MODS TXT LINES:
// {"name":"Custom","status":true,"description":"","parameters":{"Debug":"0"}},
// #MODS TXT LINES END
And then below it add whatever function you are changing with the changes you want. As an example I have this in mine
//Max Bar customers
Game_Troop.prototype.waitressBattle_startingCustomers = function() {
let actor = $gameActors.actor(ACTOR_KARRYN_ID);
let customers = [];
let startingNum = 10;
let rep = $gameParty._barReputation;
startingNum = Math.min(startingNum, BAR_TOTAL_SEATS);
for(let i = 0; i < startingNum; ++i) {
customers.push(this.waitressBattle_validEnemyId());
}
return customers;
};
Which is from the waitress file and this edit makes it so 10 people always spawn when the waitress mini game starts so you have a full crowd.