Let's say you create a project folder named 'project' in your desktop and inside of it a simple index.html file.
Now, you want to create a script and so to not polute your index.html, you code your script inside a script.js file and then import it in your index.html using <script src="script.js"></script>
.
This works flawlessly! However, if you just so wish to make it an ES6 module by using type="module"
, you'll face a CORS policy block error and the script will not load.
Why does this happen? Is there any way to use ES6 modules in local files without coding directly in a script tag within the html file? Is this ever going to be supported?
Using a bundler/compiler is out of question in this scenario as it is inteded to be as simple as possible, but using ES6.