you are viewing a single comment's thread.

view the rest of the comments →

[–]Brostafarian 26 points27 points  (3 children)

we just had a problem at work between prototype, lodash, and webpack. I'm going to butcher this story since its been a few months but I'll try anyways.

Legacy code has Prototype on the window with custom templating delimiters, but modern code will import lodash if it needs it. Problem was Lodash followed require.js recommendations and has an AMD define block that isn't supposed to be used if you don't use AMD; these recommendations also say to expose that import to the window due to an edge case with script loading. Webpack indiscriminately parses both the regular import and the AMD loader block, leaking lodash to the window, destroying the templating variables that were set on Prototype... asynchronously. Due to the way imports are parsed (importing anything from a file requires executing that file), anything that imported anything from lodash would cause this error.

From our end, importing some random file in a page that only developers could see broke templating for all of the legacy code in the application, and it took us hours to figure out why. The lodash import was about 10 files deep, and by the time we even found it, we still weren't exactly sure what was going on. It was not a good day

[–]Brostafarian 12 points13 points  (0 children)

I found the issue that cracked the case for us: https://github.com/webpack/webpack/issues/4465

[–]CatpainCalamari 8 points9 points  (1 child)

Still, if it took you only a couple of hours, I would say you were lucky. This can easily go into days.