Forum Discussion

DanJ's avatar
DanJ
New Contributor
7 years ago
Solved

Importing scripts across projects

Hi folks

 

Using TC12 web module, language is javascript

 

I'm currently building a project suite that contains multiple projects. One for generic application access kind of things (pGeneric) and one for specific tests (pSpecific). The idea is that the pSpecific should be able to use scripts in pGeneric to interact with my application to reduce code duplication across the various scripts in pSpecific. My question is if I have a script (sLoadFormData) in pGeneric that imports several other scripts in pGeneric, is there a way for pSpecific to use sLoadFormData without also having to also import all the scripts that sLoadFormData imports?

 

Apologies if this is confusing. I'm more than happy to clarify any points

 

Thanks

 

Dan

  • Consider each project as a "stand-alone" application.  All code units/modules that are needed within that project need to be added to the project.  So, any modules that are needed need to be added to all projects.  So, any of the modules that sLoadFormData imports need to be added to pSpecific as well.

     

    Alternatively, rather than "add existing items", you could encapsulate all your shared code that you need to use in all your projects into Script Extensions.  Then, no matter what project you're working on, the code units are available immediately without needing to modify the project.

6 Replies