Skip to content

Instantly share code, notes, and snippets.

@jecrockett
Forked from rrgayhart/require.markdown
Last active April 5, 2016 14:46
Show Gist options
  • Save jecrockett/d155cb622ac72c25a146061ff49bc6f9 to your computer and use it in GitHub Desktop.
Save jecrockett/d155cb622ac72c25a146061ff49bc6f9 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 small chunks of your application that serve a specific purpose (cite: 2nd article). It's basically a group of functions/variables that are related and belong in their own separate file. I think of it like a class but I don't know if that's technically the right way to think of it.
The code examples from the second blog post look very different from the first. Why?
  • The second article is using RequireJS. Seems to wrap modules in functions where the arguments are the dependencies and then can be referenced in the module by the assigned variables (after the define part associates the files with the variables names).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment