I upgraded @rails/webpacker version in package.json from 4.0.2 to 5.4.3, and node version from 10.16.0 to 12.13.1 and got the following error in the browser console of my rails application after doing yarn install:
Error: Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: dist/index.es.js: unknown Statement of type "ForOfStatement"
at Emitter.Ep.explodeStatement (:3000/node_modules/regenerator-transform/lib/emit.js:593:13)
at Object.getConstructor (fromRequireContextWithGlobalFallback.js:15:1)
at Object.mountComponents (index.js:92:1)
(anonymous) @ fromRequireContextWi…lobalFallback.js:21
mountComponents @ index.js:92
./node_modules/react_ujs/react_ujs/index.js.ReactRailsUJS.handleMount @ index.js:153
Taking hints from the stack trace i have tried upgrading in package.json:
"@babel/polyfill": "^7.2.5",
"@babel/preset-react": "^7.0.0",
"react_ujs": "^2.4.4",
but no luck yet. Has anyone else experienced this before? Any tips to debug this further? To me, this looks like an incompatibility between Node 12, webpacker 5.4.3 and babel/react_ujs but I'm unable to debug. Looking forward to some help.
Some additional info if it helps:
node --version v12.13.0
rails -v Rails 6.0.5.1