unjs / pathe

🛣️ Drop-in replacement of the Node.js's path module module that ensures paths are normalized

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Not compactible in browser

antfu opened this issue · comments

Environment

Browser

Reproduction

https://stackblitz.com/edit/vitejs-vite-fyufym?file=main.js&terminal=dev

Describe the bug

Pathe is referencing process and becomes not isomorphic

const path = index >= 0 ? arguments_[index] : process.cwd().replace(/\\/g, "/");

Additional context

No response

Logs

No response

I think we could resolve this with a node export condition and a slight tweak to the build step.

A simple typeof check should be also do the trick :)

A simple typeof check should be also do the trick :)

I am happy to do that, but what should we use on non-node env? / or ''?

I think / would be safer for root

fixed in 1.0.1 / 1.1.0