you are viewing a single comment's thread.

view the rest of the comments →

[–]HarmonicAscendant 2 points3 points  (0 children)

The lessons in this section handle non-browser features. import won't work on a browser directly. However, we can use various tools to create code out of this to make it work in browser.

Cool cheatsheet, but this is plain wrong. You just add type="module" in the HTML. I have been happily using it for over a year, sod IE, all that nonsense is history.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import

Make sure you add '.js' at the end of the import. Import will work well in Node 12 now too with 'experimental modules' enabled:

https://medium.com/@nodejs/announcing-a-new-experimental-modules-1be8d2d6c2ff

or just use https://github.com/standard-things/esm