Menu

The React Compiler silently skipped 15 of our files, and it will tell you exactly why if you ask it
📰

The React Compiler silently skipped 15 of our files, and it will tell you exactly why if you ask it

DEV Community: nextjs·Daniel Pertu·5 days ago
#TuAg36hN
#devtonextjs#devto#dev#compiler#react
Reading 0:00
15s threshold

PubTrivia has had this in its Next config since the first week:

const nextConfig = { // Enable React Compiler for automatic memoization reactCompiler : true , . . .

Enter fullscreen mode

Exit fullscreen mode

One line, a devDependency on babel-plugin-react-compiler , and then nobody ever looked at what it did. The whole pitch of the compiler is that you stop thinking about memoisation, so not thinking about it felt like compliance. This week I went and audited it from both ends: the output in the deployed JavaScript, and the compiler's own log over the source.

What is in the shipped bundle

Compiled output is easy to spot. A compiled function opens with a call into the compiler runtime and compares each cached slot against a sentinel:

function a ( e ) { let i , n , a = ( 0 , r . c ) ( 6 ) , { size : s , label : l , className : o , children : c } = e ; return a [ 0 ] === Symbol . for ( "react.memo_cache_sentinel" ) ?…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.