What
The link checker, hyperlink, for this project currently fails when trying to parse modern JavaScript, specifically featuring Optional Chaining e.g. ?..
This is a JavaScript feature that meets our browser support so while we could revert the usage it feels inappropriate.
Instead we have skipped testing this file (4c5cea4) as the main purpose for the checking link functionality is to avoid dead links between content pages.
Initial exploration
Fallen down a little bit of a rabbit hole trying to understand why the tests are failing.
If we look at the log output from hyperlink (which would be very useful to have as a build artefact!) we can see:
not ok 30 load build/javascripts/application.js
---
operator: load
expected: "200 build/javascripts/application.js"
actual: "Unknown node type ChainExpression."
at: build/index.html:504:18 <script src="/javascripts/application.js">...</script>
...
I have no idea how that output ends up in the hyperlink output, but I'm reasonably sure it's because the new cookie-related JavaScript introduced in 5.2.0 uses optional chaining. It probably shouldn't, as I don't believe it's being transpiled, and so will cause errors in browsers that don't support optional chaining.
It looks like hyperlink (via AssetGraph) is actually parsing the JavaScript using Estraverse (and, according to this comment, acorn) to try and find other linked assets, and it can't cope with the optional chaining 🤯
Originally posted by @36degrees in #577 (comment)
Why
We have chosen to skip parsing this file so we can upgrade to the latest govuk_tech_docs gem.
Who needs to know about this
@alphagov/design-system-developers
Done when
What
The link checker, hyperlink, for this project currently fails when trying to parse modern JavaScript, specifically featuring Optional Chaining e.g.
?..This is a JavaScript feature that meets our browser support so while we could revert the usage it feels inappropriate.
Instead we have skipped testing this file (4c5cea4) as the main purpose for the checking link functionality is to avoid dead links between content pages.
Initial exploration
Originally posted by @36degrees in #577 (comment)
Why
We have chosen to skip parsing this file so we can upgrade to the latest govuk_tech_docs gem.
Who needs to know about this
@alphagov/design-system-developers
Done when