Commit de1dc0ae authored by Alex Lamar's avatar Alex Lamar Committed by James M Snell
Browse files

module: preserve symlinks when requiring

Currently, required modules use the real location of the
package/file as their __filename and __dirname, instead
of the symlinked path if it exists. This behaviour is
undocumented (it even goes against documentation in
certain scenarios), creating hard-to-debug problems
for developers who wish to leverage filesystem abstractions
to lay out their application.

This patch resolves all required modules to their canonical
path while still preserving any symlinks within the path,
instead of resolving to their canonical realpath. The one
special case observed is when the main module is loaded
-- in this case, the realpath does need to be used
in order for the main module to load properly.

PR-URL: https://github.com/nodejs/node/pull/5950


Reviewed-By: default avatarJames M Snell <jasnell@gmail.com>
parent 236b7e8d
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment