Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to require from the main modules view point #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

maxnordlund
Copy link

This should make it more robust, since it will more closely match the applications require behaviour.

@kevinbeaty
Copy link
Owner

Thanks. I haven't had a chance to really look at this, but seems like a good idea. I'll have to look at why the tests are failing though.

@kevinbeaty
Copy link
Owner

In what situation would require.main.require work? I didn't really see anything documented in that regard on a quick look.

@maxnordlund
Copy link
Author

maxnordlund commented Jul 12, 2016

It doesn't work in the REPL, but other then that it should always work. Basically, if there's an entry point (unlike the REPL), there's an main module. E.g. node foo.js -> foo.js is the main module.

@maxnordlund
Copy link
Author

Regarding the tests, it may be that it tries to require from within mocha, which should be solvable by using a local copy instead of the global one.

@kevinbeaty
Copy link
Owner

@jamestalmage Do you have any thoughts on preferring require.main.require for use with auto-detection of an implementation? This would apply more to any-observable since global Promise are more common and would be preferred.

@jamestalmage
Copy link

Hmm. I think I would be tempted to use caller instead of main.

@jamestalmage
Copy link

@sindresorhus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants