Reload your script files with window.reloadExternalModules

TwilioQuest uses Node.js require to import your JavaScript files like events.js and validator.js. This is generally pretty handy and works well for end players.

Because its optimized for production though, there's a particular issue content authors can run into. When Node.js requires an external module, it caches the imported module. If you make a change to the required script file TwilioQuest will not pick it up until you restart the game.

To make development easier, we have attached a variable to the window called reloadExternalModules that forces TwilioQuest to reset its cache every time it uses require. This means you will no longer need to restart TwilioQuest to see your script changes in game.

Here's a short events.js file that sets this value onLevelDidLoad so that you don't forget to do this manually while developing.

const DEBUG = true;

module.exports = (event, world) => {
  if (DEBUG && event.name === 'levelDidLoad') {
    window.reloadExternalModules = true;
  }
}
Tagged:
If this is an emergency, please contact Twilio Support. This is not an official Support channel. https://support.twilio.com/
Have an urgent question?
Please contact Twilio Support. This is not an official Support channel.
Contact Support