【问题标题】:r.js and the text pluginr.js 和文本插件
【发布时间】:2014-07-21 13:52:45
【问题描述】:

我正在尝试编译一个使用 require.js 的项目。我想使用 r.js 进行优化,但我遇到了构建问题:

Error: RangeError: Maximum call stack size exceeded
In module tree:
    main
      vorbok
        dataloader

我在数据加载模块中注意到,如果我采用这条线,问题就消失了:

"text!/templates/registration/mous

tache/toppanel.moustache"

我的配置文件是:

({
    appDir: "../../lambdev/src/interface/static/js/registration",
    baseUrl: ".",
    dir: "../app-build",
    paths: {
        jquery: '../jquery/jquery-2.0.0.min',
        Grid:"grid",
        Backbone:"../bower_components/backbone/backbone-min",
        Gridutils:"gridutils",
        Underscore:"../bower_components/underscore/underscore-min",
        text:"../bower_components/requirejs-text/text",
        mustache:"../mustache",
        jcolor: "jquery/jquery.color",
        bootstrap:"../bootstrap3/bootstrap.min",
        gridtable:"gridtable",
        gridvalidation:"gridvalidation",
        table_engine:"table_engine",
        paginator:'../bootstrap3/bootstrap-paginator.min',
        fangskraningpanel:"mmode/massaskraning",
        routerfunctions:"routerfunctions",
        moment:"../bower_components/moment/min/moment.min",
        rowvalidation:"rowvalidation",
        utils:"../various/utils",
        batch:"batch",
        messages:"messages",  
        autocomplete:"../bower_components/jquery-ui/ui/minified/jquery-ui.min",
        jstorage:"../bower_components/jstorage/jstorage.min",   
        notify:"notify",
        whenitype:"../bower_components/jquery.whenitype/dist/jquery.whenitype.min",
        dataloader:"dataloader",
        inputhelper:"../various/input.helper",
        listeners:"listeners",   
        nod:"../bower_components/jquery-nod/nod",
        tooltip:"bootstrap3/tooltip",
        qtip:"../jquery/jquery.qtip",
        modal:"../bootstrap3/modal",  
        ramsearch:"../various/ramsearch",
        ewesearch:"../various/ewesearch",
        focusmanager:"focusmanager",
        vorbok:"mmode/vorbok",
        afdrifaskraning:"mmode/afdrifaskraning",
        saedingaskraning:"mmode/saedingaskraning",
        saedingar:"mmode/saedingar",
        error_check_panel:"mmode/error_check_panel",
        keytooltips:"keytooltips",


    },
    optimizeCss: "standard.keepLines",
    modules: [
        {
            name: "main"
        }
    ],
    stubModules : ['text'],
    inlineText: true,
    optimizeAllPluginResources: false,
    fileExclusionRegExp: /\.hg/
})

我需要知道如何修复由于文本插件引起的错误。

【问题讨论】:

    标签: require r.js


    【解决方案1】:

    这似乎是一个老问题,但我只是自己遇到并解决了这个问题,所以我想我会伸出援手。

    对我来说,我的文本文件的定义路径不符合 RequireJS 的口味。我的文件系统中的 HTML 模板与我的 JS 文件分开,如下所示:

    .
    ├── html
    |   ├── ko-component-template.html
    ├── js
    |   ├── app
    |       ├── ko-component.js
    

    所以我是这样定义 HTML 模板的:

    'text!../../html/ko-component-template.html'
    

    这在不编译 RequireJS 的情况下工作,但是一旦 Grunt 编译它,就会弹出错误。

    所以我重新组织了它,这样我就不必遍历父目录了

    .
    ├── js
    |   ├── app
    |       ├── ko-component.js
    |   ├── html
    |       ├── ko-component-template.html
    

    现在我可以像这样定义 HTML 模板了:

    'text!html/ko-component-template.html'
    

    【讨论】:

      猜你喜欢
      • 2013-11-30
      • 2014-05-14
      • 1970-01-01
      • 1970-01-01
      • 2014-06-08
      • 1970-01-01
      • 1970-01-01
      • 2013-02-28
      • 1970-01-01
      相关资源
      最近更新 更多