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 container for code. All files are isolated from each other using npm so modules make up the basic building blocks for piecing together code. A module could contain a class, function or variable and can be re-used later on using require('./FILENAME') in another file.
-
The code examples from the second blog post look very different from the first. Why?
- The second blog post utilized RequireJS which is a slightly different file management system and relies on definte('FILENAME') and require('FILENAME') to pull in needed files as opposed to exporting certain elements from a code base as does npm modules.