Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Use of Revealing Modules for scripts

Hi, The API cookbook page on the Help Centre describes the Revealing Module pattern but doesn't actually say where it needs to be used. Is it required for scripts to use this pattern to integrate with others? Can ES6 modules be used also?
1585932431
The Aaron
Roll20 Production Team
API Scripter
It is not required, it's just a technique of building a private scope and protecting the global scope from collisions. ES6 Modules won't work on the Roll20 API, as the individual scripts don't get loaded like they would in a Node Application.  They instead get concatenated together into one large script that is then executed by the API Sandbox.
Ah, ok. So it's a good idea because when they're all concatenated multiple scripts might conflict in the global space.
1585937117
The Aaron
Roll20 Production Team
API Scripter
Right you are!