title: How can I convert a function to a module in RequireJS in a simplistic way?
body: <p>I have been reading the documentation, but I can't seem to do this in an easy way. I think I confuse this too much with <code>node.js</code> which uses the same words, e.g. <code>require</code>, <code>exports</code>, <code>module</code> etc.</p>
  
  <p>Imagine a main script something like this. (And imagine the functions are complex)</p>
  
  <pre><code>require(['jquery', 'domReady!'], function($) {
  
      $("#staticButton").click(function() {
          showMessage('What does this button do?');
      });
  
      function showMessage(message) {
          alert(message);
      }
  
  });
  </code></pre>
  
  <p>Now imagine I want to use <code>showMessage()</code> in multiple scripts. How do I actually do that?</p>
  
  <p>In <code>Node.js</code> I would attach <code>showMessage()</code> to <code>exports.showMessage</code> inside <code>showMessage.js</code> and do something like this everywhere I want to use it:</p>
  
  <pre><code>require(['jquery', 'domReady!'], function($) {
  
      var showMessage = require('showMessage'); // Easy huh?
  
      $("#staticButton").click(function() {
          showMessage('What does this button do?');
      });
  
  });
  </code></pre>
  
  <p>But with <code>RequireJS</code> this gives me the error that I first need to load it. Do I need to <code>require</code> or <code>define</code> this before I can use the above syntax?
  Do I really need to add it in the main script <code>require</code> array? I don't like that. What if you have 20 functions?</p>
  
  <pre><code>require(['jquery', 'domReady!', func01, func02, (...) func20], function($, empty, func01, func02, (...) func20) {}
  </code></pre>
  
  <p>That's pure syntactic salt. I like the <code>Node.js</code> sugar way better:</p>
  
  <pre><code>var func01 = require(func01),
      func02 = require(func02),
      (...)
      func20 = require(func20);
  </code></pre>
  
  <p>I am confusing the two too much. Can someone explain how I simply put functions in external files and use them as simple as possible?</p>
  
  <hr>
  
  <p>I'm assuming the module turned function needs to look like this:</p>
  
  <pre><code>define(function(require, exports, module) {
      return function(message) {
          alert(message);
      }
  });
  </code></pre>
  
  <p>..but if that can be done easier, I'd love to hear about it.</p>