svg-sprite-loader icon indicating copy to clipboard operation
svg-sprite-loader copied to clipboard

webpack should be a peer dependency

Open Eli-Black-Work opened this issue 4 years ago • 3 comments

svg-sprite-loader uses webpack but doesn't declare it as a peer dependency, which generates warnings when using the Yarn Berry's PnP (plug and play) feature:

Error: svg-sprite-loader tried to access webpack, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

To fix this problem, I believe svg-sprite-loader should list webpack in its peerDependencies or optionalDependencies section.

Eli-Black-Work avatar Apr 12 '21 10:04 Eli-Black-Work

As a temporary workaround, it's possible to add this to one's .yarnrc.yml file:

# svg-sprite-loader depends on webpack but doesn't yet list it as a peer dependency.
#
# This gives us an error while compiling, so we patch svg-sprite-loader to add webpack as a peerDependency.
#
# Bug report: https://github.com/JetBrains/svg-sprite-loader/issues/450
packageExtensions:
    svg-sprite-loader@*:
        peerDependencies:
            "webpack": "*"

Eli-Black-Work avatar Apr 12 '21 10:04 Eli-Black-Work

Has it been solved?

zhibin2015 avatar Mar 16 '22 12:03 zhibin2015

@zhibin2015 For a workaround, see the comment directly above yours 🙂

Eli-Black-Work avatar Mar 17 '22 02:03 Eli-Black-Work