Evgenus / spa

Single Page Applications builder
Other
7 stars 2 forks source link

AMD modules don't really work #58

Closed wizzard0 closed 9 years ago

wizzard0 commented 10 years ago
LOADER: EvaluationError Object {id: "invariant", url: "../modules/invariant.js", hash: "...", size: ..., type: "amd"…} TypeError: Cannot read property 'apply' of undefined {stack: "TypeError: Cannot read property 'apply' of undefin…14232
    at http://localhost:8010/build/:25:7720", message: "Cannot read property 'apply' of undefined"}message: "Cannot read property 'apply' of undefined"stack: "TypeError: Cannot read property 'apply' of undefined
    at AMDEvaluator.get_define.define (http://localhost:8010/build/:26:6391)
    at Object.eval (eval at <anonymous> (http://localhost:8010/build/:26:3962), <anonymous>:3:5)
    at AMDEvaluator.eval (eval at <anonymous> (http://localhost:8010/build/:26:3962), <anonymous>:21:4)
    at AMDEvaluator.BasicEvaluator.run (http://localhost:8010/build/:26:3993)
    at http://localhost:8010/build/:26:14232
    at http://localhost:8010/build/:25:7720"get stack: function () { [native code] }set stack: function () { [native code] }__proto__: Error 
wizzard0 commented 10 years ago

we expect define([], cb) format, but not others

wizzard0 commented 10 years ago

define((r,e,m){}):

  return define = function(names, func) {
            var needREM;
            if(!func) {
                console.log("no-names hack");
                func = names;
                names = [];
                needREM = true;
            }
            var deps, name;
            if(needREM){
                var m={};
                m.exports={};
                deps = [void 0,m.exports,m];
                func.apply(this["this"], deps);
                return this.result = m.exports;
            }else{
            return deps = function() {
                var _i, _len, _results;
                for (_results = [], _i = 0, _len = names.length; _len > _i; _i++) name = names[_i], _results.push(this.deps[name]);
                return _results
            }.call(this), this.result = func.apply(this["this"], deps)
            }
        }, define.bind(this)