Loading external modules via 'require'

Hello Everyone,
I have a few external modules that has to be loaded during runtime and I cannot find any other way to import it other than using script tag.
This also poses a major problem when trying to import standard JS modules.

So Does UXP support loading external modules via ‘require’ ? If not is it going to be a feature that is going to be introduced in a later version?

UXP plugins fully support loading modules with require.
Are you building a plugin or a script? It was not possible to use it in UXP Scripting.
Support was added in the latest Photoshop beta version (24.2 February 2023).

it’s possible to use require to load modules. but while testing I found that not all modules are supported.

I also remember having to add ./ or ./modules/moduleName/scriptName.js to the path of the module. not sure why

edit: keep in mind that core modules like http/fs/path…etc are not identical to the ones present in nodejs. so not all functionality is supported

This is very interesting.

I did the same thing @Maher mentioned and didn’t work the first time. But like @tomzag said, it was included in one of the latest updates, so I had to do an update on Photoshop and tried the same method @Maher mentioned and it worked!

Thank you for the help everyone!