You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm the maintainer of StrykerJS, which has a plugin autodiscovery feature similar to Karma's. It isn't pnpm compatible. How should plugin discovery actually work? Let me explain.
karma is the core package; it doesn't have its plugin as a dependency (neither as a direct dependency nor a peer dependency).
karma-jasmine is a plugin; it lists karma in its peer dependencies.
karma requires karma-jasmine, because it automatically requires packages matching karma-*.
There are two problems here:
The auto-discovery works by walking the file system. This won't work with pnpm because the files are in different locations (and symlinked).
When karma uses require('karma-jasmine'), it effectively imports a dependency that isn't listed in its package.json, meaning that this probably shouldn't work.
Solving the first issue might be as simple as listing all known karma plugins and trying them out one by one. However, the second issue is more complicated to solve. What should karma do in this case? Should it import from cwd? For example, require.resolve('karma-jasmine', { paths: [process.cwd()] })? And how would that work with ESM, since we don't have an easy way to 'import from cwd'? Or is there some other way to make this work?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I'm the maintainer of StrykerJS, which has a plugin autodiscovery feature similar to Karma's. It isn't
pnpmcompatible. How should plugin discovery actually work? Let me explain.A
karmaplugins-style tool works like this:karmais the core package; it doesn't have its plugin as a dependency (neither as a direct dependency nor a peer dependency).karma-jasmineis a plugin; it lists karma in its peer dependencies.karma-jasmine, because it automatically requires packages matchingkarma-*.There are two problems here:
pnpmbecause the files are in different locations (and symlinked).karmausesrequire('karma-jasmine'), it effectively imports a dependency that isn't listed in its package.json, meaning that this probably shouldn't work.Solving the first issue might be as simple as listing all known karma plugins and trying them out one by one. However, the second issue is more complicated to solve. What should
karmado in this case? Should itimportfromcwd? For example,require.resolve('karma-jasmine', { paths: [process.cwd()] })? And how would that work with ESM, since we don't have an easy way to 'import from cwd'? Or is there some other way to make this work?Beta Was this translation helpful? Give feedback.
All reactions