Skip to content

Instantly share code, notes, and snippets.

@lingtran
Forked from rrgayhart/require-1602.markdown
Last active July 11, 2016 15:17
Show Gist options
  • Save lingtran/5ecc317e978a62ad4f6928a535df08a2 to your computer and use it in GitHub Desktop.
Save lingtran/5ecc317e978a62ad4f6928a535df08a2 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 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment