I'm working in RStudio and am instructing knitr to include a JavaScript code chunk:
```{js, echo=FALSE}
import { MyModule } from './js/mymodule.js';
[other code]
```.
However, the JS engine is throwing an import error because I need the opening <script>
tag to contain the attribute type="module"
. Is there a way I can have knitr automatically add this attribute for me instead of putting in by hand in the resulting HTML file?
I'd suggest that you write the <script>
tag directly, since it's not much extra typing effort, and raw HTML elements work fine in Markdown.
<script type="module">
import { MyModule } from './js/mymodule.js';
[other code]
</script>