Closed aleclarson closed 6 years ago
Since I have symlinks in the node_modules of many of my local packages, I have altered Module._load to support symlink resolution. This effectively cleans up stack traces when using symlink'd depedencies.
node_modules
Module._load
For paths that are neither absolute nor relative:
require('my-module')
Module._load('my-module', parent, isMain)
package.json
parent.id
path.dirname("path/to/package.json") + "/node_modules"
This PR also includes support for relative imports via the console.
// When entered in the console, it's assumed you mean "relative to process.cwd()". require('./my-module')
After my patches, this all works as intended. LMK what you think. 😁
The symlink-related code is no longer useful. At least with electron@2.x.x, which is all I tested.
electron@2.x.x
Since I have symlinks in the
node_modules
of many of my local packages, I have alteredModule._load
to support symlink resolution. This effectively cleans up stack traces when using symlink'd depedencies.For paths that are neither absolute nor relative:
require('my-module')
→Module._load('my-module', parent, isMain)
package.json
nearest toparent.id
path.dirname("path/to/package.json") + "/node_modules"
This PR also includes support for relative imports via the console.