Skip to content

Instantly share code, notes, and snippets.

@hhoopes
Forked from rrgayhart/require-1511.markdown
Last active May 23, 2016 05:05
Show Gist options
  • Save hhoopes/3b0c5de5f4d41ee6ac5951637ba560a1 to your computer and use it in GitHub Desktop.
Save hhoopes/3b0c5de5f4d41ee6ac5951637ba560a1 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?

Modules map directly to files and everything within them by default is private. Exposing a module with module.exports allows whatever is exported to be used by another module.

  • The code examples from the second blog post look very different from the first. Why?

The second link is using RequireJS which defines modules, and then passes other modules in as arguments when defining a module that requires the initial modules. The first link described the default Node pattern of loading modules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment