Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lodash is modified for all npm packages using the same lodash version #17

Closed
axten opened this issue Apr 25, 2018 · 2 comments · Fixed by #18 or #23
Closed

lodash is modified for all npm packages using the same lodash version #17

axten opened this issue Apr 25, 2018 · 2 comments · Fixed by #18 or #23

Comments

@axten
Copy link

axten commented Apr 25, 2018

see gruntjs/grunt-legacy-log#26
grunt-legacy-util has the same problem and overrides the lodash functions for all npm packages using the same lodash version!

// Mixin Underscore.string methods.
_.str = require('underscore.string');
_.mixin(_.str.exports());

@shama
Copy link
Member

shama commented Apr 26, 2018

Wow nice find, thanks a bunch for digging into this!

grunt-legacy-log will be easy to fix as it doesn't really use those libraries. Although grunt-legacy-util purposely mixins the underscore.string functions into lodash.

In other words, if we remove _.mixin(_.str.exports()); it will break Gruntfiles relying on those functions: grunt.util._.clean(' foo bar'). So we'll need to probably build our own object rather than mixing into the existing lodash one. Let me do some testing and chat with the other maintainers and get a fix out asap.

@ntwb
Copy link
Contributor

ntwb commented Apr 26, 2018

Thanks @shama 👍

shama added a commit that referenced this issue Apr 26, 2018
…tside instances.

See: #17

If grunt-legacy-util has the same version of lodash as another library
outside of Grunt, underscore.string overwrites the lodash same named lodash
functions.
vladikoff pushed a commit that referenced this issue May 21, 2018
Fixes GH-17

The Object.create solution I implemented #18 wasn't a good one. As it breaks calling the lodash function directly: grunt.util._()

Lodash has a function to create our own instance though: runInContext which is a better solution and still fixes the original issue so we dont pollute other lodash instances.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants