• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

ExtendScript - using require('') function?

New Here ,
Apr 11, 2016 Apr 11, 2016

Copy link to clipboard

Copied

Hello all,

I'm relatively new to this whole scripting thing - at least with ExtendScript and JavaScript.

I have a bunch of editing I need to do in order to organize an event.  I have already figured out how to modify the photoshop document to update posters, times, etc - but there is also a word document that I would like to modify as well.

I have found some potential useful projects on github, but the problem is that ExtendScript does not seem to have native support for the require('x') function that most of these projects use.

I've been trying to figure this out off an on throughout the last two weeks with minimal success.

Does anyone have any ideas on what I need to do in order to get the require('x') function to work?  It seems that it is supposed to be node.js - but for some reason it is not executing from within ExtendScript IDE.

Any help, tips, pointers, or link to useful info would be much appreciated!

Thanks!

TOPICS
Actions and scripting

Views

4.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Apr 12, 2016 Apr 12, 2016

Copy link to clipboard

Copied

I do not know JavaScrip or Photoshop Script. However I do hack at Photoshop. So I thought I look at this append but it above my pay grade.  I did find something though that may be of use for you. Node.js, Require and Exports

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Apr 12, 2016 Apr 12, 2016

Copy link to clipboard

Copied

Hi,

if you're not in the context of an HTML Panel in Photoshop (but standard ExtendScript, i.e. a JSX file) instead of require('something') you can use preprocessor directives such as

#includepath "include;../include"

#include "file.jsxinc"

This is documented from page 233 onwards of the JavaScript Tools Guide PDF (jsxinc is just an arbitrary extension, you can use whatever you want)

In HTML Panels it doesn't work for Photoshop (InDesign is fine with that, though), so you have to load JSX files dynamically with $.evalFile().

Hope this helps!

Davide Barranca

---

http://htmlpanelsbook.com

www.davidebarranca.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 14, 2016 Apr 14, 2016

Copy link to clipboard

Copied

Thanks guys for the info...  Still new to the Javascript thing, and I appreciate the help.

I guess a lot of the stuff on GITHUB is geared towards node.js - which isn't exactly ExtendScript.  In talking with someone that is more familiar with this... they mentioned that I can launch a node.js socket on my system to run the scripts there, which seems a little more complicated than I want.

I guess the next option is to look at the projects I wanted to include, and modify them so that they are are local to my machine, and not dependent on the node.js require('') function.  I did find an extend script version of the require('') function... so I'm starting to play with that a little bit to see what I can accomplish.  Thanks again!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 30, 2017 Jun 30, 2017

Copy link to clipboard

Copied

Did you ever get require() to work for you? Which ESTK version did you find?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 10, 2018 Mar 10, 2018

Copy link to clipboard

Copied

i have a version of require that i use

GitHub - theiviaxx/PSLib: Photoshop CommonJS modules

works great

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 11, 2018 Oct 11, 2018

Copy link to clipboard

Copied

LATEST

Hey, I'm at a point where I'd love to be able to use external modules with Adobe ExtendScript and even compiling to that from TypeScript. I feel like I'm so close; the only thing I need now is to be able to use External Modules instead of keeping everything in one gigantic file with namespaces.

I tried out that PSLib repo, but it doesn't seem to work anymore. I've raised an issue about it, but I fear that the project is completely abandoned and I won't receive a reply.

How did you manage to get it working, brettd42018514?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines