-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Make providesModuleNodeModules ignore nested node_modules directories #3984
Conversation
2025924
to
7592a94
Compare
Updates the `_isNodeModules` function so that nested `node_modules` subdirectories of whitelisted npm packages are not whitelisted. This is causing problems because arbitrary npm packages that aren't explicitly whitelisted can cause Haste map collisions. Test plan: Added unit tests that were failing before and ensure that they are passing now in addition to older unit tests.
7592a94
to
a77e2d2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks. I've only got a little uncertainty about the Regexp usage, lemme know what you think
return !match || match.length > 1; | ||
const whitelist = this._whitelist; | ||
const match = whitelist.exec(filePath); | ||
const matchEndIndex = whitelist.lastIndex; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs says lastIndex
stays zero if the regexp doesn't have the g
flag. Isn't this a problem? Can we use the result match
to figure it out instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regexp always has the g
flag in this case, we control that here: https://github.com/ide/jest/blob/a77e2d255af4fbd7f6057664c3311aed3255b092/packages/jest-haste-map/src/index.js#L107
We could use match[0].length
, I think both approaches are good enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
return !match || match.length > 1; | ||
const whitelist = this._whitelist; | ||
const match = whitelist.exec(filePath); | ||
const matchEndIndex = whitelist.lastIndex; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
I wanted to investigate the breakage in CircleCI, but it loads forever and doesn't show me the error logs. I'll try locally then ship it. |
Tests are passing locally, merging then. |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Updates the
_isNodeModules
function so that nestednode_modules
subdirectories of whitelisted npm packages are not whitelisted. This is causing problems because arbitrary npm packages that aren't explicitly whitelisted can cause Haste map collisions.Test plan: Added unit tests that were failing before and ensure that they are passing now in addition to older unit tests.