Skip to content

Instantly share code, notes, and snippets.

@Claudia108
Forked from rrgayhart/require-1602.markdown
Last active July 5, 2016 14:56
Show Gist options
  • Save Claudia108/98c93937b49ad764541e2217380bfcf2 to your computer and use it in GitHub Desktop.
Save Claudia108/98c93937b49ad764541e2217380bfcf2 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 are specific parts of code that live in their own files. This allows better orginization of code. In order to use these code modules they need to be exported and specifically required them from other files. This makes code easier to read and handle.

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

The second blog post uses require.js to create modules split out in different files. This approach uses different syntax to create modules (define() instead of defining vars and functions). Exporting specific code is not necessary with require.js but it also uses require() in order to use functions from other files.

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