#til

#TIL : ES6 Module import in client browsers

moduleA.js

export const message = "Hello from moduleA!";

moduleB.js

import { message } from './moduleA.js';
console.log(message);

app.html

<script type="module" src="moduleB.js"></script>

// Print console log "Hello from moduleA!"

So moduleB.js acts like a module entry-point, it loads all dependencies deeply to run it-self, so you only need add script tag point to it.

Enjoyed this post?

If you found this helpful, consider sharing it or leaving a kudo!

0 kudos