I have a program with a fallback for browsers that do not support web workers. The reason I'm doing this is because I want to deploy it to cocoon's canvas+, which does not support web workers. The non web worker code can access the script 'mountainNoise.js' fine, since it uses ES6 import and export, however when the worker imports the script via "importScripts()" it throws an error since export declarations can only appear in modules.
Is there a way to detect if the code is running in a module? My main concern is duplicating the file to support both versions, but this is ridiculous since it's taking much more memory for one line of code.