Replace lodash with eta
Brought to you by:
tomkozak
Originally created by: rtritto
lodash v4.18.0 introduced the issue https://github.com/lodash/lodash/issues/6167 with lodash.template.
E.g.:
Error: Unable to generate service worker from template. 'assignWith is not defined'
at populateSWTemplate (C:\Users\<USER>\AppData\Local\Yarn\Berry\cache\workbox-build-npm-7.4.0-c84561662c-10c0.zip\node_modules\workbox-build\build\lib\populate-sw-template.js:76:15)
at writeSWUsingDefaultTemplate (C:\Users\<USER>\AppData\Local\Yarn\Berry\cache\workbox-build-npm-7.4.0-c84561662c-10c0.zip\node_modules\workbox-build\build\lib\write-sw-using-default-template.js:28:73)
at generateSW (C:\Users\<USER>\AppData\Local\Yarn\Berry\cache\workbox-build-npm-7.4.0-c84561662c-10c0.zip\node_modules\workbox-build\build\generate-sw.js:95:23)
lodash.template is also deprecated (soruce lodash.template (www.npmjs.com)):
This package is deprecated. Use https://socket.dev/npm/package/eta instead.
lodash is used only in the workbox-build package (it uses lodash.template) and it can be replaced with eta (https://www.npmjs.com/package/eta).
The @types/lodash dependency at root package.json can also be removed.
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
@google-cla I signed the CLA
Originally posted by: rtritto
FYI @swissspidy
Originally posted by: rtritto
@swissspidy all test passed, please can you review?
Ticket changed by: swissspidy
Originally posted by: rtritto
@swissspidy thanks!
PS: next time you merge a PR, I reccomend you to use
squashinstead ofmerge: by this way you'll only have 1 commit in the historyOriginally posted by: jayaddison
NB: this appears to have been due to a CLI mapping that was not updated during the release of various
lodashpackages at v4.18.0 -- a fixup release v4.18.1 has recently been published that should repair those: https://github.com/lodash/lodash/releases/tag/4.18.1Originally posted by: jayaddison
A question: is the
etapackage used here from the source repository at: https://github.com/bgub/eta/Originally posted by: rtritto
Yes
Originally posted by: jayaddison
Ok, thanks @rtritto
Originally posted by: rtritto
@jayaddison should we remove
useWith: truesetting?Originally posted by: jayaddison
@rtritto I don't have an opinion about that yet, I haven't read much about the functionality or source code of
eta.Originally posted by: jayaddison
Ah, also, I forgot: I'm a bit wary about this bugreport in
eta- to me it indicates that the template parsing it does may be fragile: https://github.com/bgub/eta/issues/337Originally posted by: rtritto
There is an opened PR
Originally posted by: jayaddison
@jayaddison
@rtritto
That PR did exist when you mentioned it @rtritto -- but I can't find it when I view the
etapull requests any more, so I am wondering if it has been closed and/or deleted.Although the usage of templates in
workboxis fairly minimal, I personally feel that staying withlodashas the templating engine -- although with thevariableoption enabled, so that JavaScriptwithstatements are not required (something that I wouldn't have learned about if not for the migration toeta) -- is probably safer.That's based on my sense that slow-moving, widely-used dependencies tend to be mature, and that faster-moving ones can be risky.
@swissspidy @rtritto what do you think?
Originally posted by: swissspidy
Would you mind opening a new issue with your proposal for visibility? Discussions on closed PRs are easily missed.
Originally posted by: jayaddison
Sensible, thanks @swissspidy; I've opened a separate thread to consider migrating back to
lodashat: [#3529]Related
Tickets: #3529