So I'm writing an ES6 application that uses multiple files and dependencies. I bundle this up using webpack in to a single bundle.js. From here I want to run it through Babel to get ES5 JS inside of a VM (Duktape.) From here I can run the JS successfully, but then I want to actually instantiate the class I originally created by appending additional JS on to the end of this generated ES5 code.
Normally, my final output file built.js could be required like this:
const MyLib = require('built.js');
And then I would just use it like so:
let instance = MyLib();
instance.doSomething();
However, I need to access MyLib from the same JS string, instead of using require or import. The Babelfied output doesn't have meaningful names or any way to simply instantiate a "class" in vanilla JS. How would I use my module from ES5 appended to the end of this file?