How to import es6 module that was defined in script type = "module"> tag inside html?
I can define the module in my html me.html file:
<script type="module" id="DEFAULT_MODULE">
import Atom from './atom.js';
console.log("definition of getAtom")
export default function getAtom(){
return new Atom('atom');
}
console.log("exported getAtom")
</script>
Also see
=> Is it possible to import this "anonymous" module into another script module into the same html file? Or in some "code behind" - a JavaScript file that was also uploaded by the me.html file? Export seems to work; at least this does not cause any error.
To import the method, getAtom
I tried for example:
<script type="module">
import getAtom from '.'; //this line does not work
console.log("usage of getAtom")
var atom = getAtom();
</script>
I would expect some syntax like
import getAtom;
import getAtom from '.';
import getAtom from window;
import getAtom from './me.html';
import getAtom from '.DEFAULT_MODULE';
However, none of these lines worked.
=> What is the correct syntax for referencing an anonymous module, if at all possible?
Chrome 63.0.3239.108.
: