Ajaxmin MinifyJavascript adding before object










0















I am facing an issue while minifying a javascript file using AjaxMin's MinifyJavaScript method.



Unminified Code



if (typeof define === 'function' && define.amd) 
define(['moment'], function (moment)
root.moment = factory(moment)
return root.moment
)
else if (typeof exports === 'object')
module.exports = factory(require('moment'))
else
root.moment = factory(root.moment)



Minified Code



if(typeof define=="function"&&define.amd)define(["moment"],function(i)return n.moment=t(i),n.moment);else if(typeof exports=="object")module.exports=t(require("moment"))else n.moment=t(n.moment)}


Here in minified code "" is added after module object e.g.: module.exports but it should be module.exports



There are few more files before minifying the file:
1. jquery-3.3.1.min.js
2. moment.min.js



All the files are bundled in single file and after that minification is done.










share|improve this question
























  • C# tag looks like a misplaced tag here...

    – elgonzo
    Nov 13 '18 at 10:57











  • You need to put some ; in your code. The carriage returns are signifying the end of your lines, once you remove these and without any ; your minified code does something very different.

    – Liam
    Nov 13 '18 at 10:59











  • I tried with ; also but it gives me same result

    – Gaurav Mishra
    Nov 13 '18 at 11:04











  • so what's your minified output now? Please edit the question.

    – Liam
    Nov 13 '18 at 11:31











  • The one mentioned above

    – Gaurav Mishra
    Nov 13 '18 at 11:32















0















I am facing an issue while minifying a javascript file using AjaxMin's MinifyJavaScript method.



Unminified Code



if (typeof define === 'function' && define.amd) 
define(['moment'], function (moment)
root.moment = factory(moment)
return root.moment
)
else if (typeof exports === 'object')
module.exports = factory(require('moment'))
else
root.moment = factory(root.moment)



Minified Code



if(typeof define=="function"&&define.amd)define(["moment"],function(i)return n.moment=t(i),n.moment);else if(typeof exports=="object")module.exports=t(require("moment"))else n.moment=t(n.moment)}


Here in minified code "" is added after module object e.g.: module.exports but it should be module.exports



There are few more files before minifying the file:
1. jquery-3.3.1.min.js
2. moment.min.js



All the files are bundled in single file and after that minification is done.










share|improve this question
























  • C# tag looks like a misplaced tag here...

    – elgonzo
    Nov 13 '18 at 10:57











  • You need to put some ; in your code. The carriage returns are signifying the end of your lines, once you remove these and without any ; your minified code does something very different.

    – Liam
    Nov 13 '18 at 10:59











  • I tried with ; also but it gives me same result

    – Gaurav Mishra
    Nov 13 '18 at 11:04











  • so what's your minified output now? Please edit the question.

    – Liam
    Nov 13 '18 at 11:31











  • The one mentioned above

    – Gaurav Mishra
    Nov 13 '18 at 11:32













0












0








0








I am facing an issue while minifying a javascript file using AjaxMin's MinifyJavaScript method.



Unminified Code



if (typeof define === 'function' && define.amd) 
define(['moment'], function (moment)
root.moment = factory(moment)
return root.moment
)
else if (typeof exports === 'object')
module.exports = factory(require('moment'))
else
root.moment = factory(root.moment)



Minified Code



if(typeof define=="function"&&define.amd)define(["moment"],function(i)return n.moment=t(i),n.moment);else if(typeof exports=="object")module.exports=t(require("moment"))else n.moment=t(n.moment)}


Here in minified code "" is added after module object e.g.: module.exports but it should be module.exports



There are few more files before minifying the file:
1. jquery-3.3.1.min.js
2. moment.min.js



All the files are bundled in single file and after that minification is done.










share|improve this question
















I am facing an issue while minifying a javascript file using AjaxMin's MinifyJavaScript method.



Unminified Code



if (typeof define === 'function' && define.amd) 
define(['moment'], function (moment)
root.moment = factory(moment)
return root.moment
)
else if (typeof exports === 'object')
module.exports = factory(require('moment'))
else
root.moment = factory(root.moment)



Minified Code



if(typeof define=="function"&&define.amd)define(["moment"],function(i)return n.moment=t(i),n.moment);else if(typeof exports=="object")module.exports=t(require("moment"))else n.moment=t(n.moment)}


Here in minified code "" is added after module object e.g.: module.exports but it should be module.exports



There are few more files before minifying the file:
1. jquery-3.3.1.min.js
2. moment.min.js



All the files are bundled in single file and after that minification is done.







javascript microsoft-ajax-minifier ajaxmin






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 11:35







Gaurav Mishra

















asked Nov 13 '18 at 10:55









Gaurav MishraGaurav Mishra

83




