# Correct way to use ES6 modules and import classes

**URL:** <https://discourse.processing.org/t/correct-way-to-use-es6-modules-and-import-classes/21386>\
**Category:** Coding Questions\
**Created:** [May 28, 2020, 10:54pm UTC](https://discourse.processing.org/t/correct-way-to-use-es6-modules-and-import-classes/21386 "2020-05-28T22:54:08Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [May 28, 2020, 11:12pm UTC](https://discourse.processing.org/t/correct-way-to-use-es6-modules-and-import-classes/21386/2 "2020-05-28T23:12:01Z")

</div>

> [@josephh](#):
>
> … because they are in a different module not in the global namespace.

> [@How to access p5js functions when using ES6 modules](https://discourse.processing.org/t/how-to-access-p5js-functions-when-using-es6-modules/21359/2):
>
> That “p5.voronoi” library is meant for sketches using the “global mode” approach only: It means at the very least your main “sketch.js” file gotta use the “global mode” approach as well. If p5.js is loaded via \<script\>, it dumps itself on the global namespace & thus it can be accessed even by ES6 module files, as long as it finds setup() and/or draw() on the global namespace as well, like this: window.setup = function () {} Here’s a p5.js global mode sketch example using ES6 module files…

---

_[View the full topic](https://discourse.processing.org/t/correct-way-to-use-es6-modules-and-import-classes/21386)._
