Svg-sprite-loader: Detecting webpack version via require-ing it works wrong in some tricky cases

Created on 24 Jan 2019  路  11Comments  路  Source: JetBrains/svg-sprite-loader

It's a bug relates to #248.

Here svg-sprite-loader tries to detect webpack version by require-ing it:
https://github.com/kisenka/svg-sprite-loader/blob/master/lib/utils/get-webpack-version.js#L2

But this doesn't work if by some reason we have different webpack versions. I think it'd most reliable to analyze current webpack instance instead which loader is running on top.

Most helpful comment

Hello,

The same error Error: Cannot find module 'webpack/package.json' appears in VSCode with this plugin each time one opens a new js file. I had the version 4.1.6, downgrading to 4.1.3 made the error disappear.

All 11 comments

This change breaks gatsby-plugin-svg-sprite. It works until v4.1.3

Gatsby allows to override webpack config to add loaders such as this one. Although after your change in 4.1.4, the same line breaks with the error Error: Cannot find module 'webpack/package.json'

Hello,

The same error Error: Cannot find module 'webpack/package.json' appears in VSCode with this plugin each time one opens a new js file. I had the version 4.1.6, downgrading to 4.1.3 made the error disappear.

Getting the same error as @DanielaValero in VS Code while running ESLint with a webpack resolver.

Hi @DanielaValero ,

Please how did you downgrade to 4.1.3, because I cannot find svg-sprite-loader in my package.json I have gatsby project

Same error as @DanielaValero . Currently using svg-sprite-loader 4.2.1.

Yup, the VS Code error unfortunately persist in 4.2.1 which includes #352.

Actually that downgrading thing did not really work... I still have the problem, it has been so long that when is fixed I will miss the false negatives from the lintin notifications panel in VS Code, and the import statements...

@agigox @Klutch27 @martinkadlec0 @DanielaValero

Using autodetecting webpack version was very bad idea. I've published alpha version without detecting webpack version, could some of you guys help me with trying it out?

npm install svg-sprite-loader@drop-webpack-version-detector

@kisenka
I had this issue with my reproduction repo of #364, which is an Angular CLI project.
I tried your fixed version on a Windows machine and it worked with this repo.

Published [email protected] without version detecting, but checking features instead.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

evgenyrodionov picture evgenyrodionov  路  4Comments

whois42 picture whois42  路  5Comments

alxpsr picture alxpsr  路  4Comments

suamikim picture suamikim  路  5Comments

no-more picture no-more  路  7Comments