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
?In Node, a module is the fundamental building block which corresponds to a file and can be used much like a Class in Ruby, splitting code up into multiple files and maintaining a single-responsibility approach.
-
The code examples from the second blog post look very different from the first. Why?
The code in the second blog post looks different because they’re using RequireJS which uses define(), which can take an array of dependencies and a function, instead of require() for wrapping modules. However the main file uses require().
👍