You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue we've found here is when the regexp passed to require.context uses a lookbehind expression like /(?<!.spec).(js|tsx)$/, swc transforms it to RegExp("(?<!.spec).(js|tsx)$"). Playground
webpack only processes require.context if the provided regex is a literal and otherwise skips it. So in our case, removing the lookbehind made swc keep it as a literal and it worked for us. Another option is to set the target to ES2022 (if the project allows) where swc will keep it as a literal too.
Though it would be nice if swc-loader could be smart about this and not transform require.context arguments but I'm not sure how feasible that is.
From swc-project/swc-loader#64 (comment) by @callmeteus
The text was updated successfully, but these errors were encountered: