Skip to content

Instantly share code, notes, and snippets.

@dastinnette
Forked from rrgayhart/require.markdown
Last active April 2, 2016 20:16
Show Gist options
  • Save dastinnette/758cc399fb45461ffae5d33937bf8ae5 to your computer and use it in GitHub Desktop.
Save dastinnette/758cc399fb45461ffae5d33937bf8ae5 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 an object in Node that maps one file directly to another. One node must require another and the required node must export specific information to be exposed in other files.
  • The code examples from the second blog post look very different from the first. Why?
    • The second post uses RequireJS which packages the module in a define function as opposed to require. It loads the needed modules before another module is run to ensure the module requiring others has all the infomation it needs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment