Browse Source

devkit: improved node wrapping

should allow require.resolve (as in
`(JSObjectProxy on: require) resolve: ...`)
Herbert Vojčík 9 years ago
parent
commit
00804204e5
1 changed files with 6 additions and 4 deletions
  1. 6 4
      external/amber-dev/lib/helpers.js

+ 6 - 4
external/amber-dev/lib/helpers.js

@@ -12,13 +12,15 @@ exports.nodeWrapWithoutShebang = function (id) {
     var wrapSource = JSON.stringify('_wrap_' + id),
         idSource = JSON.stringify(id);
     return {
-        start: "(function(define){\n" +
-        "define(" + wrapSource + ", function (require) {\n",
+        start: "(function(define, require){\n" +
+        "define(" + wrapSource + ", function (requirejs) {\n" +
+        "requirejs.resolve = require.resolve;\n" +
+        "require = requirejs;\n",
         end: "require(" + idSource + ");\n" +
         "});\n" +
         "define.require(" + wrapSource + ");\n" +
-        "}(" +
+        "}((" +
         require("amdefine") +
-        "(module)));"
+        "(module)), require));"
     };
 };