Simple demonstration of packaging for IIFE using single project.
This project attempts to use one source code to distribute multiple packages. This project is compiled for IIFE. For more detail check the github repo.
Before anything we should install the dependencies:
npm i dj-hello-world-iife
Write a html file importing the script.
<script src="node_modules/dj-hello-world-iife/index.js"></script>
After importing the script you can use the global variable DJ_Hello_World
.
<script>
let world = new DJ_Hello_World.World();
world.sayHello();
</script>
Check the printed messages in the console from browser's Developer Tools tab.