Today, while upgrading Sitecore JSS from 21.0.9 to 21.5.3, I encountered an unusual error that the internet couldn’t provide much help with…
> Build error occurred
TypeError: Cannot read properties of undefined (reading 'and')
at Object.webpack (C:\MyProject\rendering\node_modules\next-transpile-modules\src\next-transpile-modules.js:206:60)
at getBaseWebpackConfig (C:\MyProject\rendering\node_modules\next\dist\build\webpack-config.js:1937:32)
Searching for what went wrong didn’t yield many results and didn’t identify the issue, so I had to start thinking about what was happening with transpile. Assuming that it was coming from
next-transpile-modules which is in our package.json, I did a search for that and found that NextJS 13 has now included transpile in the core code, so the plugin is no longer necessary and this extremely helpful page explained exactly how to migrate it.
Now, on to the next thing that has changed.
I hope this has been helpful. Thanks for reading. :-)