XM Function external library | XM Community
Skip to main content

Hi ☺️ 

 

I am trying to use a library within the worker.js of an XM function and all methods are failing. I have tried both es6 and typescript packages with available notations and executing the task either returns a lib not found or forbidden import. Does anybody know the way to call a library or even a function from another file within the project within the worker.js?

 

Thanks!

the worker.js file operates in a restricted serverless environment. This environment has limitations on what libraries or modules you can import and use due to its sandboxed nature. Additionally, the worker script runs in a Web Worker-like context, which means standard Node.js module resolution and imports (e.g., require or import) might not work as expected


try bundling the worker.js and dependencies into a single file for execution and check es6 and typescript packages supports the module system. 


Thank you both! It turned out, environment is indeed more restricted than I initially though. After exhausting all ideas, I ended up including the needed library inline in the worker.js and it works fine like this.


Leave a Reply