svgr: [v6.0.0] TypeError: this.getOptions is not a function
🐛 Bug Report
Last release v6.0.0 provoked the following issue : TypeError: this.getOptions is not a function
Which is referring to the following call:
To Reproduce
Steps to reproduce the behavior:
- Compile any React 17 web project
Expected behavior
The compilation process fails and throws an exception :
Failed to compile. TypeError: this.getOptions is not a function
This unexpected behavior appeared right after upgrading to v6.0.0, it is most likely related to an incompatibility issue with the 3.0.0+ version of loader-utils which brought the following breaking change :
removed getOptions in favor loaderContext.getOptions (loaderContext is this inside loader function),
note - special query parameters like ?something=true is not supported anymore,
if you need this please do it on loader side, but we strongly recommend avoid it, as alternative you can use ?something=1 and handle 1 as true
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 6
- Comments: 19 (6 by maintainers)
Commits related to this issue
- perf: remove useless loader-utils package Related #631 — committed to gregberge/svgr by gregberge 3 years ago
- use webpack5 in storybook https://github.com/gregberge/svgr/issues/631 を解決するためにはwebpack5にあげれば良いとのこと — committed to MH4GF/log.mh4gf.dev by MH4GF 2 years ago
- downgrade @svgr/webpack to support SVG into Storybook using the latest version introduces this [issue](https://github.com/gregberge/svgr/issues/631) — committed to oceanprotocol/market by EnzoVezzaro 2 years ago
I have exact same problem. Going back to 5.5.0 fixed it for now.
I had the same issue here while trying to use svgr with
@storybook/react@^6.4.9. The storybook’s docs said it fully upgraded to webpack@5 , but I still see webpack@4 references in my .lock fileCan be solved by forcing storybook to use webpack 5: https://storybook.js.org/blog/storybook-for-webpack-5/
Hello @gregberge , I finally understood what was going on.
create-react-app, which is used to compile React apps, is usingwebpack 4behind the scene, so even if I hadwebpack 5dependency explicitly set on my ownpackage.json, it was not used during the compilation. I had to upgradecreate-react-appto @next which is being developed uponwebpack 5. The final word issvgris perfectly fine and we can definitely close this issue.Hello @gregberge , Actually I’m already using Webpack 5 :
npm view webpack:Good to hear, thanks!
Hello, the new loader is only compatible with webpack 5, please upgrade or stay in v5.x.