Libraries, I just could not get working.
But, modules. That I could do. I didn't think of it at first, because I thought of a module as being a display piece, as in it would be the header part of the app or something, but I really just needed inputs and outputs. In the end, I ended up having the module be a sidebar, that way I could enforce the selection options that were being provided as inputs, so I'm not sure if it would work for pure code encapsulation without the visual components. But, for me, it provides a way to write code once and use it twice, and that's what I need.
Hey, I have been trying to do the same, but without any luck, did you manage to figure out how to create your own custom external library? Maybe someone from Retool could help clarify? Can we create our own custom library with code specific to our business models and logic? or we can only load libraries from here: Libraries - cdnjs - The #1 free and open source CDN built to make life easier for developers
OK, I believe I figured out, Retool might be checking for specific urls to allow libraries, we don't seem to be able to load custom libraries. I would love if somenone from Retool team could confirm this, but this is most likely what is happening.
The main guideline around imported libraries is to make sure they're UMD builds. They don't have to be from a particular URL so you should be able to host your own!
The dev team is looking at improving the experience of integrating code with Retool more generally as well. The amount of work you had to do here to get modular code is way more than ideal @nl-setech Hopefully we can make the experience smoother for both of you!
It could be worth checking your browser's dev tools for any errors @sebap, that might give some insight as to why the custom library isn't working.
Hey @Kabirdas , thanks for your reply, but I did a little experiment. I copied the content of the Pusher library, one that I found works if imported, and pasted it in a file that i am hosting myself, and the library does not recognize the Pusher object. But if imported from the original source, it works just fine. There must be some validation that is happening internally, it would be great to have this documented.
Hey @Kabirdas, thanks for the tip, looked into the dev console and there was a CORS issues, I think i could try few more things here
Awesome! If you try and still run into issues let me know!