-
Notifications
You must be signed in to change notification settings - Fork 951
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
Warn if a developer is using yarn@2 with PnP #2356
Conversation
This is pretty scary junk, can you add some comments about what's going on? |
@abeisgoat good idea, many comments added. BTW I am very open to the verdict that yarn2 support is not worth it, but since I spent basically a whole day figuring this stuff out I figured I'd post the PR and we could discuss. |
Could this PR be re-reviewed? It would be lifesaver for a project I'm working on. |
@Walsker would you mind trying this branch and seeing if it actually works for your project? If it does I'm inclined to release this. Here's how to do that: # Clone this repo
git clone https://github.com/firebase/firebase-tools
cd firebase-tools
# Checkout the branch
git checkout ss-fix-yarn-2
# Build the repo locally
npm install
npm run build
# Make the `firebase` command on your system point to the local build
npm link Once you do all these steps the |
My findings, testing DevelopmentJavascript: works great
I'm sure it's possible to patch these dependencies on the cli side, however the main issue is likely that these packages have their dependencies configured in a way that works okay with a I tried the same typescript files with npm and yarn 1, both worked fine. I also confirmed that these issues were present on a fresh project configured to typescript. EmulationJavascript: works fine DeploymentIt seems that the deployment process uses npm regardless of whether you chose not to manage your packages with npm when initializing. In our case, this mean that the deployment process has no knowledge of where any packages are, so it fails any npm command it tries to run. Additional NotesThis solution doesn't support yarn workspaces, where the Unfortunately my project uses typescript, and with the addition of firebase functions I would be looking to configure it as a workspace, so I think I hit a double whammy of incompatibility 😅 |
@Walsker thank you for trying it and leaving such detailed feedback! To be totally honest the issues you've discovered go way beyond my personal knowledge of Yarn/PnP and I'm not sure how I would address them. I don't think anyone on the team knows much more about it either, since we don't use Yarn2 for anything internally right now. You also raised an important point:
This is true and will remain true for the foreseeable future. Which leads me to believe that supporting Yarn2 locally could be a bad thing. The point of these emulators is to make local development simple so that you can confidently deploy to production. If something works locally but won't deploy or won't work correctly after deploying we've actually done harm! So I think rather than try to patch all of these holes we should instead just say "Cloud Functions for Firebase does not work with Yarn2". We can use some of the things in this PR to give clear warnings to developers who try to use Yarn2 now that we know how to detect it. What do you think about that? Am I missing something? |
No you're totally correct, patching all of this would be a lot. In terms of how you say that last part, it's worth noting that I ended up enabling the |
@Walsker glad we're on the same page and thanks for clarifying the terminology. I'll update this PR to be more of a "detect and warn" thing. |
// module resolution. This feature is mostly incompatible with CF3 (prod or emulated) so | ||
// if we detect it we should warn the developer. | ||
// See: https://classic.yarnpkg.com/en/docs/pnp/ | ||
const pnpPath = path.join(frb.cwd, ".pnp.js"); |
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.
@samtstern The file is called .pnp.cjs
for new versions of yarn2. Would be good to include the new name, I didn't see the warning until I tried the deployment.
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.
@barbogast would you like to send a PR to fix this? I guess we should check for both.
Description
See #2198
Scenarios Tested
A basic yarn setup (provided in #2198) with
.pnp.js
for dependencies.Sample Commands
N/A