-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
How to know which file(s) were entry points? #225
Comments
Can you provide an example of why you would need to know that in a module? |
For the same reasons you might need that in normal Node. Importing a file and executing a file are usually considered two distinct actions. So with Browserify not being able to specify this, you are left with a void.. Was this entry-file imported? As it might be during tests/etc, or was this file run directly. I consider a module that "does something" when imported to be rather volatile. Browserify forces this onto you (i believe), so i feel compelled to isolate this file. |
Files that execute directly with side-effects are probably a good thing to isolate from modules that export functionality explicitly. This feature does not fit very well with the v2 changes either. |
I would like to not have them at all. There is no need for it in Node, why have a need for it in Browserify?
Ah, oh well. Thanks for responding :) |
In Node.js you can use
require.main
to know when a file was executed directly. Is something like this possible with Browserify?It appears
require
doesn't even exist during runtime (i assume it's parsed during compile), so is there any way to make a file know if it was the entry point?Eg:
if require.main == module { // do stuff }
The text was updated successfully, but these errors were encountered: