Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use _rem array for ['require', 'module', 'exports'] checks

  • Loading branch information...
commit 765ce943b47fc5ac5e9ed61dd7b8981780bfbd2d 1 parent 7cf5548
Taka Kojima authored
Showing with 5 additions and 3 deletions.
  1. +5 −3 lib/needs.main.js
View
8 lib/needs.main.js
@@ -14,6 +14,8 @@
_head,
// Used for checking circular dependencies.
_dependencies = {},
+ // Used in various places, defined here for smaller file size
+ _rem = ["require", "exports", "module"],
// Configurable properties...
_baseUrl = "",
@@ -160,7 +162,7 @@
* Always return back the id for "require", "module" and "exports",
* these are replaced by calls to _swapArgs
*/
- if (id === "require" || id === "module" || id === "exports") {
+ if (~_rem.indexOf(id)) {
return id;
}
@@ -271,7 +273,7 @@
}
);
- dependencies = (factory.length > 1 ? ["require", "exports", "module"] : ["require"]).concat(dependencies);
+ dependencies = (_rem.slice(0,factory.length)).concat(dependencies);
}
if (dependencies.length && !depsLoaded) {
@@ -295,7 +297,7 @@
// Swap "require", "module" and "exports" with actual objects
facArgs =_swapArgs(
- dependencies.length ? dependencies : (factory.length > 1 ? ["require", "exports", "module"] : ["require"]),
+ dependencies.length ? dependencies : (_rem.slice(0,factory.length)),
{
"require" : require.localize(context),
"module" : module,
Please sign in to comment.
Something went wrong with that request. Please try again.