Skip to content

Commit

Permalink
Remove process.cwd usage from path polyfill (#37130)
Browse files Browse the repository at this point in the history
Avoid process usage detection warning for edge runtime bundle
  • Loading branch information
huozhi committed May 23, 2022
1 parent 565a2fa commit fc06fe6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import {
WebNextResponse,
} from '../../../../server/base-http/web'

// Polyfilled for `path-browserify` inside the Web Server.
process.cwd = () => ''

export function getRender({
dev,
page,
Expand Down
2 changes: 1 addition & 1 deletion packages/next/compiled/path-browserify/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions packages/next/taskfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,12 @@ export async function ncc_path_browserify(task, opts) {
target: 'es5',
})
.target('compiled/path-browserify')

const filePath = join(__dirname, 'compiled/path-browserify/index.js')
const content = fs.readFileSync(filePath, 'utf8')

// Remove process usage from path-browserify polyfill for edge-runtime
await fs.writeFile(filePath, content.replace(/process\.cwd\(\)/g, '""'))
}

// eslint-disable-next-line camelcase
Expand Down

0 comments on commit fc06fe6

Please sign in to comment.