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

<script> tags require specific ordering of attributes or else become type="module-shim" #555

Closed
1 of 5 tasks
thescientist13 opened this issue Apr 13, 2021 · 0 comments · Fixed by #556
Closed
1 of 5 tasks
Assignees
Labels
bug Something isn't working CLI P0 Critical issue that should get addressed ASAP v0.10.1
Milestone

Comments

@thescientist13
Copy link
Member

Type of Change

  • New Feature Request
  • Documentation / Website
  • Improvement / Suggestion
  • Bug
  • Other (please clarify below)

Summary

Noticed as part of #554 that if you didn't organize the attributes of your <script> tag a specific way, your script tag would come out with the wrong type in production.

For example, this works

<script type="module" src="..."></script>
<script src="..." type="module"></script>

will come out as type="module-shim" in production builds (and so of course won't load / work)

<script src="..." type="module-shim"></script>

Details

This is because in plugin-standard-thml, the regex expects a pattern like this:

/<script type="module-shim"/

Which mean it will only handle <script> tags of the type attribute comes first. Matching it to the pattern in plugin-node-modules would fix it.

/type="module-shim"/

One thought is to scope this kind of change to only what is in the <head> tag, to avoid clobbering a user's content.

@thescientist13 thescientist13 added bug Something isn't working P0 Critical issue that should get addressed ASAP CLI labels Apr 13, 2021
@thescientist13 thescientist13 added this to the 1.0 milestone Apr 13, 2021
@thescientist13 thescientist13 self-assigned this Apr 13, 2021
@thescientist13 thescientist13 changed the title <script> tags require specific ordering of attributes or else become type="module-shim <script> tags require specific ordering of attributes or else become type="module-shim" Apr 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working CLI P0 Critical issue that should get addressed ASAP v0.10.1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant