| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
I've found this sentence: `In Node.js, files and modules are in one-to-one correspondence.` a bit vague, so I propose replacing it with a more informative one.
|
Please wrap lines at 80 characters. |
Sorry, something went wrong.
|
|
||
| Node.js has a simple module loading system. In Node.js, files and modules are | ||
| in one-to-one correspondence. As an example, `foo.js` loads the module | ||
| Node.js has a simple module loading system. In Node.js each JavaScript file is a separate module which means that all variables, constants, functions, etc. declared in the file can be accessed only in that specific file unless explicitly exposed using `exports`-`require` interface. As an example, `foo.js` loads the module |
There was a problem hiding this comment.
Node supports more than just JavaScript source files.
Sorry, something went wrong.
There was a problem hiding this comment.
You mean json, c++ addons? Are they treated as modules, too?
Sorry, something went wrong.
There was a problem hiding this comment.
You mean json, c++ addons? Are they treated as modules, too?
Yes. :)
Sorry, something went wrong.
|
|
||
| Node.js has a simple module loading system. In Node.js, files and modules are | ||
| in one-to-one correspondence. As an example, `foo.js` loads the module | ||
| Node.js has a simple module loading system. In Node.js each JavaScript file is a separate module which means that all variables, constants, functions, etc. declared in the file can be accessed only in that specific file unless explicitly exposed using `exports`-`require` interface. As an example, `foo.js` loads the module |
There was a problem hiding this comment.
Things can also be exposed outside of a module if they are declared as globals, for example.
Sorry, something went wrong.
There was a problem hiding this comment.
You mean adding something to global object? global is there but it should be the last resort or never used at all.
Sorry, something went wrong.
There was a problem hiding this comment.
I was referring to accidentally creating global variables, but yes, you could do that too. Definitely not something that we want to recommend, but still technically possible.
Sorry, something went wrong.
There was a problem hiding this comment.
omg Node doesn't use strict mode by default. That changes things a little bit. Current module system doesn't protect from polluting global namespace, but just reads and executes specified files. I hope Node.js will soon support ES2015 modules. Thanks for pointing this out.
Sorry, something went wrong.
|
TBH, I find the existing text to be more clear than the proposed changes. |
Sorry, something went wrong.
|
@cjihrig You know all Node ins and outs, so your point of view is different from somebody who just start out with this runtime. Is it too simplistic for you? (of course after sorting out mistakes you pointed out). |
Sorry, something went wrong.
Added short clarification
|
I've changed the text as suggested in the comments. What do you think about it now? |
Sorry, something went wrong.
|
Updated text LGTM (I think you've answered @cjihrig's comments) |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM
Sorry, something went wrong.
PR-URL: #9026 Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: #9026 Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: #9026 Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: #9026 Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: #9026 Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
| Back | FazBrowse Home | New Git URL |
Checklist
Affected core subsystem(s)
doc
Description of change
I've found this sentence: In Node.js, files and modules are in one-to-one correspondence. a bit vague, so I propose replacing it with a more informative one.