Skip to content

Instantly share code, notes, and snippets.

@MattRooney
Forked from rrgayhart/require.markdown
Last active February 16, 2016 22:11
Show Gist options
  • Save MattRooney/bd156c73c57e8e0ca991 to your computer and use it in GitHub Desktop.
Save MattRooney/bd156c73c57e8e0ca991 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?

    In Node, a module is the fundamental building block which corresponds to a file and can be used much like a Class in Ruby, splitting code up into multiple files and maintaining a single-responsibility approach.

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

    The code in the second blog post looks different because they’re using RequireJS which uses define(), which can take an array of dependencies and a function, instead of require() for wrapping modules. However the main file uses require().

@rrgayhart
Copy link

👍

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