V
V
Vladimir B.2015-07-01 17:00:54
JavaScript
Vladimir B., 2015-07-01 17:00:54

JS: How to convert existing project dynamic loading system to requireJS?

There is a system of asynchronous loading of modules.
But there is a desire to collect the project and / or individual modules into a common file with the necessary dependencies using gulp.
The loading structure looks like this:
3b8d989517a543238ee916570735c0fd.png
How can this be done with requirejs or something like that?
Earlier I asked a similar question, but I did not receive an answer to it: What is better to use to load modules - if you need to build the project later?
Attempts to solve this issue:
I tried to start writing in *.boot.js files :

define( 'requirejsTest', 
  [ 'requirejsTest' ] /* Необходимо загрузить файл requirejsTest*/,
        function( requirejs ) { debugger; }
);

require( [ 'requirejsTest' ], 
  function( requirejs )
  { 
    debugger;
  } );

But nothing happens, apparently I do not correctly understand the work of requirejs itself .

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Kitmanov, 2015-07-01
@k12th

Named modules began to work strangely from some point. I suspect they were broken and not fixed. I understand you need something like this:

define(function(require, exports, module) { // первый аргумент должен быть именно require, остальные можно опустить
        var a = require('a'),
            b = require('b');

        //Return the module value
        return function () {};
    }
);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question