GitHub user breautek added a comment to the discussion: Support ES6

There's kind of different environments at play here.

Short answer: No

The webview itself may ES Modules support. Chrome has ESM support since Chrome 
61, so as long as the device is running Chrome 61+, you should be able to use 
`<script type="module=" src="myModule.mjs"></script>`, so your application 
itself might be able to consume ES modules, but I honestly not even sure if 
this works (cause I know they have specific mime requirements, which I'm 
honestly not sure if cordova fulfils). Factory API 24 devices will ship with 
Chrome 53 (based on the AOSP simulators), so assuming that device is running 
Chrome 61+ might be an unsafe assumption.

But for everything else there is a lot of ESM interop issues between CommonJS 
and ESM.

Plugins impementing JS modules for cordova environments uses a module system 
that predates CommonJS but is very much similar to commonjs (in the sense that 
they have a `exports` object and `require` method). The difference is the 
exported object is what is used to clobber the global namespace. So ESM support 
won't work well here, because cordova JS module can't have an asynchronous 
export definition. Even if a plugin exports an object that is then modified by 
reference later in time would simply cause `deviceready` to fire before that 
plugin is actually ready to be used.

For the Cordova tooling itself that runs in NodeJS, there's a lot of interop 
issues between CommonJS and ESM. Cordova tooling was built with the module 
system available at the time, which was commonjs format. Though I can't think 
of concrete examples off the top of my head, I do know that it was preventing 
us from upgrading certain dependencies as they moved to ESM.



GitHub link: 
https://github.com/apache/cordova/discussions/434#discussioncomment-7103648

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to