Menu

#3489 Replace lodash with eta

closed
nobody
None
2026-06-04
2026-04-01
Anonymous
No

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.

Discussion

  • Anonymous

    Anonymous - 2026-04-01

    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.

     
  • Anonymous

    Anonymous - 2026-04-01

    Originally posted by: rtritto

    @google-cla I signed the CLA

     
  • Anonymous

    Anonymous - 2026-04-10

    Originally posted by: rtritto

    FYI @swissspidy

     
  • Anonymous

    Anonymous - 2026-04-27

    Originally posted by: rtritto

    @swissspidy all test passed, please can you review?

     
  • Anonymous

    Anonymous - 2026-04-27

    Ticket changed by: swissspidy

    • status: open --> closed
     
  • Anonymous

    Anonymous - 2026-04-27

    Originally posted by: rtritto

    @swissspidy thanks!

    PS: next time you merge a PR, I reccomend you to use squash instead of merge: by this way you'll only have 1 commit in the history

     
  • Anonymous

    Anonymous - 2026-04-28

    Originally posted by: jayaddison

    NB: this appears to have been due to a CLI mapping that was not updated during the release of various lodash packages 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.1

     
  • Anonymous

    Anonymous - 2026-05-07

    Originally posted by: jayaddison

    A question: is the eta package used here from the source repository at: https://github.com/bgub/eta/

     
  • Anonymous

    Anonymous - 2026-05-07

    Originally posted by: rtritto

    A question: is the eta package used here from the source repository at: https://github.com/bgub/eta/

    Yes

     
  • Anonymous

    Anonymous - 2026-05-08

    Originally posted by: jayaddison

    A question: is the eta package used here from the source repository at: https://github.com/bgub/eta/

    Yes

    Ok, thanks @rtritto

     
  • Anonymous

    Anonymous - 2026-05-08

    Originally posted by: rtritto

    @jayaddison should we remove useWith: true setting?

     
  • Anonymous

    Anonymous - 2026-05-08

    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.

     
  • Anonymous

    Anonymous - 2026-05-08

    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/337

     
  • Anonymous

    Anonymous - 2026-05-08

    Originally posted by: rtritto

    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: [bgub/eta#337](https://github.com/bgub/eta/issues/337)

    There is an opened PR

     
  • Anonymous

    Anonymous - 2026-06-03

    Originally posted by: jayaddison

    @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: [bgub/eta#337](https://github.com/bgub/eta/issues/337)

    @rtritto

    There is an opened PR

    That PR did exist when you mentioned it @rtritto -- but I can't find it when I view the eta pull requests any more, so I am wondering if it has been closed and/or deleted.

    Although the usage of templates in workbox is fairly minimal, I personally feel that staying with lodash as the templating engine -- although with the variable option enabled, so that JavaScript with statements are not required (something that I wouldn't have learned about if not for the migration to eta) -- 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?

     
  • Anonymous

    Anonymous - 2026-06-03

    Originally posted by: swissspidy

    Would you mind opening a new issue with your proposal for visibility? Discussions on closed PRs are easily missed.

     
  • Anonymous

    Anonymous - 2026-06-04

    Originally posted by: jayaddison

    Sensible, thanks @swissspidy; I've opened a separate thread to consider migrating back to lodash at: [#3529]

     

    Related

    Tickets: #3529


Log in to post a comment.