Skip to content

Instantly share code, notes, and snippets.

@danjwinter
Forked from rrgayhart/require.markdown
Last active April 3, 2016 21:54
Show Gist options
  • Save danjwinter/64104ba32ab1a03c34b6ee4f4b77d2c5 to your computer and use it in GitHub Desktop.
Save danjwinter/64104ba32ab1a03c34b6ee4f4b77d2c5 to your computer and use it in GitHub Desktop.
The Concept of Require

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 and answer the following questions:

  • 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment