Babel - unknown Statement of type "ForOfStatement"
shadowfoxish opened this issue · 2 comments
React 17 app, with webpack/babel and all that.
When I try to build/run the app with oidc-client-ts, I get the following error.
There is a work around regarding adding a 7 year old babel plugin, which introduces a deprecated dependency on core-js. I wonder if the code could be adjusted to remove the ForOfStatement in lieu of different syntax maybe?
Compiled with problems:
ERROR in ./node_modules/oidc-client-ts/dist/esm/oidc-client-ts.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: C:\Code\Frontend\node_modules\oidc-client-ts\dist\esm\oidc-client-ts.js: unknown Statement of type "ForOfStatement"
at Ep.explodeStatement (C:\Code\Frontend\node_modules\regenerator-transform\lib\emit.js:593:13)
at C:\Code\Frontend\node_modules\regenerator-transform\lib\emit.js:325:12
at Array.forEach (<anonymous>)
at Ep.explodeStatement (C:\Code\Frontend\node_modules\regenerator-transform\lib\emit.js:324:22)
at Ep.explode (C:\Code\Frontend\node_modules\regenerator-transform\lib\emit.js:282:40)
at PluginPass.<anonymous> (C:\Code\Frontend\node_modules\regenerator-transform\lib\visit.js:108:17)
at PluginPass.<anonymous> (C:\Code\Frontend\node_modules\regenerator-transform\lib\util.js:28:17)
at newFn (C:\Code\Frontend\node_modules\@babel\traverse\lib\visitors.js:177:21)
at NodePath._call (C:\Code\Frontend\node_modules\@babel\traverse\lib\path\context.js:53:20)
at NodePath.call (C:\Code\Frontend\node_modules\@babel\traverse\lib\path\context.js:40:17)
Which version are you using, i do not intend to fix 7 year bugs in babel. Maybe you can patch that loop on your side. About which loop do we talk anyway?
Hi Pamapa, I managed to get it working "normally".
When I initially received this error, I went looking for a solution by web search, and found this comment; parcel-bundler/parcel#1269 (comment)
That lead me to the 7-year old thing.
This particular problem has been corrected more formally, by adding "@babel/plugin-transform-for-of" to the babel plugins section, and referencing "@babel/plugin-transform-for-of": "^7.24.7", in devDependencies in packages.json.
Specifically regarding your question on which bit of code was problematic, I don't know. Babel (and honestly the ts-js transpilation concept) is not something I'm well versed in.