Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 BUG: scripts with a src prop and a prop with a value of true are hidden from the build output when using a js component #266

Closed
Mikkel-T opened this issue Jan 15, 2022 · 4 comments

Comments

@Mikkel-T
Copy link

What version of astro are you using?

latest

What package manager are you using?

yarn

What operating system are you using?

Windows

Describe the Bug

Script tags with a src prop and a prop with either "true", true or {true} as the value are hidden in the build output when using a js component in the page such as a react or svelte component.
Without having gone too deep into the technical side of astro, i suspect that the issue is with rendering scripts in the SCRIPTS array created by this part of the compiler, it looks like scripts without a src prop that are passed into that array are all fine and get added to the last part of the head in the output file while scripts with a src prop never get added when a frontend framework is used in the page (More info here)
I am sure that there is much more to this bug than I have been able to find, but it looks like one of the props have to be src while the other can be named whatever you want, just as long as it has one of the values mentioned above.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-icwr81?file=src%2Fpages%2Findex.astro&on=stackblitz

@Mikkel-T
Copy link
Author

Just made another stackblitz example where it shows the compiler output. Run node full-file.js to compile the full file (The file in the other stackblitz repro example) and node just-head.js to compile just the head. Hope this will be at least helpful in some way! https://stackblitz.com/edit/node-vb7wmc?file=just-head.js

@jonathantneal
Copy link
Contributor

Yea, this does seem like a compiler issue. Something with <script> without src but with other props.

@ghost ghost assigned natemoo-re Jan 21, 2022
@jonathantneal jonathantneal transferred this issue from withastro/astro Jan 21, 2022
@natemoo-re
Copy link
Member

I'm going to try to tackle this soon. Per withastro/roadmap#41, any attribute other than hoist should mean a <script> tag remains on the page as authored.

@natemoo-re
Copy link
Member

OK I think this has been addressed? In https://github.com/withastro/rfcs/blob/main/proposals/0016-style-script-defaults.md, we introduced the is:inline directive to opt scripts out of processing, meaning you should now have full control over which scripts are included literally in the page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants