-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Add preflight check to guard against wrong versions of webpack/eslint/jest higher up the tree #3771
Conversation
fs.readFileSync(maybeDepPackageJson, 'utf8') | ||
); | ||
const expectedVersion = expectedVersionsByDep[dep]; | ||
if (depPackageJson.version !== expectedVersion) { |
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.
Assuming the package is found and the version matches, do we need to continue looking up the tree?
In this case, we could splice
it out of the array.
Our dependencies should never be hoisted out of our project [except in the case of Yarn Workspaces] and this fails spectacularly currently.
I'm fine with this if we want to be cautious and support Yarn Workspaces in the future
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.
It's a shame we have to look multiple levels, because if we only needed the first occurrence we could be sly and use require
(simplifying this logic):
depsToCheck.map(name => {
try {
const { version } = require(`${name}/package.json`)
// ...
} catch (e) {
// ignored
}
})
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.
We want to support YW so I think we shouldn’t stop.
What fails?
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.
Also just one level doesn’t help. In my example we’ll still find “our own” webpack but the project above might have its copy.
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.
What fails?
react-scripts
when used with Yarn Workspaces, not this PR (what #3435 is attempting to solve).
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.
Also just one level doesn’t help. In my example we’ll still find “our own” webpack but the project above might have its copy.
You're right. This LGTM.
)} package (apart from the expected ${chalk.bold( | ||
'react-scripts' | ||
)}) installed ${chalk.bold(dep)}.\n\n` + | ||
`If nothing else helps, add ${chalk.bold( |
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.
Should we mention valid cases?
When not using YW or Lerna+Hoist, it's valid to nest like so:
/node_modules
/[email protected]
/client
/node_modules
/[email protected]
/[email protected]
/[email protected] (hoisted)
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.
Open to other wordings!
This ensures we don't try to filter NODE_PATH twice, accidentally removing the now-absolute path.
…/jest higher up the tree (#3771) * Run real scripts in local development * Add preflight check warning * I know what I am doing * Move preflight check into individual scripts This ensures we don't try to filter NODE_PATH twice, accidentally removing the now-absolute path. * Slightly tweak the wording * Fix lint
…/jest higher up the tree (#3771) * Run real scripts in local development * Add preflight check warning * I know what I am doing * Move preflight check into individual scripts This ensures we don't try to filter NODE_PATH twice, accidentally removing the now-absolute path. * Slightly tweak the wording * Fix lint
…/jest higher up the tree (#3771) * Run real scripts in local development * Add preflight check warning * I know what I am doing * Move preflight check into individual scripts This ensures we don't try to filter NODE_PATH twice, accidentally removing the now-absolute path. * Slightly tweak the wording * Fix lint
…/jest higher up the tree (#3771) * Run real scripts in local development * Add preflight check warning * I know what I am doing * Move preflight check into individual scripts This ensures we don't try to filter NODE_PATH twice, accidentally removing the now-absolute path. * Slightly tweak the wording * Fix lint
…/jest higher up the tree (#3771) * Run real scripts in local development * Add preflight check warning * I know what I am doing * Move preflight check into individual scripts This ensures we don't try to filter NODE_PATH twice, accidentally removing the now-absolute path. * Slightly tweak the wording * Fix lint
…/jest higher up the tree (#3771) * Run real scripts in local development * Add preflight check warning * I know what I am doing * Move preflight check into individual scripts This ensures we don't try to filter NODE_PATH twice, accidentally removing the now-absolute path. * Slightly tweak the wording * Fix lint
…/jest higher up the tree (facebook#3771) * Run real scripts in local development * Add preflight check warning * I know what I am doing * Move preflight check into individual scripts This ensures we don't try to filter NODE_PATH twice, accidentally removing the now-absolute path. * Slightly tweak the wording * Fix lint
…/jest higher up the tree (facebook#3771) * Run real scripts in local development * Add preflight check warning * I know what I am doing * Move preflight check into individual scripts This ensures we don't try to filter NODE_PATH twice, accidentally removing the now-absolute path. * Slightly tweak the wording * Fix lint
…/jest higher up the tree (facebook#3771) * Run real scripts in local development * Add preflight check warning * I know what I am doing * Move preflight check into individual scripts This ensures we don't try to filter NODE_PATH twice, accidentally removing the now-absolute path. * Slightly tweak the wording * Fix lint
It looks like this:
I thought about extracting it to gist but I kinda like that we can substitute the dep name right into the message. We might also want to do something similar for duplicate React.
There is an opt-out mechanism mentioned at the very end (cc @jlongster):
in
.env
file."Fixes" #1795.