I'm not able to import a function called jsonFetch and use define:vars= simultaneously inside a <script> in Astro
---
// Code related to the Astro backend
const question = { /* data */ };
---
// HTML code
<script define:vars={{ question }}>
import {jsonFetch} from "../../utils/json-fetch.ts";
</script>
❌ The code above shows me this error:
Uncaught SyntaxError: Cannot use import statement outside a module
✅ But if I remove define:vars={{ question }}, the import works fine
❌ Using <script define:vars={{ question }} type="module"> shows me this error:
GET http://localhost:4322/utils/json-fetch.ts 404 (Not Found)
How can I import a function and keep define:vars=?
Thank you for checking!
I managed to do it by using an alternative way of passing server-side variables