Files
Jiachi LiuandGitHub 3738e8ecc0 Fix react-refresh for transpiled packages (#60563)
### What

We're applying react-refresh to browser layer and inject ESM or CJS
helper based on file type. Some package from `trasnpilePackages` might
contain CJS browser bundle. And injecting ESM helper breaks them.
Actually they don't need to have fast refresh ability since they're in
`node_modules`.

### How
Skip react-refresh for transpiled packages as they're in node_modules
and won't change.

Fixes #56487 
Closes NEXT-2061
2024-01-12 21:44:41 +01:00

24 lines
671 B
JavaScript

'use client'
import getType, { named, value, array, obj } from 'non-isomorphic-text'
import add from 'transpile-ts-lib'
// ESM externals has react has a peer dependency
import useSWR from 'swr'
export default function Page() {
const { data } = useSWR('swr-state', (v) => v, { fallbackData: 'swr-state' })
return (
<div id="content">
<div>{`module type:${getType()}`}</div>
<div>{`export named:${named}`}</div>
<div>{`export value:${value}`}</div>
<div>{`export array:${array.join(',')}`}</div>
<div>{`export object:{x:${obj.x}}`}</div>
<div>{`transpilePackages:${add(2, 3)}`}</div>
<div>{data}</div>
</div>
)
}