Out of curiosity, in which scenarios you have used...
# suitescript
e
Out of curiosity, in which scenarios you have used browserify in SuiteScript? I always try to look for AMD support when I use external libraries but I have seen some people mention browserify, so I would like to know some case uses.
watching following 1
e
Would be curious to see as well
👌 1
s
I have tried but don't recall ever ultimately using browserify successfully for a library to be used in NS. Instead focusing on AMD as @eminero says and/or UMD support.
👌 1
e
I'm not sure I've ever run across a problem where I thought browserify/webpack/etc were the solution.
b
browserify can be used to bundle packages that use the common js module format into the umd format instead
umd can be used in the amd modules
for example, you can use browserify so that you can use xml2js in your suitescript code
n
I've web-packed modules such as you find on NPM and sometimes needed to use a node-web-pack pollyfill on top of that. Never used browserify, intriguing.
e
Hey guys! I'm exploring a way to use xmldom (node.js library) into SuiteScript, I have used browserify to include the full tree dependecies it might have (this is just for exploring purposes due to a project we are working on). @battk after using browserify with a command like this: npx `browserify mainDom.js --standalone xmldomBundle -o bundle2.js`I got something that seems that is AMD compatible but when I tried to import it using a
config.json
file on a UE script it does not recognize the methods I'm trying to use, when I log the external library (bundle2.js) it is just an empty object. Did you do any extra steps to make it work with your xml2js example?
b
what does mainDom.js look like
e
There you go.
b
do the normal thing and use module.exports
e
I updated it but no luck, it seems it does execute the file but it does not exist or load. (I put some lines when evaluating if define.amd is there and it gets executed)
b
what does the suitescript code look like and the edited moainDom.js
e
There you go. Do not pay attention to
loadBundle
that was another dummy test I was doing.
b
first off, make sure you know how to use mainDom.js in a node js script first
both the scripts you shared dont show understanding of how to properly require another module
once you get the common js version working, you will need to learn how to do the same thing via amd, you can go through SuiteScript 2.x Custom Modules if you need help there
s
I recommend JSONIX
e
Thanks @Shawn Talbert I'm gonna take a look at that! @battk it was just a small and simple POC, you will not see anything fancy there. I was just testing.
@Shawn Talbert probably you saw that I was trying to convert some xml, however my final objective is to use
xmldom
on Suitescript, the other code was just for testing, thanks for the suggestion, tho.
👍 1