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
?
A module in Node feels a lot like a class or other namespace in Ruby. However, simply requiring the file doesn't do the full job. You do have to export the module, to allow it to be sent out and used in other places. This can help prevent the pollution of the global namespace, I guess. (A very "green" way to code) You keep extraneous and private functions/variables hidden away, and only expose what you want to.
- The code examples from the second blog post look very different from the first. Why?
This code is using RequireJS to load in modules. I need more code examples, I think, to fully understand how this is better/faster/cleaner than how you would normally require in Node. It seems like it's related to dependencies, but I don't fully get it yet.