Closed rschristian closed 2 years ago
Latest commit: 4494e19a52e1cf11c1849b6d66ebc2181dab001d
The changes in this PR will be included in the next version bump.
Not sure what this means? Click here to learn what changesets are.
[Click here if you're a maintainer who wants to add another changeset to this PR](https://github.com/preactjs/wmr/new/fix/script-tag-prerender?filename=.changeset/perfect-apes-tell.md&value=---%0A%22wmr%22%3A%20patch%0A---%0A%0Afix%3A%20First%2C%20not%20last%2C%20non-external%20script%20in%20HTML%20should%20have%20prerender()%0A)
oooof, yeah. TBH that's a solid argument in favor of flipping the error message. I can think of cases where first script is likely not the correct one (polyfills), but I can also think of cases where the last script is incorrect (analytics).
Size Change: +4 B (0%)
Total Size: 806 kB
Filename | Size | Change |
---|---|---|
packages/wmr/wmr.cjs |
767 kB | +4 B (0%) |
Will do that instead (only thought of it after I pushed, whoops).
Analytics will probably end up being external more often than not, ensuring they get skipped. So long as the error messages matches the behavior it should be an easy and quick correction anyways.
The first script tag in the file should be assumed to have a
prerender()
, however, due to the loop continuing even after the first non-external script tag is found, it was actually the last script tag that was used and would need to haveprerender()
.It should be noted that this behavior has existed for the past 9 months, and fixing it could potentially cause someone's setup to break. We could just flip the error message/comments instead?
https://github.com/preactjs/wmr/blob/039f79925ecab2e277d32e1f4f7341d38a222b59/packages/wmr/src/lib/prerender.js#L106