Adi
Adi3y ago

Adi – 17-33 May 30

I have one question lets say I am using revealing module pattern in JS and if some methods are public and I attach that module to window object then I can access that public method of that specific module in another JS file is that correct? But lets say we have 2 separate files each of them are ESModules generated through webpack then can I access public method of one file in another JS file?? As we have generated both files using webpack module bundler they will not be accessed from any other file is this correct understanding?
2 Replies
ScriptyChris
ScriptyChris3y ago
An ESM module or "old school" one (created typically by some IIFE) doesn't attach any variables to the global scope by default (unless you explicitly do so or are in non-strict mode, which allows implicit global variables). So if you create any variable in such module, then it will not be accessible outside that module (including global scope)
reactibot
reactibot3y ago
This thread hasn’t had any activity in 12 hours, so it’s now locked. Threads are closed automatically after 12 hours. If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/980886675238584330