Remove process auto polyfill in edge runtime (#65751)
### What Disable auto polyfill for process in edge runtime. ### Why React uses process.emit behind a typeof guard now. This leads to process being bundled and process.emit being called which triggers build warnings since we stub process APIs since they're not supported in Edge runtime. There's condition like `"object" === typeof process && "function" === typeof process.emit` in the react build now where the 2nd condition is falsy. Stop polyfilling to skip that condition since it's mainly for Node.js runtime Related to #65692
This commit is contained in:
parent
0840d521d5
commit
0b261f0919
3 changed files with 23 additions and 1 deletions
|
@ -664,7 +664,7 @@ export default async function getBaseWebpackConfig(
|
|||
reactProductionProfiling,
|
||||
hasRewrites,
|
||||
}),
|
||||
...(isClient || isEdgeServer
|
||||
...(isClient
|
||||
? {
|
||||
fallback: {
|
||||
process: require.resolve('./polyfills/process'),
|
||||
|
|
|
@ -24,6 +24,11 @@ describe('app-dir edge SSR', () => {
|
|||
expect(await res.text()).toInclude('Hello')
|
||||
})
|
||||
|
||||
it('should treat process as object without polyfill in edge runtime', async () => {
|
||||
const $ = await next.render$('/edge-apis/process')
|
||||
expect(await $('#process').text()).toContain('object')
|
||||
})
|
||||
|
||||
it('should handle /index routes correctly', async () => {
|
||||
const appHtml = await next.render('/index')
|
||||
expect(appHtml).toContain('the /index route')
|
||||
|
|
17
test/e2e/app-dir/app-edge/app/edge-apis/process/page.tsx
Normal file
17
test/e2e/app-dir/app-edge/app/edge-apis/process/page.tsx
Normal file
|
@ -0,0 +1,17 @@
|
|||
import React from 'react'
|
||||
|
||||
export default function Page() {
|
||||
return (
|
||||
<>
|
||||
<p id="process">
|
||||
{typeof process === 'object'
|
||||
? typeof process.emit === 'function'
|
||||
? 'emit'
|
||||
: 'object'
|
||||
: 'undefined'}
|
||||
</p>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export const runtime = 'edge'
|
Loading…
Reference in a new issue