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

Incorrect generated file paths when using Yarn 2 for virtual packages #3530

Closed
snasirca opened this issue Jun 7, 2020 · 1 comment
Closed

Comments

@snasirca
Copy link
Contributor

snasirca commented Jun 7, 2020

Yarn 2 will create virtual packages for those dependencies that have peer dependencies. The Karma plugins that we use such as karma-requirejs have a peer dependency on karma. The virtual package path that Yarn 2 generates is:

/Users/shahn/my-project-dir/.yarn/$$virtual/karma-requirejs-virtual-d16b0e1d06/0/cache/karma-requirejs-npm-0.2.5-fb217d2fa2-3.zip/node_modules/karma-requirejs/

So for example the karma-requirejs plugin will try to load the lib/adapter.js file which would resolve to this path:

/Users/shahn/my-project-dir/.yarn/$$virtual/karma-requirejs-virtual-d16b0e1d06/0/cache/karma-requirejs-npm-0.2.5-fb217d2fa2-3.zip/node_modules/karma-requirejs/lib/adapter.js

Problem is that the Karma middleware will try to generate the HTML file with all these paths but it uses the replace() function in JS and the double dollar sign $$ is a special pattern. It means replace with $. So the paths generated to put in the HTML code is:

/Users/shahn/my-project-dir/.yarn/$virtual/karma-requirejs-virtual-d16b0e1d06/0/cache/karma-requirejs-npm-0.2.5-fb217d2fa2-3.zip/node_modules/karma-requirejs/lib/adapter.js

This errors out with 404s.

There are several ways to go about fixing this but I figured I just pass in an arrow function instead and that would turn off the special patterns.

@devoto13
Copy link
Collaborator

devoto13 commented Mar 9, 2021

Fixed by #3663

@devoto13 devoto13 closed this as completed Mar 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants