Originally created by: rtritto
This PR refactors the Eta template rendering configuration within workbox-build by removing the useWith: true option.
Using with () { ... } blocks (which useWith relies on) is generally considered bad practice in modern JavaScript due to performance implications, potential scoping issues, and incompatibility with Strict Mode.
To accommodate this change, the service worker template (sw-template.ts) has been updated to explicitly reference injected variables using the default it. object property, ensuring compatibility and cleaner variable resolution during template compilation.
packages/workbox-build/src/lib/populate-sw-template.ts: Removed useWith: true from the Eta initialization options.packages/workbox-build/src/templates/sw-template.ts: Updated all template variable interpolations (e.g., <%= importScripts %>, <%= use(...) %>) to use the explicit it. prefix (e.g., <%= it.importScripts %>, <%= it.use(...) %>).with () {} in JavaScript slows down execution and can cause confusing bugs from https://dev.to/bgub/i-built-a-js-template-engine-3x-faster-than-ejs-lj8
Originally posted by: google-cla[bot]
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
View this failed invocation of the CLA check for more information.
For the most up to date status, view the checks section at the bottom of the pull request.
Originally posted by: rtritto
FYI @jayaddison
Originally posted by: jayaddison
Thanks @rtritto. Could we enable strict mode for the template evaluation?
Originally posted by: rtritto
Nice catch, I did the commit
Originally posted by: rtritto
Removed the commit.