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

Lockfile generated by @nx/vite:build is invalid with patched dependencies present #18012

Closed
1 of 4 tasks
rosettaroberts-impact opened this issue Jul 6, 2023 · 4 comments · Fixed by #18700
Closed
1 of 4 tasks
Assignees

Comments

@rosettaroberts-impact
Copy link

Current Behavior

When using Yarn 3 in a Nx workspace, running @nx/vite:build with generateLockfile generates a lockfile that contains an empty package name when a dependency is patched.

"":
  version: 0.27.0
  resolution: "@growthbook/growthbook@patch:@growthbook/growthbook@npm%3A0.27.0#./.yarn/patches/@growthbook-growthbook-npm-0.27.0-3197004b39.patch::version=0.27.0&hash=07ade4&locator=%40nx-vite-lockfile-issue%2Fsource%40workspace%3A."
  dependencies:
    dom-mutator: ^0.5.0
  checksum: 3f972c2c8f9ee4667c56457a400b17f9dd5ae2c26e32213704a9eb7855bc2605866e41935dbf94389d64f7f11fdb716445cf484a42051af2bc2665b299b787c7
  languageName: node
  linkType: hard

Empty package names are invalid and cause yarn to error out when they are present:

Internal Error: Invalid descriptor ()
    at WA (/home/rose/.volta/tools/image/yarn/3.5.1/bin/yarn.js:390:24431)
    at je.setupResolutions (/home/rose/.volta/tools/image/yarn/3.5.1/bin/yarn.js:439:1283)
    at async je.find (/home/rose/.volta/tools/image/yarn/3.5.1/bin/yarn.js:436:1518)
    at async yu.execute (/home/rose/.volta/tools/image/yarn/3.5.1/bin/yarn.js:499:11751)
    at async yu.validateAndExecute (/home/rose/.volta/tools/image/yarn/3.5.1/bin/yarn.js:345:664)
    at async Hn.run (/home/rose/.volta/tools/image/yarn/3.5.1/bin/yarn.js:359:2057)
    at async Hn.runExit (/home/rose/.volta/tools/image/yarn/3.5.1/bin/yarn.js:359:2241)
    at async i (/home/rose/.volta/tools/image/yarn/3.5.1/bin/yarn.js:446:12054)
    at async t (/home/rose/.volta/tools/image/yarn/3.5.1/bin/yarn.js:446:10283)

Expected Behavior

@nx/vite:build should be generating valid yarn.lock files when one of the dependencies is patched.

GitHub Repo

https://github.com/rosettaroberts-impact/nx-vite-lockfile-issue

Steps to Reproduce

Ensure that yarn 3 and node 18 are installed:

git clone https://github.com/rosettaroberts-impact/nx-vite-lockfile-issue.git
yarn dlx nx build app

cd dist/apps/app
# Yarn errors out because the generated lock file is invalid
yarn

Nx Report

Node   : 18.16.1
   OS     : linux-x64
   yarn   : 3.6.1
   
   nx (global)        : 16.5.0
   nx                 : 16.5.0
   @nx/js             : 16.5.0
   @nx/linter         : 16.5.0
   @nx/workspace      : 16.5.0
   @nx/cypress        : 16.5.0
   @nx/eslint-plugin  : 16.5.0
   @nx/vite           : 16.5.0
   @nx/web            : 16.5.0
   typescript         : 5.1.6

Failure Logs

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

This likely has the same underlying cause as #17873.

@meeroslav
Copy link
Contributor

Thank you @rosettaroberts-impact for reporting this.

Patching was not tested, so there are likely some bugs. I'll look into it as soon as possible.

@meeroslav
Copy link
Contributor

Please also commit your .yarn folder and .yarnrc.yml files? Otherwise, we can't use this repo for debugging.

@meeroslav
Copy link
Contributor

Ok, I managed to reproduce the steps. Please note that patches should be bundled and not included in the target package.json and the lock file.

Even if the lock would be properly generated, you would still need to copy over the patch files, which does not happen currently automatically.

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants