Webpack loader to transform <script type="module"> to require statements.
npm install html-script-module-loader
You'll also need another loader (like raw-loader or html-loader) to actually load the HTML files.
<script type="module" src="./nested.js"></script>
<h1>This is the template</h1>
console.log('loaded nested.js');
// Loader order is important. html-script-module-loader operates on JavaScript,
// so it must run *after* (further *left* in the loader string) raw-loader or html-loader.
var template = require('html-script-module-loader!raw-loader!./template.html');
// => "loaded nested.js"
console.log(template);
// => "<h1>This is the template</h1>"
MIT