<script>
console.log($);
alert($.capital("hridayesh"))
$.addDOMContent("It works I think!!!")
</script>
Indeed, that works fine. But I'm wondering, how it would have to look like, if I externalize this functionality into a separate module "index.js" at the "index.html" directory level.
I can't make the import run. Could you elaborate please?
index.js:
import capital from './dist/index_bundle.js'
alert(capital("hridayesh"))
First attempt:
index.html:
<script src="dist/index_bundle.js"></script>
<script src="index.js"></script>
<!-- <script>
console.log($)
alert($.capital("hridayesh"))
$.addDOMContent("Well It Works Fine!!!")
</script> -->
Browser error:
Cannot use import statement outside a module
Second attempt:
index.html:
<script src="dist/index_bundle.js"></script>
<script type="module" src="index.js"></script>
<!-- <script>
console.log($)
alert($.capital("hridayesh"))
$.addDOMContent("Well It Works Fine!!!")
</script> -->
Browser error:
The requested module './dist/index_bundle.js' does not provide an export named 'default'
Indeed, that works fine. But I'm wondering, how it would have to look like, if I externalize this functionality into a separate module "index.js" at the "index.html" directory level.
I can't make the import run. Could you elaborate please?
index.js:
First attempt:
index.html:
Browser error:
Cannot use import statement outside a module
Second attempt:
index.html:
Browser error:
The requested module './dist/index_bundle.js' does not provide an export named 'default'