Closed epsitec closed 8 years ago
Hi @epsitec,
The current require('..')
already uses "main" in package.json
if present. You should be able to verify this by cd
ing into your project's node_modules
directory and running node -e require('..')
. This behaviour is described in the node API docs.
You mentioned you are using special tools, could you elaborate? Is there some reason why they don't follow node's module loading convention?
@yortus I am using Wallaby.js to run my tests live in the editor. When using the code produced by require-self
(in my case, ./node_modules/electrum-starter-3.js
):
module.exports = require('..');
Wallaby.js complains that it Cannot find module '..'
.
However, if I manually edit the file (or use the output produced by the PR) to this:
module.exports = require('../src/index.js');
then Wallaby.js is just fine. So this would be an issue with Wallaby.js. I'll let know @ArtemGovorov about this issue.
Thanks @epsitec for opening the issue on wallaby.js
. I've subscribed to it so I'll see their response.
I'll close this PR for now since it's an external problem. Feel free to re-open if they or you find that there really is something non-compliant about the current implementation.
Indeed. I was missing a piece of configuration in Wallaby.js. Now everything is running smoothly with the original 0.1
version of require-self
.
In my projects, I have no
index.js
in the root of the project. Rather, I am pointing npm to the main entry point by way of the"main"
definition inpackage.json
. With the tools I am using, the trick of require-self only works if the auto-generated.js
file innode_modules
points at the right place.I'd be thankful if you could include my modification in the official release, so I don't have to create yet another npm module just for my special use case ;-)