diff --git a/packages/next/src/build/webpack-config.ts b/packages/next/src/build/webpack-config.ts index 262b0c718f..df2887434d 100644 --- a/packages/next/src/build/webpack-config.ts +++ b/packages/next/src/build/webpack-config.ts @@ -664,7 +664,7 @@ export default async function getBaseWebpackConfig( reactProductionProfiling, hasRewrites, }), - ...(isClient || isEdgeServer + ...(isClient ? { fallback: { process: require.resolve('./polyfills/process'), diff --git a/test/e2e/app-dir/app-edge/app-edge.test.ts b/test/e2e/app-dir/app-edge/app-edge.test.ts index dfb64dfc15..5d46218153 100644 --- a/test/e2e/app-dir/app-edge/app-edge.test.ts +++ b/test/e2e/app-dir/app-edge/app-edge.test.ts @@ -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') diff --git a/test/e2e/app-dir/app-edge/app/edge-apis/process/page.tsx b/test/e2e/app-dir/app-edge/app/edge-apis/process/page.tsx new file mode 100644 index 0000000000..958b0d63b1 --- /dev/null +++ b/test/e2e/app-dir/app-edge/app/edge-apis/process/page.tsx @@ -0,0 +1,17 @@ +import React from 'react' + +export default function Page() { + return ( + <> +

+ {typeof process === 'object' + ? typeof process.emit === 'function' + ? 'emit' + : 'object' + : 'undefined'} +

+ + ) +} + +export const runtime = 'edge'