Hi all, I am developing an InDesign UXP plugin and I want to export javascript functions from one file to another but I am getting error
> "uxp://uxp-internal/domjs_scripts.js:2 Uncaught ReferenceError: module is not defined
> at test.js:9:1"
. Can anyone please help?
Here is my code:
HTML
<!DOCTYPE html>
<html>
<head>
<script src="main.js"></script>
<script src="test.js"></script>
</head>
<style>
.wrapper {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100vw;
height: 100vh;
flex-direction: column;
display: flex;
padding: 12px;
}
</style>
<body>
<div class="wrapper">
<p> Congratulations! You just created your first plugin.</p>
</div>
</body>
</html>
main.js
const { entrypoints } = require("uxp");
const { app } = require("indesign");
entrypoints.setup({
commands: {
showAlert: () => showAlert()
},
panels: {
showPanel: {
show({node} = {}) {}
}
}
});
showAlert = () => {
Test.display();
const dialog = app.dialogs.add();
const col = dialog.dialogColumns.add();
const colText = col.staticTexts.add();
colText.staticLabel = "Congratulations! You just executed your first command.";
dialog.canCancel = false;
dialog.show();
dialog.destroy();
return;
}
test.js
var Test = {
text : "hhhhh",
display : function() {
console.log(this.text);
}
}
module.exports.Test = Test;