Replies: 2 comments
-
I see that pretty much the same issue was reported here , e.g. https://github.com/Aviortheking/astro-template-not-running-js/blob/master/src/pages/index.astro; but this is not solved and does not behave as expected? As mentioned above, the IMHO, this makes Astro significantly less compatible with HTML Templates. You will have to memorize for each component if you use a component within it within a Also, it makes it impossible to use astro components with complex scripts (e.g. that import other ES Modules, as |
Beta Was this translation helpful? Give feedback.
-
So my current workaround for this problem is:
Then, instead of:
You do:
...and Dummy's script will be bundled. Done in this way such that, if Astro decides to fix this, all you have to do is modify:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Take the following example component:
Dummy.astro
:Now code an
index.astro
file with the following contents:This will lead to the fact that astro will never bundle the script of the Dummy component. You will only see the
Hello World
console log after removing theDummy
component from the template tag. Astro seems to not include scripts of the component if it is within a template tag, even if it is rendered into the page too, outside of the template tag.Is this a bug?
I found out that adding
is:inline
on the script tag fixes this, but this only works as long your script does not import any ES modules, so I guess this is not really the right solution.Beta Was this translation helpful? Give feedback.
All reactions