headbank commented on issue #7408:
URL: https://github.com/apache/netbeans/issues/7408#issuecomment-2140480171

   I'll start by saying I may be guilty of mistaking "Firefox doesn't prevent 
you doing it" for "valid" in terms of the language. I've been going off the MDN 
pages on 
[`await`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await)
 and 
[`import()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import)
 and have been uncertain how rigidly-defined modules are at this point in 
language terms.
   
   Regarding `.mjs` I note the "Aside" on the subject in the [MDN Modules 
page](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#basic_example_structure)
 and think it is probably not (yet) a good determinant as it may be impractical 
for people to deploy with.
   
   The only real-world example I can speak on is my own codebase, which I'm in 
the midst of rewriting (thus how I washed up here). Some time ago I adapted my 
existing class-loader code to employ dynamic `import()` due to the advantages 
of it being Promise-based and that it prevents repeat-downloading of a URI; but 
I maintained the actual class files as already written, which is that they 
declare themselves in global scope:
   ```
   window.MyClass = class MyClass {...};
   ```
   Obviously this is a side-effect, which modules are discouraged from having, 
but not using `export` kept the door open to being able to load them by other 
means if desired.
   
   It's _useful_ that `import()` can be employed in a non-module context, and 
upon files that bear no module-specific syntax; likewise that top-level `await` 
does not place any module-specific syntax requirements on its file either. 
However it's fairly clear such usage is not _intended_ so I'd understand if you 
demur on supporting it.
   
   Would a warning, rather than error, condition be a compromise worth 
considering? (In context where `export` or `import` are absent)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to