Forum Replies Created

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • in reply to: Global require.config #26138 Score: 0

    Jim Thompson
    Member
    • Contributions: 2
    • Level 1
    @jim_thompson

    Eric,

    I’ve moved to have a single lib file that dynamically loads on other libraries as needed. All my scripts use this single lib file as the module to load and to access the other libs. I’ve just used Object.defineProperty to dynamically load in additional functionality as needed. This gives me one central location to manage new functionality and things like version control. I call this my “core” set of libraries and this project always gets deployed as single project through environments.

    define([some native NS commonly used modules],function(…){

    require([the list of my libraries and less common NS libs ]);

    _this= {};

    Object.defineProperty(_this,”moment”,{

    get: function(){

    if(!this._moment){

    this._moment = require(‘/SuiteScripts/Libs/moment’);

    }

    return this._moment;      }    });

    ….

    return _this

    }

    Now, when consumed by a script the script always refers to the  same property on the core library but I can control which version of that core library is used by changing one file.

    define([‘/SutieScripts/Libs/utils’],function(utils){
    var moment =utils.moment;
    …..

    });

  • in reply to: Global require.config #26074 Score: 0

    Jim Thompson
    Member
    • Contributions: 2
    • Level 1
    @jim_thompson

    Eric,

    I have an environment where I have 1 production account 4 sandbox accounts. Moving work across 5 environments is cumbersome and time consuming.  I’m trying to figure out if there is a way I can create a utilities library module in production and configure  the sandbox accounts to really load in the production version of the module. For example…

    In production, no special config would be needed. I just put the utils.js in the correct location in the file cabinet…

    define([‘L/utils’],function(utils){…..});

    In the sandbox accounts I would need to figure out some configuration that mapped ‘L/utils’ to the public/external url of utils.js in production. Then the same code would work in the sandboxes but would really be loading the production version.

    It that possible?

Viewing 2 posts - 1 through 2 (of 2 total)