Length | Points | Week |
---|---|---|
20 minutes | 10 | Week 2 |
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
- Fork This Gist
- Respond in your forked gist with answers to the following questions
- In the context of Node, what is a
module
?- In Node, a module is a file. Everything written in a module is scoped to that file. For the content of a module to be made available outside of that file, it must be exported. The command to export content from a file is
module.exports = 'Object'
- In Node, a module is a file. Everything written in a module is scoped to that file. For the content of a module to be made available outside of that file, it must be exported. The command to export content from a file is
- The code examples from the second blog post look very different from the first. Why?
- RequireJS is optimizer that takes modules, combines them into one file, and minifies them in order to improve performance. A key difference is that the code in the second example loads all the modules first, which optimizes browser performance. If one were performing an asychronous call using the require statements from the first example, the modules may not load in time. In the second example, we know all dependencies before executing the script.
- In the context of Node, what is a