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 Node building block that maps to a file
- All things within a module are private unless exported
- The code examples from the second blog post look very different from the first. Why?
- The first blog showed examples of using
require
and how to leverage the return values of imported modules. - The second blog focused on RequireJS, which is a JS file and module loader. It showed examples of wrapping multiple modules within a function via
define
, which will return those modules. RequireJS shows how its API can handle multiple modules, account for their dependencies, and fetch and execute them.
- The first blog showed examples of using