Commit fa30290
authored
Fix cjs client components tree-shaking (#64558)
## What
Determine if the client module is a CJS file and `default` export is
imported, then we include the whole module instead of using webpack
magic comments to only extract `default` export.
## Why
Unlike ESM, The `default` export of CJS module is not just `.default`
property, we need to include `__esModule` mark along with `default`
export to make it function properly with React client module proxy
Fixes #64518
Closes NEXT-31191 parent d52d32f commit fa30290
File tree
6 files changed
+60
-1
lines changed- packages/next/src/build/webpack/plugins
- test
- production/app-dir/client-components-tree-shaking
- app/cjs-dep
- node_modules/cjs-client-module
6 files changed
+60
-1
lines changedLines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| |||
664 | 665 | | |
665 | 666 | | |
666 | 667 | | |
| 668 | + | |
| 669 | + | |
667 | 670 | | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
668 | 678 | | |
669 | 679 | | |
670 | 680 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Lines changed: 27 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
73 | 100 | | |
74 | 101 | | |
Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
test/production/app-dir/client-components-tree-shaking/node_modules/cjs-client-module/package.json
Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14603 | 14603 | | |
14604 | 14604 | | |
14605 | 14605 | | |
14606 | | - | |
| 14606 | + | |
| 14607 | + | |
14607 | 14608 | | |
14608 | 14609 | | |
14609 | 14610 | | |
| |||
0 commit comments