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 is a way to encapsulate/organize related code. Modules require that you expilcitly require or export the code contained within if you wish to use the functions or variables elsewhere in your program.
-
The code examples from the second blog post look very different from the first. Why?
In the second example, they are using require.js to export modules. Instead of haing to callrequire()
orexport()
, they can use require.js's syntax ofdefine
to acheive the same thing.