Can't run service worker

I updated Ionic 2, codova and the app-scripts to the latest versions and when I un-commented the service worker block in index.html file, I get this error: “Uncaught SyntaxError: Unexpected token )” on line 27 in index.html file, and right after it, this error: “Uncaught TypeError: Cannot read property ‘insertBefore’ of null”.
It seems to me that maybe index.html and serice-worker.js aren’t transpiled (when I used es5 code in index.html file, there wasn’t an error in index.html file, but there was in service-worker.js file).
Can you please tell me how should I fix this?