Skip to content

Instantly share code, notes, and snippets.

@jasonpilz
Forked from rrgayhart/require.markdown
Last active February 9, 2016 20:38
Show Gist options
  • Save jasonpilz/efe649c08296a7f6908c to your computer and use it in GitHub Desktop.
Save jasonpilz/efe649c08296a7f6908c 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 maps, or corresponds to, a file.
The code examples from the second blog post look very different from the first. Why?
  • They are using require.js which has its own syntax for requiring and exporting. Instead of using the require() method, require.js uses the define() function to wrap a module of code. Exception - require() is only used in the "main" file, which takes and array of dependencies.
@rrgayhart
Copy link

👍

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