When you start working with WebPack for GameTime, you'll notice that you can't just define a variable in one file and find it in another as easily as you can in Rails.
Read Node.js, Require and Exports and Organize Your Code with RequireJS
- In the context of Node, what is a
module
?
Modules map directly to files and everything within them by default is private. Exposing a module with module.exports
allows whatever is exported to be used by another module.
- The code examples from the second blog post look very different from the first. Why?
The second link is using RequireJS which defines modules, and then passes other modules in as arguments when defining a module that requires the initial modules. The first link described the default Node pattern of loading modules.