Webix 6 and RequireJs

Hi,

I use requireJs to compile all my JS files, including Webix.

But since version 6 of Webix, I can no longer make Webix work with my other JS files, I get an error “webix is not defined”.

If I add the file webix.min.js in a script tag of my page, everything works, but then I load the framework twice, once in requireJs for the internal operation of my application (js files that contain my methods that interact with webix), and another time as a global variable for third-party files (localization files, spreadsheet, dhtmlxscheduler…) that do not seem to find webix with requireJs.

How to avoid this double loading please?

Translated with DeepL Translate: The world's most accurate translator

I tried to put in my main.js file:

var webix = require('webix'); 
window.webix = webix;

But it doesn’t work, because apparently requireJs trying before loading third-party files, for example :

spreadsheet:   'webix_6/spreadsheet_6/codebase/spreadsheet', 
scheduler: 'webix/scheduler/dhtmlxscheduler',
locale_fr: 'webix/scheduler/locale/locale_fr',

As RequireJs tries to load all these files before I can type methods, it detects errors and crashes, because these files can’t find webix.

Starting from Webix 6.0, files are build as UMD modules

    require(['webix'], function(webix) {
        window.webix = webix; // re-attach to global scope

        // Now load the problematic module
        require(['webix_6/spreadsheet_6/codebase/spreadsheet'], function() {
            // This module can use webix as a global variable
        });
    });

Also, webix package provides full sources and toolchain, just change the target to “iife” and rebuild the library to have a file which always registers a global variable