Suitescript channel overlords, please, can all npm...
# suitescript
s
Suitescript channel overlords, please, can all npm modules be shim-ed to in 2.1? Is there a prequisit to the module I want to shim? i.e does it need to be in a specific format like umd, or is it possible in cjs or esm? Is it possible to identify if it's shim-able based on the file or source? @battk @Sandii @erictgrubaugh @PNJ @michoel @Watz @darrenhillconsulting
p
Overlord please, not lord! 😉
w
I consider myself as a swamp rat, so I'll exclude myself from this. 😄
s
*edited thanks overlord
@Watz nah, y'all doing the lords work in this channel but when you figure it out do contribute and let us know Orz
d
I don't shim ... never have
s
UMD modules work best in my experience. That said, since node now (12+) natively supports ES modules I'm hopeful NS will support that soon as well rather than forcing everything to be AMD. I think being able to standardize on the module system defined in the language would be a good thing.
s
@darrenhillconsulting I think in terms of the feel, the shim is the biggest edition to changing from 2.0 to 2.1, because it opens you up to using say otpauth, creating a qr-code for otpauth, or like openpgp when you need to start to play with authentication, i feel like it's a necessity haha i was in a project that did the above using npm, and i think looking back as a consultant it wouldn't have been possible if shim wasn't possible
b
varies on what you need to do
s
@stalbert Thanks! I find that when i wanted to shim the otpauth module from npm, umd was the one that worked immediately, that said i'm not someone that started off with software development, is there a way to change say amd into umd in a simpler way than refactoring the whole script?
b
sometimes browserify is enough
sometimes you have to write code that mocks the browser the module is using
s
^^^ but NS (at least used to) includes some global things that can confuse the boilerplate module detection code
s
@battk say I want to create an excel file, from csv to excel, and i decide if it's possible via exceljs from npm, like how do I know if I can shim it?
b
load the module in netsuite and see what happens
👍 1
fix things as you go
s
note that there are lots of NPM modules which will NOT work in NS if they are meant to run specfically in NodeJS due to their reliance on Node-only things.
b
things that say they work in browsers and node have good chances of running in netsuite
s
I mean for excel I understand I mean I can cheat the concept with like creating an xml string and slap some like N/render module and addCustomDataSource but like, is there a more concrete way of like trying, like not going full dive but as proof of concept to say, hey it's probably do-able kindathing? I mean for like quotes or what not
s
Yes, usually modules meant to run both in browser and node are more likely to work. That really only fails if the library has deep dependencies on things only in the browser or only in node 🙂
d
Check the dependencies in npm
s
@battk so the first steps I guess, as in "load the module in NS" is I would shim the file which presumably is marked as Main when the it's constructed in the compiler?
or are you guys also saying there is a way of using browserify to convert the scripts to kinda make it work (or validate it'll work?)
b
basic answer is the compiled file
in this case, probably the one named exceljs.bare.js
add it to your define function's dependencies
see if/what breaks
s
@battk as in skip the shim and config.json?
s
i'll try that thanks @battk:DDD