next.js
6790004d - Fix barrel optimization to ignore layers (#59254)

Commit
2 years ago
Fix barrel optimization to ignore layers (#59254) Fixes #57624. The recent issue was an unexpected side effect caused by https://github.com/vercel/next.js/commit/305bb015060e82be3e6ae59a3d063c11a3e207f9, which only affects specific packages like `@mui/material`. The problem was that the entry file of `@mui/material` has `"use client"` at top, which affects the compilation result to output reference info only (when on the RSC layer), instead of keeping the original export statements. And the fix here is to ignore all layer info and React specific transforms here, as barrel optimization isn't related to all these framework features at all. To keep all directives unchanged, the SWC transform needs to parse and pass that info to the Webpack loader. This PR adds a test to ensure that `@mui/material` is working as expected (less than 1500 modules compiled). Without this feature it'll be ~2400 modules. Closes NEXT-1793, closes NEXT-1762.
Author
Parents
Loading