Browse Source

Making amdefine self-contained so easily embeddad.

Node's require caches module, so calling require()
multiple times comes with little cost.
Also 'use strict'; is present in the body of the function.

This form of the function allows to easily embed amdefine
programmatically by just including its string representation.
Herbert Vojčík 12 years ago
parent
commit
1e1786f4a1
1 changed files with 2 additions and 2 deletions
  1. 2 2
      amdefine.js

+ 2 - 2
amdefine.js

@@ -8,8 +8,6 @@
 /*global module, process */
 /*global module, process */
 'use strict';
 'use strict';
 
 
-var path = require('path');
-
 /**
 /**
  * Creates a define for node.
  * Creates a define for node.
  * @param {Object} module the "module" object that is defined by Node for the
  * @param {Object} module the "module" object that is defined by Node for the
@@ -21,9 +19,11 @@ var path = require('path');
  * module.
  * module.
  */
  */
 function amdefine(module, require) {
 function amdefine(module, require) {
+    'use strict';
     var defineCache = {},
     var defineCache = {},
         loaderCache = {},
         loaderCache = {},
         alreadyCalled = false,
         alreadyCalled = false,
+        path = require('path'),
         makeRequire, stringRequire;
         makeRequire, stringRequire;
 
 
     /**
     /**