Crashes on Node 22.12.0
Appears to cause a crash on Node 22.12.0 when used as a dependency. It works on 22.9.0 if that helps.
2024-12-10T09:43:38.151622+00:00 app[web.1]: ReferenceError: self is not defined
2024-12-10T09:43:38.151623+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/accessible-autocomplete/dist/accessible-autocomplete.min.js:1:226)
2024-12-10T09:43:38.151623+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1565:14)
2024-12-10T09:43:38.151623+00:00 app[web.1]: at Object..js (node:internal/modules/cjs/loader:1708:10)
2024-12-10T09:43:38.151623+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:1318:32)
2024-12-10T09:43:38.151623+00:00 app[web.1]: at Function._load (node:internal/modules/cjs/loader:1128:12)
2024-12-10T09:43:38.151624+00:00 app[web.1]: at TracingChannel.traceSync (node:diagnostics_channel:322:14)
2024-12-10T09:43:38.151624+00:00 app[web.1]: at wrapModuleLoad (node:internal/modules/cjs/loader:219:24)
2024-12-10T09:43:38.151624+00:00 app[web.1]: at node:internal/modules/esm/translators:229:5
2024-12-10T09:43:38.151624+00:00 app[web.1]: at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:196:7)
2024-12-10T09:43:38.151624+00:00 app[web.1]: at ModuleJobSync.runSync (node:internal/modules/esm/module_job:395:35)
2024-12-10T09:43:38.151624+00:00 app[web.1]:
2024-12-10T09:43:38.151625+00:00 app[web.1]: Node.js v22.12.0
Tested via these dependencies in the prototype kit:
"@x-govuk/govuk-prototype-components": "3.0.4",
"govuk-country-and-territory-autocomplete": "2.0.0",
"hmrc-frontend": "6.4.0"
tested with version 3.0.1 of autocomplete
the accessible autocomplete package.json looks like this:
{
"name": "accessible-autocomplete",
"version": "2.0.4",
"main": "dist/accessible-autocomplete.min.js",
with a reference to the file causing the issue - might that be related?
I'm getting the same problem with Vite / SvelteKit (Node v20.17.0). I was able to get round it by disabling server-side rendering for the page where I'm using the accessible autocomplete, but obviously that isn't ideal.
+1 can't use it right now in a Gatsby project, please make accessible-autocomplete SSR friendly 🙏
cc @owenatgov
I think that the problem resides in polyfills used to build the library (see also https://github.com/pixijs/pixijs/issues/7703#issuecomment-899119760). I tried to clone and build accessible-autocomplete using the following .browserlistrc configuration and self variable disappears.
last 6 Chrome versions
last 6 Firefox versions
last 6 Edge versions
last 2 Samsung versions