How to add the standalone lodash-joins package as a module to complement lodash

Like many other developers I’ve been able to use lodash.js in SuiteScript 2.X Suitelets by referring to the library as a module (“/SuiteScripts/lodash”).

Lodash has a lot of “per method packages” that are standalone, and specifically I’m trying to figure out how to incorporate the lodash-joins standalone package.   Lodash-joins has a lot of powerful SQL-like functionality to merge two javascript arrays. The developer for lodash-joins has a minified lodash-joins.min.js located here which I’ve been able to successfully work with this library in the script tag on websites and in node.  But I can’t figure out how to use it as a module in server-side Netsuite.

I tried adding it as lodashJoins.js to my SuiteScripts folder and referring to it as “/SuiteScripts/lodashJoins”, but I get a MODULE_DOES_NOT_EXIST error for lodash.

So then I edited the lodashJoins.js file’s require statements to refer to /SuiteScripts/lodash/ instead of just lodash, but now I’m getting a MODULE_DOES_NOT_EXIST error for lodash/flatten.  I’m not sure how to move forward from here, but here’s a snippet of my current /SuiteScripts/lodashJoin.js’s require statements:

/*! For license information please see lodash-joins.js.LICENSE.txt */ !function(e,t){“object”==typeof exports&&”object”==typeof module?module.exports=t(require(“/SuiteScripts/lodash”),require(“/SuiteScripts/lodash/flatten”),

Is anyone familiar with lodash standalone packages and how to incorporate ones like lodash-joins as modules for SuiteScript?  Thank you for any help!

Rookie Asked on October 27, 2021 in SuiteScript.
Add Comment
1 Answer(s)
Best answer

The define statement for lodash-joins looks like

], t)

It has a whole bunch of dependencies that you probably dont want to try manually fixing. Those dependencies are designed to work with lodash-amd, specifically using an amd package. This will require you to use a require Configuration

Advanced Answered on October 27, 2021.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Limebox   Become a Sponsor