Browse Source

updated amdefine; much simpler injecting now

require('amdefine') returns completely self-sufficient function
so it can be used directly for injecting
Herbert Vojčík 10 years ago
parent
commit
a193376992
2 changed files with 2 additions and 23 deletions
  1. 1 22
      bin/amberc.js
  2. 1 1
      package.json

+ 1 - 22
bin/amberc.js

@@ -57,27 +57,6 @@ function always_resolve(callback) {
  * // which can either be stored in a file or interpreted with eval().
  */
 function createConcatenator () {
-	var defineAmdDefine = function () {
-		var path = require('path');
-		return ($AMDEFINE_SRC$)();
-	};
-
-	// The createAmdefineString is hack to help injecting amdefine into the concatenated output.
-	//
-	// Usually, the line 'var define = require('amdefine')(module), requirejs = define.require;'
-	// is needed when using amdefine with node and npm installed.
-	// var f = require('amdefine') itself returns one big self-sufficient function which must be called
-	// as f(module) to get the define you can use.
-	//
-	// However, amdefine needs the definition of the 'path' variable (node's internal 'path' module).
-	// To create this dependency the defineAmdDefine() function is used which defines
-	// the path variable first and adds a placeholder for the amdefine function/sourcecode.
-	// The defineAmdDefine() function is then converted to its string representation
-	// and the placeholder is replaced with the actual sourcecode of the amdefine function.
-	var createAmdefineString = function() {
-		return ('' + defineAmdDefine).replace('$AMDEFINE_SRC$', '' + require('amdefine'));
-	}
-
 	return {
 		elements: [],
 		ids: [],
@@ -92,7 +71,7 @@ function createConcatenator () {
 		},
 		start: function () {
 			this.add(
-				'var define = (' + createAmdefineString() + ')(), requirejs = define.require;',
+				'var define = (' + require('amdefine') + ')(), requirejs = define.require;',
 				'define("amber_vm/browser-compatibility", [], {});'
 			);
 		},

+ 1 - 1
package.json

@@ -39,6 +39,6 @@
     "grunt-contrib-jshint": "~0.3.0",
     "grunt-image-embed": "~0.1.3",
     "grunt-contrib-mincss": "~0.3.2",
-    "amdefine": "0.0.6"
+    "amdefine": "0.0.8"
   }
 }