Can only one script be a "shared asset"



  • I would like to split my globally shared helper script. But I cannot check the "shared helpers.." checkbox.

    Can only one script be shared?
    If this is the case, can I split up the code anyway and import/export functions from the shared script?


  • administrators

    do you mean that you can not make two assets become shared helpers? or do you mean that you can not make two scripts to be global? (shared helpers vs global scripts are different)

    this should be possible in both cases, and here i can check that it is working.



  • I have a feeling that I have a lack of knowledge about scripts and assets. Do I somehow have to make the script an "asset" before I can share it?

    The first script (common) had a checkbox for making it shared"
    0_1567140531488_upload-7307fcad-44e3-4293-ab50-7000cfe7dd7c
    0_1567140543411_upload-d00f20b3-52c0-422e-877a-706451650617

    The second script looks different. What did I miss?
    0_1567140453471_upload-161dc5a0-0b2d-4fb3-9571-f50454d0fa7a
    0_1567140474222_upload-df1d7a33-3a8c-42ec-8aae-c7fcfc9249a3



  • Please disregard this =)
    I kind of gave the solution away to myself by writing the last post.

    Solution: Create an asset and name it test.js instead of creating a script.



  • Follow-up question:
    Will the assets be attached to the template in the same order as they appear in the folder?

    In that case I can require what I need in the first script and use it later (for example moment.js).
    In other case I need to require it in a var (not a const), since it must be required again in each script.


  • administrators

    Will the assets be attached to the template in the same order as they appear in the folder?

    the order of shared helpers depends mostly on what the store returns, we just take them from the store and concat them to the template helpers, but since helpers are about registering functions for template engines usage then the order does not matter to much.

    you seem to be confused by the shared helper and global script, code of an asset marked as shared helper won't have an effect to a script.

    In other case I need to require it in a var (not a const), since it must be required again in each script.

    i think you only have a problem with this with helpers, but at this point i'm not sure if you want to do something in helpers or scripts



  • Yes, I was confused by the global script. Thank you for your time.


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.