requireJs:没有为 jsep 加载依赖项

requireJs: dependencies not getting loaded for jsep

这是我的配置

requirejs.config({
    baseUrl : 'vassets/lib/',
    shim : {
        'knockout' : [ 'jquery' ]
    },
    paths : {
        jquery : 'jquery/jquery.min',
        knockout : 'knockout/knockout',
        selectize : 'selectize.js/js/standalone/selectize.min',
        main : '/vassets/js/koapp/main',
        jsep : '/vassets/js/jsep/jsep.min'
    }
});

jsep 是 javascript 表达式解析器,可在此处获得 http://jsep.from.so/

这是我的模块定义:

define ()->
     require ['jsep'],(jsep)->
        console.log jsep
        # does not work, jsep is undefined

     ()->
        console.log jsep
        # does not work, jsep is available. but HOW????
        # I dont see this type of usage in api documnentation. How does this work?

另外下面的模块定义也不起作用

   define ['jsep'], (jsep)->
     console.log jsep
     # does not work
     # this is the normal usage I find in documentation, why this does not work???

可以

添加垫片,解决了问题。对于没有实现 define 功能的模块,按照 require js 的要求。 shim 配置中需要导出配置。下面的配置让它工作。

requirejs.config({
    baseUrl : 'vassets/lib/',
    shim : {
        'knockout' : [ 'jquery' ],
    'jsep': {
      exports: 'jsep'
    }
    },
    paths : {
        jquery : 'jquery/jquery.min',
        knockout : 'knockout/knockout',
        selectize : 'selectize.js/js/standalone/selectize.min',
        main : '/vassets/js/koapp/main',
        jsep : '/vassets/js/jsep/jsep.min'
    }
});