I have migrated react app to Symfony and now getting SyntaxError: invalid identity escape in regular expression. App worked before compiled by yarn but now with encore its stucked on this error. I try adding babel plugins
.configureBabel(function(babelConfig) {
babelConfig.plugins.push('transform-class-properties');
babelConfig.plugins.push('@babel/plugin-proposal-class-properties');
babelConfig.plugins.push(["@babel/plugin-proposal-unicode-property-regex", { "useUnicodeFlag": false }]);
})
but it wasn't help. I am trying it for week now. Can someone help me?
Hi,
Can you post the whole stack trace (if available) or/and provide a reproduction repo?
Did you enable react preset (doc)?
The error is thrown by Firefox console and points on first line of vendor-app.js I simplified project to minimum and it's still here. You can look at it here. I find out, that when I compile only react app by yarn, it works. But compiling it with Symfony docs doesn't work
Hi @pajasry,
Since the error is coming from vendors~app.js it may be caused by a RegExp used in a vendor (those are not transpiled by Babel by default).
After looking at the content of your package.json could you try this?
Encore.configureBabel(function(babelConfig) {
babelConfig.plugins.push('transform-class-properties');
babelConfig.plugins.push('@babel/plugin-proposal-class-properties');
babelConfig.plugins.push(["@babel/plugin-proposal-unicode-property-regex", { "useUnicodeFlag": false }]);
+ }, {
+ includeNodeModules: ['camelcase']
})
I suspect things like that line from camelcase are not well understood by Firefox :)
Thank you very much, I spend more than week on this issue. You are my savior. It was caused by bad support of new Regex in firefox rigth?
Most helpful comment
Hi @pajasry,
Since the error is coming from
vendors~app.jsit may be caused by a RegExp used in a vendor (those are not transpiled by Babel by default).After looking at the content of your
package.jsoncould you try this?I suspect things like that line from
camelcaseare not well understood by Firefox :)