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

Bug with yarn berry: @vue/test-utils tried to access @vue/compiler-dom #2107

Open
stefpb opened this issue Jun 22, 2023 · 8 comments · Fixed by #2114
Open

Bug with yarn berry: @vue/test-utils tried to access @vue/compiler-dom #2107

stefpb opened this issue Jun 22, 2023 · 8 comments · Fixed by #2114
Labels
bug Something isn't working

Comments

@stefpb
Copy link

stefpb commented Jun 22, 2023

Describe the bug
with yarn berry i have an issue with the version 2.4.0.


 RUN  v0.32.2 /app

 ❯ example.test.ts (0)

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Suites 1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

 FAIL  example.test.ts [ example.test.ts ]
Error: @vue/test-utils tried to access @vue/compiler-dom (a peer dependency) but it isn't provided by your application; this makes the require call ambiguous and unsound.

Required package: @vue/compiler-dom (via "@vue/compiler-dom/package.json")
Required by: @vue/test-utils@virtual:0460f86c7587ee75dac643681550c044e8047ba46e219a5baac054fc0fea2d0af97a9bd3fe4b22de0884797215e0a1a4368bb60f9ef7087a69c4008789f4e032#npm:2.4.0 (via /app/.yarn/__virtual__/@vue-test-utils-virtual-4aca422d8c/0/cache/@vue-test-utils-npm-2.4.0-7d32a4f2ce-28b9628cf8.zip/node_modules/@vue/test-utils/dist/vue-test-utils.esm-bundler.mjs)
Ancestor breaking the chain: app@workspace:.


 ❯ makeError .pnp.cjs:11264:34
 ❯ resolveToUnqualified .pnp.cjs:12930:21
 ❯ Object.resolveToUnqualified .pnp.cjs:13173:26
 ❯ resolve$1 .pnp.loader.mjs:1977:31

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: {
  "code": "MODULE_NOT_FOUND",
  "data": {
    "brokenAncestors": [
      {
        "name": "app",
        "reference": "workspace:.",
      },
    ],
    "dependencyName": "@vue/compiler-dom",
    "issuer": "/app/.yarn/__virtual__/@vue-test-utils-virtual-4aca422d8c/0/cache/@vue-test-utils-npm-2.4.0-7d32a4f2ce-28b9628cf8.zip/node_modules/@vue/test-utils/dist/vue-test-utils.esm-bundler.mjs",
    "issuerLocator": {
      "name": "@vue/test-utils",
      "reference": "virtual:0460f86c7587ee75dac643681550c044e8047ba46e219a5baac054fc0fea2d0af97a9bd3fe4b22de0884797215e0a1a4368bb60f9ef7087a69c4008789f4e032#npm:2.4.0",
    },
    "request": "@vue/compiler-dom/package.json",
  },
  "pnpCode": "MISSING_PEER_DEPENDENCY",
}
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯

 Test Files  1 failed (1)
      Tests  no tests
   Start at  16:15:05
   Duration  894ms (transform 51ms, setup 0ms, collect 0ms, tests 0ms, environment 198ms, prepare 124ms)

To Reproduce
https://github.com/stefpb/vue-test-utils-yarn-issue

Expected behavior
test-runner passed

Related information:
Look to my minimal repo.

@stefpb stefpb added the bug Something isn't working label Jun 22, 2023
@cexbrayat
Copy link
Member

The peer dependency is marked as optional using peerDependenciesMeta (see https://github.com/vuejs/test-utils/blob/main/package.json#L72-L74)

Maybe that should not be the case as it used to compile slots (I don't remember why it was marked optional).

Would you like to open a PR to remove the optional from the pakage.json file and see if that fixes the issue? We would greatly appreciate it

@stefpb
Copy link
Author

stefpb commented Jun 28, 2023

Thanks for your answer. Now it looks like that this commit b08b1f0 leads to this problem. But yes, how i can double check this?

but now i don't know how i change this line https://github.com/stefpb/vue-test-utils-yarn-issue/blob/main/Dockerfile#L21 to say yarn to load the library from there :/

@cexbrayat
Copy link
Member

Yes, it's hard to test. But I think you can safely open a PR to remove compiler-dom from peerDependencies and peerDependenciesMeta, as the dependency is in fact mandatory.

cexbrayat added a commit to cexbrayat/vue-test-utils-next that referenced this issue Jun 30, 2023
The `processSlot` function needs `compiler-dom` so the dependency should not be marked as optional.
Fixes vuejs#2107
cexbrayat added a commit to cexbrayat/vue-test-utils-next that referenced this issue Jun 30, 2023
The `processSlot` function needs `compiler-dom` so the dependency should not be marked as optional.
Fixes vuejs#2107
lmiller1990 pushed a commit that referenced this issue Jul 1, 2023
The `processSlot` function needs `compiler-dom` so the dependency should not be marked as optional.
Fixes #2107
@stefpb
Copy link
Author

stefpb commented Aug 30, 2023

Unfortantely this Pull-Request (#2114) is not solving #2107. With 2.4.1 i have still this issue: https://github.com/stefpb/vue-test-utils-yarn-issue/tree/main

My intention was to revert b08b1f0 as you can see in #2113. Could you also restore the optional dependencies to the original state, as was intended?

@cexbrayat cexbrayat reopened this Aug 30, 2023
@lmiller1990
Copy link
Member

If this fixes it, I say we go for it. Can you make a fresh PR @stefpb? I don't really know the intricacies of optionalDeps vs peer etc, it sounds like this is something you know well and have a fix for.

stefpb added a commit to stefpb/test-utils that referenced this issue Aug 31, 2023
Otherwise you get with yarn berry an error
@vue/test-utils tried to access @vue/compiler-dom (a peer dependency)
but it isn't provided by your application; this makes the require call
ambiguous and unsound.

May cause vuejs#1958 again. May fixes vuejs#2107.
@stefpb
Copy link
Author

stefpb commented Aug 31, 2023

PR has been submitted. If a new release is available, I'll test that version here: https://github.com/stefpb/vue-test-utils-yarn-issue/blob/main/Dockerfile#L21

@RyanThomas73
Copy link

Any updates on planned fixes for this?

Checking the current package.json @vue/compiler-dom is still listed as a devDependency in lieu of either dependency or peerDependency

@urkle
Copy link

urkle commented Sep 9, 2024

In order to fix this issue with Yarn (in PNP mode) I had to add the following to my .yarnrc.yml to fake the dependencies so that things work.

packageExtensions:
  "@vue/test-utils@*":
    dependencies:
      "@vue/compiler-dom": "3.3.13"
      "@vue/server-renderer": "3.3.13"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
5 participants