Building InDesign UXP Plugins without index.html?

I’m trying to build a UXP plugin with components (App.js & main.js) but keep getting errors. Is this approach better than using index.html. Is it worth the hassle, or should I stick with the HTML way? Looking for advice and maybe a basic example of using .js components.

David, if I’m understanding the question correctly, I believe you use require and specify an .mjs file like the following:

const { IdPreferencesDataStructure } = require("./idPreferencesDataStructure.mjs");
const { alert_displayDialogAsync } = require("../sharedModules/alert.mjs");

This is listed somewhere in Adobe’s documentation, but I don’t remember where.

WARNING: even though your development environment might be happy allowing you to load a module from outside the UXP project’s root folder, UXP itself won’t allow that.


I should try to clarify and say that I’m getting better but still pretty new at this. I’ve had success with the UXP templates with index.html for UI and separate JavaScript files for logic. This feels straightforward, but I’ve seen others building UXP plugins for photoshop with just an App.js file with linked components and scripts, skipping index.html then importing that into the main.js. They claim it’s more consistent, but when I try this, I encounter errors, like .app not available, can’t resolve module main.js.

Is it standard practice or necessary to use the index.html?

Are there any successful simple examples that would show a simple wired up ui using that method?

I’m unsure if pursuing this component-based approach without index.html is worth the hassle, or stick with the index.html workflow.