Search Unity

package.json dependencies

Discussion in 'Package Manager' started by StalsKnight, Sep 2, 2019.

  1. StalsKnight

    StalsKnight

    Joined:
    Nov 20, 2016
    Posts:
    4
    Wondering if I'm thinking about packages the wrong way or didn't find some feature, but for some reason, I haven't found any discussion on the issue.

    My idea with packages was to have a git repository and put all the packages there (monorepo), each package is a Unity project with its scripts and package.json inside the Assets folder. This way you could open any package, do some changes, run tests, publish it and use in the main project. It all seems to work if packages don't have any dependencies of their own.

    So the issue is in the following case, I have a "child" package & a "parent" package. "child" is a simple script, but "parent" defines "child" as its dependency.
    When I add "parent" to the main project - everything works fine, Unity downloads both "parent" & "child", but if I open the "parent" project on its own, I can't actually reference any of the "child" scripts. The only option I found is to add "child" to the manifest.json in the "parent" project, but this leads to duplicate definition of dependencies and their versions (package.json & manifest.json), and every time I update the version inside package.json I need to also update it in the manifest.json.

    Am I missing something or the idea of making each package its own Unity project is wrong?
     
    Last edited: Sep 4, 2019
    Zamaroht likes this.
  2. okcompute_unity

    okcompute_unity

    Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    756
    Hi @StalsKnight ,

    Have you read the Package Manager documentation? More specifically the introduction and custom packages sections. I would suggest to start there and come back here if you still have pending questions.

    Regards!

    Pascal
     
  3. StalsKnight

    StalsKnight

    Joined:
    Nov 20, 2016
    Posts:
    4
    Thank you for the reply,
    embeded packages do seem to be the solution, initially, I've tested with Unity 2018.3 (which we are currently using) and didn't notice any real difference if package.json was just in the Assets folder, or inside the Packages subfolder, but after testing in Unity 2019, embedded packages answer my initial question and do download the dependencies listed in package.json, there is no need to modify the manifest.json.
     
    Zamaroht and okcompute_unity like this.