goto-bus-stop/node-resolve

Paths cannot be normalized or are normalized incorrectly

Opened this issue · 0 comments

Thanks for creating this library. The source code is well written and easy to understand.

I encountered an issue was that node resolution didn't work when the library is compiled to WASM since "path.canonicalize" is not available on that platform (see WebAssembly/wasi-filesystem#27).

To mitigate that I tried using the preserve_symlinks option to switch to the library's internal normalize_path function, but this option also didn't work for us because some paths are transformed incorrectly. For example, in node, path.normalize("../foo/bar/../baz") returns ../foo/baz -- but the internal normalize_path function in this library converts the same path into /foo/baz.

For the second issue, it could be possible to fix the function directly, but to resolve the first issue, I wonder if it would make sense to use a library like https://crates.io/crates/normpath instead of fs::canonicalize.

Is it possible to implement node module resolution without performing any path normalization / provide that as an option?

I'd be happy to try making a pull request if that was helpful. 🙂