Detailed answer
It is treated as a JavaScript module, with imports, module scope, and strict-mode semantics.
Cross-origin loading uses module-related CORS rules. Serve examples over HTTP for realistic testing rather than assuming local file URLs will behave the same way. Imported resources must return suitable JavaScript content and MIME types.
Example
<script type="module" src="/scripts/app.js"></script>
Understanding the behavior
Module scripts use module scope and strict-mode semantics and are deferred by default unless async changes scheduling. Imports are resolved as URLs, and server MIME and cross-origin rules matter. Opening a project directly from a file URL can produce different restrictions.
Practical implementation notes
Serve the example through a local HTTP server and inspect failed import requests. A variable declared in a module is not automatically attached to window for a separate classic script to access.
How to check it
Use type=module and serve the example through HTTP with correct resource types.
Expected result
The browser treats imports and scope according to module rules.
Watch out: A top-level module variable is not automatically a window property.
Read the reference ↗