Weird transpilation bug
First I removed Babel plugin I added to my
preact-cli thinking it was causing problems. That didn’t fix it so I tried to make a reduced test case: pulled clean
preact-cli and wrote minimal service worker. On build, everything worked. Further exploration pointed towards a difference in my
preact-cli by default supports 0.25% of active browsers while my project did only 0.75%.
I cross-referenced the difference in browser support by running
npx browserslist and then kept adding additional browsers one by one to my config. Finally, it came down to Samsung 4. A very old browser that causes
babel-env to add a bunch of transforms and plugins just for it.
babel-env example repo and modified it so I could get the output of plugins used solely by Samsung 4. Looking at the plugins list, few stood out immediately so I tried adding those to my build (same way I added plugin I initially removed).
In the end, adding
transform-arrow-functions fixed the issue. That fix is not optimal since arrow functions are widely supported but transpilation fixed scoping issue I had. I suspect that issue might be related to the way
I reported an issue to