Closed 719media closed 4 years ago
Made a PR for that here https://github.com/JetBrains/svg-sprite-loader/pull/382
For what it's worth, I still get the error with this PR. May be related to https://github.com/microsoft/TypeScript/issues/19117
If I use just straight up require, or change the conditional to be if (!require.main || !require.main.require || true) {
, then vscode + eslint works just fine. I'm guessing that require.main within vscode + eslint points to the node used internally, which doesn't have webpack, which is why this jacks everything up.
PR #383 addresses my problems. I have included the PR #382 into #383. There may be another way to address this problem, but this is what I went with.
For what it's worth, I still get the error with this PR.
That's right, i updated my PR.
OK Cool. To hopefully expedite this, I've closed #383 since it is now a duplicate of #382
@kisenka Please consider this issue. There is a PR to fix it. Happy to change it in any way. I'm not sure that the supplied PR #382 fixes it in my preferred way (the PR treats the "default" webpack version as 4, instead of null or empty string), but it would be awesome to get something in there so that vscode users using linting get back on latest branch. My preferred way is #383 (very simple PR), but please provide feedback one way or another. Thank you.
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
Detecting webpack version has been dropped in svg-sprite-loader@4.2.6
Hello, I am having a problem where vscode eslint is "crapping out" after including this library. I get that this is probably a problem with vscode, and not with svg-sprite-loader.
The problem is specifically this line here: https://github.com/JetBrains/svg-sprite-loader/blob/master/lib/utils/get-webpack-version.js#L6
Which results in the vscode error
Cannot find module webpack/package.json
Because of this error, eslint effectively "breaks" inside of vscode. If I hardcode
const webpackVersion = 4
, everything works great.I'm not exactly sure why eslint inside of vscode can't "resolve" this path on installation, but this is my finding so far.
I see that webpack has a version property, but it appears this property was only added since webpack 4, and apparently you support webpack 2-4, so I understand that it is not a solution.