So say I have one file (file1.js) with the following code:
var output = {
thing: "A thing",
another: "Another thing"
}
Now if I were to reference this in another file, like this:
<script src='file1.js'></script>
<script>
console.log(output);//Logs the object to the console.
</script>
it would import the output variable, for use. However if I were to use exports, as in the following snippet it would not work, and instead only allow imports:
//file1.js
var output = {
thing: "A thing",
another: "Another thing"
}
export default output;
<script type="module">
import something from "file1.js";
console.log(something.thing);//"A thing";
console.log(output);//Error, but if I had omitted the exports and imports it would work fine.
</script>
Is there a way to make both of these work? So that I could import something from "file1.js" while still being able to use the "output" variable? Note that I'm using this in a library so I cannot rely on the user to do something client-side.