83












  • C# tag looks like a misplaced tag here...

    – elgonzo
    Nov 13 '18 at 10:57











  • You need to put some ; in your code. The carriage returns are signifying the end of your lines, once you remove these and without any ; your minified code does something very different.

    – Liam
    Nov 13 '18 at 10:59











  • I tried with ; also but it gives me same result

    – Gaurav Mishra
    Nov 13 '18 at 11:04











  • so what's your minified output now? Please edit the question.

    – Liam
    Nov 13 '18 at 11:31











  • The one mentioned above

    – Gaurav Mishra
    Nov 13 '18 at 11:32

















  • C# tag looks like a misplaced tag here...

    – elgonzo
    Nov 13 '18 at 10:57











  • You need to put some ; in your code. The carriage returns are signifying the end of your lines, once you remove these and without any ; your minified code does something very different.

    – Liam
    Nov 13 '18 at 10:59











  • I tried with ; also but it gives me same result

    – Gaurav Mishra
    Nov 13 '18 at 11:04











  • so what's your minified output now? Please edit the question.

    – Liam
    Nov 13 '18 at 11:31











  • The one mentioned above

    – Gaurav Mishra
    Nov 13 '18 at 11:32
















C# tag looks like a misplaced tag here...

– elgonzo
Nov 13 '18 at 10:57





C# tag looks like a misplaced tag here...

– elgonzo
Nov 13 '18 at 10:57













You need to put some ; in your code. The carriage returns are signifying the end of your lines, once you remove these and without any ; your minified code does something very different.

– Liam
Nov 13 '18 at 10:59





You need to put some ; in your code. The carriage returns are signifying the end of your lines, once you remove these and without any ; your minified code does something very different.

– Liam
Nov 13 '18 at 10:59













I tried with ; also but it gives me same result

– Gaurav Mishra
Nov 13 '18 at 11:04





I tried with ; also but it gives me same result

– Gaurav Mishra
Nov 13 '18 at 11:04













so what's your minified output now? Please edit the question.

– Liam
Nov 13 '18 at 11:31





so what's your minified output now? Please edit the question.

– Liam
Nov 13 '18 at 11:31













The one mentioned above

– Gaurav Mishra
Nov 13 '18 at 11:32





The one mentioned above

– Gaurav Mishra
Nov 13 '18 at 11:32












1 Answer
1






active

oldest

votes


















0














I think this are the causes to the problem




  1. ajaxmin source code module seems to be a reserved word

  2. If/else scopes doesn't compiles properly to the output.

This seems to causing the issue



var blockType = AjaxMin.BlockTypeModule.FormatInvariant
(moduleScope.ScopeName.IfNullOrWhiteSpace(AjaxMin.ModuleNameImplicit));


Workaround (this is what I did in my project):



  • You can replace that string module. with module.

  • use ternary operator instead of if/else (most probably this will skip the replacement of that whole chunk)

  • use minify version of that file (this will skip the minify)





share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53279453%2fajaxmin-minifyjavascript-adding-before-object%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I think this are the causes to the problem




    1. ajaxmin source code module seems to be a reserved word

    2. If/else scopes doesn't compiles properly to the output.

    This seems to causing the issue



    var blockType = AjaxMin.BlockTypeModule.FormatInvariant
    (moduleScope.ScopeName.IfNullOrWhiteSpace(AjaxMin.ModuleNameImplicit));


    Workaround (this is what I did in my project):



    • You can replace that string module. with module.

    • use ternary operator instead of if/else (most probably this will skip the replacement of that whole chunk)

    • use minify version of that file (this will skip the minify)





    share|improve this answer



























      0














      I think this are the causes to the problem




      1. ajaxmin source code module seems to be a reserved word

      2. If/else scopes doesn't compiles properly to the output.

      This seems to causing the issue



      var blockType = AjaxMin.BlockTypeModule.FormatInvariant
      (moduleScope.ScopeName.IfNullOrWhiteSpace(AjaxMin.ModuleNameImplicit));


      Workaround (this is what I did in my project):



      • You can replace that string module. with module.

      • use ternary operator instead of if/else (most probably this will skip the replacement of that whole chunk)

      • use minify version of that file (this will skip the minify)





      share|improve this answer

























        0












        0








        0







        I think this are the causes to the problem




        1. ajaxmin source code module seems to be a reserved word

        2. If/else scopes doesn't compiles properly to the output.

        This seems to causing the issue



        var blockType = AjaxMin.BlockTypeModule.FormatInvariant
        (moduleScope.ScopeName.IfNullOrWhiteSpace(AjaxMin.ModuleNameImplicit));


        Workaround (this is what I did in my project):



        • You can replace that string module. with module.

        • use ternary operator instead of if/else (most probably this will skip the replacement of that whole chunk)

        • use minify version of that file (this will skip the minify)





        share|improve this answer













        I think this are the causes to the problem




        1. ajaxmin source code module seems to be a reserved word

        2. If/else scopes doesn't compiles properly to the output.

        This seems to causing the issue



        var blockType = AjaxMin.BlockTypeModule.FormatInvariant
        (moduleScope.ScopeName.IfNullOrWhiteSpace(AjaxMin.ModuleNameImplicit));


        Workaround (this is what I did in my project):



        • You can replace that string module. with module.

        • use ternary operator instead of if/else (most probably this will skip the replacement of that whole chunk)

        • use minify version of that file (this will skip the minify)






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 15 '18 at 7:01









        Just codeJust code

        10.4k53066




        10.4k53066



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53279453%2fajaxmin-minifyjavascript-adding-before-object%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Use pre created SQLite database for Android project in kotlin

            Darth Vader #20

            Ondo