@@ -110,8 +110,16 @@ const babelIncludeRegexes: RegExp[] = [
110
110
/ [ \\ / ] ( s t r i p - a n s i | a n s i - r e g e x | s t y l e d - j s x ) [ \\ / ] / ,
111
111
]
112
112
113
- const preCompileReactRegex =
114
- / n e x t [ \\ / ] d i s t [ \\ / ] c o m p i l e d [ \\ / ] ( r e a c t | r e a c t - d o m | r e a c t - s e r v e r - d o m - w e b p a c k ) ( - e x p e r i m e n t a l ) ? ( $ | [ \\ / ] ) /
113
+ const browserNonTranspileModules = [
114
+ // Transpiling `process/browser` will trigger babel compilation error due to value replacement.
115
+ // TypeError: Property left of AssignmentExpression expected node to be of a type ["LVal"] but instead got "BooleanLiteral"
116
+ // e.g. `process.browser = true` will become `true = true`.
117
+ / [ \\ / ] n o d e _ m o d u l e s [ \\ / ] p r o c e s s [ \\ / ] b r o w s e r / ,
118
+ // Exclude precompiled react packages from browser compilation due to SWC helper insertion (#61791),
119
+ // We fixed the issue but it's safer to exclude them from compilation since they don't need to be re-compiled.
120
+ / [ \\ / ] n e x t [ \\ / ] d i s t [ \\ / ] c o m p i l e d [ \\ / ] ( r e a c t | r e a c t - d o m | r e a c t - s e r v e r - d o m - w e b p a c k ) ( - e x p e r i m e n t a l ) ? ( $ | [ \\ / ] ) / ,
121
+ ]
122
+ const precompileRegex = / [ \\ / ] n e x t [ \\ / ] d i s t [ \\ / ] c o m p i l e d [ \\ / ] /
115
123
116
124
const asyncStoragesRegex =
117
125
/ n e x t [ \\ / ] d i s t [ \\ / ] ( e s m [ \\ / ] ) ? c l i e n t [ \\ / ] c o m p o n e n t s [ \\ / ] ( s t a t i c - g e n e r a t i o n - a s y n c - s t o r a g e | a c t i o n - a s y n c - s t o r a g e | r e q u e s t - a s y n c - s t o r a g e ) /
@@ -1423,7 +1431,12 @@ export default async function getBaseWebpackConfig(
1423
1431
? [
1424
1432
{
1425
1433
test : codeCondition . test ,
1426
- exclude : [ codeCondition . exclude , transpilePackagesRegex ] ,
1434
+ exclude : [
1435
+ // exclude unchanged modules from react-refresh
1436
+ codeCondition . exclude ,
1437
+ transpilePackagesRegex ,
1438
+ precompileRegex ,
1439
+ ] ,
1427
1440
issuerLayer : WEBPACK_LAYERS . appPagesBrowser ,
1428
1441
use : reactRefreshLoaders ,
1429
1442
resolve : {
@@ -1471,7 +1484,8 @@ export default async function getBaseWebpackConfig(
1471
1484
{
1472
1485
test : codeCondition . test ,
1473
1486
issuerLayer : WEBPACK_LAYERS . appPagesBrowser ,
1474
- exclude : preCompileReactRegex ,
1487
+ // Exclude the transpilation of the app layer due to compilation issues
1488
+ exclude : browserNonTranspileModules ,
1475
1489
use : appBrowserLayerLoaders ,
1476
1490
resolve : {
1477
1491
mainFields : getMainField ( compilerType , true ) ,
0 commit comments