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
However, since external command packages, such as @webpack-cli/info, aren't declared as a dependency, @webpack-cli/package-utils shouldn't be able to require them.
If Yarn cannot resolve the dependency, it falls back to the top level if pnpFallbackMode is depenencies-only (default) or all. So it's possible to resolve external commands, but not default commands included in the webpack-cli.
For instance, if the dependency tree of a project is:
webpack xxx works but webpack info doesn't work because @webpack-cli/package-utils cannot resolve @webpack-cli/info. webpack xxx doesn't work if pnpFallbackMode: none.
@webpack-cli/package-utils cannot resolve external commands with pnpFallbackMode: none
What is the current behavior?
$ webpack info
Error: @webpack-cli/package-utils tried to access @webpack-cli/info, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
Required package: @webpack-cli/info (via "@webpack-cli/info")
Required by: @webpack-cli/package-utils@npm:1.0.1-alpha.4 (via @webpack-cli-package-utils/node_modules/@webpack-cli/package-utils/lib/)
Require stack:
- @webpack-cli-package-utils/node_modules/@webpack-cli/package-utils/lib/packageUtils.js
- @webpack-cli-package-utils/node_modules/@webpack-cli/package-utils/lib/index.js
- webpack-cli/lib/commands/ExternalCommand.js
- webpack-cli/lib/utils/arg-parser.js
- webpack-cli/lib/webpack-cli.js
- webpack-cli/lib/bootstrap.js
- webpack-cli/bin/cli.js
- webpack/bin/webpack.js
at internalTools_makeError (.pnp.js:21227:34)
at resolveToUnqualified (.pnp.js:22185:23)
at resolveRequest (.pnp.js:22277:29)
at Object.resolveRequest (.pnp.js:22343:26)
at Function.external_module_.Module._resolveFilename (.pnp.js:21460:34)
at Function.external_module_.Module._load (.pnp.js:21325:48)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (v8-compile-cache/v8-compile-cache.js:161:20)
at packageExists (@webpack-cli/package-utils/lib/packageUtils.js:58:9)
at Function.run (webpack-cli/lib/commands/ExternalCommand.js:27:22)
[webpack-cli] The command moved into a separate package: @webpack-cli/info
? Would you like to install @webpack-cli/info? (That will run yarn add -D @webpack-cli/info)
To Reproduce
yarn set version berry
yarn init
echo -e 'packageExtensions:\n "@webpack-cli/package-utils@*":\n dependencies:\n "cross-spawn": "^7.0.0"'>> .yarnrc.yml # Workaround for issue already fixed in master
yarn add -D webpack@^5.0.0-rc.0 webpack-cli@^4.0.0-beta.9
yarn webpack info
Expected behavior webpack info and webpack xxx (xxx is an external command) to run
The text was updated successfully, but these errors were encountered:
Describe the bug
packageExists
in@webpack-cli/package-utils
is used to resolve external commands:webpack-cli/packages/package-utils/src/packageUtils.ts
Lines 64 to 71 in a515b76
However, since external command packages, such as
@webpack-cli/info
, aren't declared as a dependency,@webpack-cli/package-utils
shouldn't be able to require them.This is especially an issue for Yarn 2 PnP as it requires all dependencies to be explicitly declared to link them (Yarn rulebook).
If Yarn cannot resolve the dependency, it falls back to the top level if
pnpFallbackMode
isdepenencies-only
(default) orall
. So it's possible to resolve external commands, but not default commands included in thewebpack-cli
.For instance, if the dependency tree of a project is:
webpack xxx
works butwebpack info
doesn't work because@webpack-cli/package-utils
cannot resolve@webpack-cli/info
.webpack xxx
doesn't work ifpnpFallbackMode: none
.To summarize:
@webpack-cli/package-utils
cannot resolve default commands (fix: declare default commands as optional peer dependencies #1816)@webpack-cli/package-utils
cannot resolve external commands withpnpFallbackMode: none
What is the current behavior?
To Reproduce
Expected behavior
webpack info
andwebpack xxx
(xxx
is an external command) to runThe text was updated successfully, but these errors were encountered: