Skip to content

Instantly share code, notes, and snippets.

@jwperry
Forked from rrgayhart/require.markdown
Last active April 4, 2016 15:50
Show Gist options
  • Save jwperry/1abc6f2727962b148b30299adca27ec3 to your computer and use it in GitHub Desktop.
Save jwperry/1abc6f2727962b148b30299adca27ec3 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 the "fundamental building block of Node" containing encapsuled, private code. Modules must be exported and then required within the files that you want to access them. Modules in this context seem very similar conceptually to separate class files in Ruby.
  • The code examples from the second blog post look very different from the first. Why?

    • The second example uses RequireJS. This allows you to use a define() function to map files/modules by their path to arguments in the define() function. This allows them to be easily referenced.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment