Is there anything like a JavaScript precompiler?

0

Well before listening to suggestions from automators such as gulp or grunt, I will explain in detail what I want; I imagined this panorama:

development / sections / object.js

{
  // atributos...
}

development / function.js

function haceHalgo(){
  var objeto = @include('secciones/objeto.js');
  // mas código...
}

production / function.js «result after compiling»

(
   function haceHalgo(){
     var objeto = {
        // atributos...
     };
     // mas código...
   }
})();

You may notice that the concatenations using pipes are not useful here since the code of a file is embedded between another file and not before or after, I look for something very similar to what is done with the Trait in PHP that ultimately generates a file for production from small modular sections under development.

If by chance they suggest RequireJs I must say that I have used it and I love being able to modularize in that way I can create objects and consume them but it does not solve this question in detail because all this happens in production and I wish it is a precompiler to generate files in development time, besides among other things is not always useful, at least not for all projects where I use angular, although I have used AngularAMD.js in addition to a library that I designed to work as AMD angular, I must say that although possible I would prefer not to do it for some projects in particular.

Another note is that please do not suggest solutions like concatenating sections as it is usually possible to see in javascript library templates:

(
   function haceHalgo(){
     var objeto = 
{
   // atributos...
};
   // mas código...
   }
})();

Thank you very much, I know that maybe what I'm looking for is a bit crazy but it would be very informative.

    
asked by NekoOs 16.10.2017 в 19:40
source

0 answers