Mustache object will be required synchronously on load and output the name and version below.
※Make sure to do npm install first.
※Requires using a server.
import require from "./index.js"
// When used externally:
// import require from "/node_modules/import-require-js/index.js"
console.log(require)
window.mustache = require('mustache')
// const mustache = require('./node_modules/mustache/mustache.min.js')
console.log({ 'window.mustache': window.mustache })
window.addEventListener('load', function(){
let html = `
Name: ${window.mustache.name}<br>
Version: ${window.mustache.version}
`
document.getElementById('output').innerHTML = html
})
Name: mustache.js
Version: 3.0.1