One dependency on multiple modules is r.js ", the next module has the same URL"

I implemented requirejs through a multi-page web application that works fine, but now I'm trying to use r.js to create a single file of “all” modules except for any third-party libraries and frameworks like jquery, etc ...

the broken assembly file (build.js) is as follows:

({

baseUrl: "../",
out: "main-v0.1.js", //"charts-v0.1.js",

include: [


    "bi/jquery/jquery.ui.autocomplete",
    "bi/jquery/jquery.ui.combobox",


    "bi/ui/investmentselector"
],

wrap: true,

exclude: [
    'jquery', 'jqueryui', 'jcanvas', 'jqtools', 'prettyphoto', 'cssSandpaper', 'knockout', 'datatables', 'handlebars'
],
preserveLicenseComments: false,
optimize: "none", // "uglify", "uglify2"

paths: {
    handlebars      : 'lib/handlebars',
    /*hb runtime    : 'lib/handlebars.runtime',*/
    jquery          : 'lib/jquery-1.9.1',
    jqueryui        : 'lib/jquery.ui/jquery-ui-1.10.3.min',
    jcanvas         : 'lib/jcanvas.min',
    jqtools         : 'lib/jquery.tools/jquery.tools.min',
    prettyphoto     : 'lib/jquery/jquery.prettyphoto-3.1.5.min',
    BI              : 'bi/BI',
    sliderconnect   : 'bi/charts/slider-connect',
    cssSandpaper    : 'lib/csssandpaper/cssSandpaper',
    csstransform    : 'bi/enhance/csstransform',
    knockout        : 'lib/knockout-2.2.1',
    datatables      : 'lib/jquery/jquery.dataTables',
    // jquery ui widgets
    uicombobox      : 'bi/jquery/jquery.ui.combobox',
    uiautocomplete  : 'bi/jquery/jquery.ui.autocomplete'
}

})

The jquery.ui.autocomplete.js and jquery.ui.combobox.js files are custom jqueryui widgets without any define () wrapped around them. The investmentselector.js module (broken down) looks like this ...

define(['jquery',
    'bi/templates/investmentselector.js',
    'bi/jquery/datatables/investmentselector.js',
    'lib/JSLinq/JSLINQ.js',
    'uicombobox', 'uiautocomplete'], function ($, tmp, datatables, jsLinq, uicombobox, uiautocomplete) {

    'use strict';


    var methods = {
        // ... code
    };

    return methods;
});

what i get when i run r.js to create a single file called "main-v0.1.js", this is ...

Tracing dependencies for: D:/Files/Trunk/BestInvest.Select.Website/js/build/main
-v0.1.js
Error: Error: Module loading did not complete for: bi/ui/investmentselector, uic
ombobox, uiautocomplete
The following modules share the same URL. This could be a misconfiguration if th
at URL only has one anonymous module in it:
D:/Files/Trunk/BestInvest.Select.Website/js/bi/jquery/jquery.ui.autocomplete.js:
 uiautocomplete, bi/jquery/jquery.ui.autocomplete
D:/Files/Trunk/BestInvest.Select.Website/js/bi/jquery/jquery.ui.combobox.js: uic
ombobox, bi/jquery/jquery.ui.combobox
    at Function.build.checkForErrors (D:\Files\Trunk\BestInvest.Select.Website\j
s\build\r.js:27237:19)

Any ideas on what's going on?

FYI ( ) :

$.widget("bi.bicombobox", {
_create: function () {
    // ...code
},
_destroy: function () { }
});

...

$.widget("bi.biautocomplete", {
_create: function () {
    // ...code
},
_destroy: function () { }
});

, !

+4
1

include , paths. , paths:

include: [
    "uicombobox",
    "uiautocomplete",
    "bi/ui/investmentselector"
]

, , . , - foo: "path/to/foo" paths foo path/to/foo . foo, . r.js uicombobox ( ) paths. "bi/jquery/jquery.ui.combobox" include , .js , . , , , , .

, define .js. . , , , , .

+8

Source: https://habr.com/ru/post/1532854/


All Articles