I can't seem to get ES6/2015 imports to work. From this Understanding ECMAScript 6 book, I understand I need to write my <script>
tags with a type
attribute of modules
:
<script type="module" src="module.js"></script>
Then I can use import
within module.js
. However, it doesn't work on the latest Firefox (v48.0.1) and Chrome (v53.0.2785.89). Nothing gets logged to the console when I put a console.log
statement in module.js
.
How can I use ES2015's import mechanism in a browser (natively, not using something like babel/webpack)?
UPDATE: Looks like Microsoft's Edge browser supports modules, at least in experimental mode. Why aren't other browsers supporting it yet then, at least in experimental mode?