Required Script used in Producer Module have to be declared in Consumer Module?

Required Script used in Producer Module have to be declared in Consumer Module?

  

OAP with both Producer and Consumer module attached.

In Producer Module I have this script and added to Required Script:


I also have client action that call this "Javascript library"




In Consumer module, I add dependency to Producer module.

There is simple logic on the button:


If I run this Consumer Module and press the button, my "Javascript Library" called hello is not defined.

See the error message.


But if I set my script as Public, then add dependency to that script:

... and set it as required script in CONSUMER module:


My "javascript library" called hello is now defined/recognized.

Javascript alert (which my hello library called) is shown.


I assumed this is a bug, because javascript library should be obscured in Producer module.

Consumer module does not have to know which Javascript library it's producer module used.

Any thought?

I don't think this is a bug, Harlin.

This follows the same idea of everything in OutSystems. To be able to use something from another module, this element must be made public and referenced where you want to use it.

It's the same thing as if you had set a JavaScript function in a web block and expected to be able to use it in another module. It's not how this works.

Dependency is per element, not per module. Yor consumer module consumes something in a producer module, not the producer module itself.

Cheers

Edit

At least to JavaScript, being an external file, it makes sense that it is not used indirectly, but must be added explicitly where you want to use it.

So, I think this is by design. But I may be wrong.

Why does Extensibility Configuration in Producer module was honored in Consumer module, but Required Script don't?


If I have made a component which utilized JS library, would it be better if Consumer module does not have to know about that?

I thinking of encapsulation of component,component that is self-sufficient in it's dependency to certain JS library.

End-user can use my component without need to know which Javascript library he need to add to his consumer module required script.

Harlin Setiadarma wrote:

If I have made a component which utilized JS library, would it be better if Consumer module does not have to know about that?

I thinking of encapsulation of component,component that is self-sufficient in it's dependency to certain JS library.

End-user can use my component without need to know which Javascript library he need to add to his consumer module required script.

Yeah...
I think here you are right. While this can have consequences in terms of performance.

Cheers.


If I want to build a really encapsulated component, I will need to include big JS library directly in every instance of Run Javascript Node.

That is the true performance consequences.

Cheers too...

Hi Harlin,

Did you take a look on the System action RequireScript?

Cheers

Henrique Batista wrote:

Hi Harlin,

Did you take a look on the System action RequireScript?

Cheers

Nice info, I'll take a look...

Thanks...