JetBrains / svg-sprite-loader

Webpack loader for creating SVG sprites.
MIT License
2.02k stars 270 forks source link

fix: Remove require override #397

Closed sidharthachatterjee closed 4 years ago

sidharthachatterjee commented 4 years ago

What kind of change does this PR introduce? (bugfix, feature, docs update, improvement)

bugfix

What is the current behavior? (You can also link to an open issue here)

Hello! Gatsby core team maintainer here 🙂

The plugin breaks when used with gatsby and gatsby-plugin-svg-sprite-loader

To be clear, this works fine when gatsby-cli is run from the site modules (./node_modules/.bin/gatsby) and does not when a globally installed gatsby-cli is run. I did some digging and this is because require.main (which is what is used before this PR) is an instance of Module with paths set relative to the globally installed binary versus (correctly) being relative to the site's folder (where webpack is indeed installed)

I wasn't sure why this was added and wanted to open this and discuss this!

What is the new behavior (if this is a feature change)?

This seems to be resolved with this change

Does this PR introduce a breaking change?

No

Please check if the PR fulfills contributing guidelines

kisenka commented 4 years ago

Hello! Detecting webpack version in that way was very bad idea, so I've removed it in svg-sprite-loader@4.2.6. Did you tried this version?

sidharthachatterjee commented 4 years ago

Yup, that does seem to fix it! Thanks!