Skip to content

Commit fc06fe6

Browse files
authored
Remove process.cwd usage from path polyfill (#37130)
Avoid process usage detection warning for edge runtime bundle
1 parent 565a2fa commit fc06fe6

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

packages/next/build/webpack/loaders/next-middleware-ssr-loader/render.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ import {
1111
WebNextResponse,
1212
} from '../../../../server/base-http/web'
1313

14-
// Polyfilled for `path-browserify` inside the Web Server.
15-
process.cwd = () => ''
16-
1714
export function getRender({
1815
dev,
1916
page,

packages/next/compiled/path-browserify/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/next/taskfile.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,12 @@ export async function ncc_path_browserify(task, opts) {
611611
target: 'es5',
612612
})
613613
.target('compiled/path-browserify')
614+
615+
const filePath = join(__dirname, 'compiled/path-browserify/index.js')
616+
const content = fs.readFileSync(filePath, 'utf8')
617+
618+
// Remove process usage from path-browserify polyfill for edge-runtime
619+
await fs.writeFile(filePath, content.replace(/process\.cwd\(\)/g, '""'))
614620
}
615621

616622
// eslint-disable-next-line camelcase

0 commit comments

Comments
 (0)