Skip to content

[Feature] Cross linking packages breaks identity checks in external dependencies #176

Closed

Description

@charlieschwabacher

Imagine I have a lerna repo w/ two packages a and b that depend on each other, and each depend on an external package from npm, c. If I bootstrap and then run code inside a, I will end up requiring two different copies of c - the one in packages/a/node_modules AND the one in packages/b/node_modules. This breaks any identity checks in c.

I'm running into this problem w/ graphql as the external dependency and a failing instanceof check.

One way to avoid this problem would be to add shared external dependencies to the root package.json, install them to node_modules, and link them from packages/a/node_modules and packages/b/node_modules in the same way that lerna links the internal dependencies.

Is this a change you would consider? Or is there another solution for this that I have overlooked?

Activity

  1. changed the title [-]Linking modules by requiring local files breaks identity checks in external dependencies[/-] [+]Cross linking packages breaks identity checks in external dependencies[/+] on Jun 5, 2016
  2. charlieschwabacher commented on Jun 5, 2016

    @charlieschwabacher
    Author

    I was able to work around my issue by adding a dummy graphql package w/

    package.json:

    {
      "private": true,
      "name": "graphql",
      "version": "0.6.0"
    }
    

    and index.js:

    module.exports = require('../../node_modules/graphql');
    

    I would still love a cleaner solution, but this is at least a temporary fix.

  3. hzoo commented on Jun 5, 2016

    @hzoo
    Contributor

    Will link https://twitter.com/gr2m/status/738454783854563330 as a reference since it seems to be a general problem too

    Is there a CLI tool that lets me git clone multiple repositories, runs npm install and links them based on "dependencies" in package.json?

  4. jamiebuilds commented on Jun 6, 2016

    @jamiebuilds
    Contributor

    Yeah I've run into this exact issue with React related stuff. I wouldn't mind adding a feature that allowed you to whitelist external dependencies that need to share a single instance that could be linked from the root node_modules.

    I think we'd have to use actual symlinks though... which we may need to explore again

  5. charlieschwabacher commented on Jun 6, 2016

    @charlieschwabacher
    Author

    @thejameskyle - why do you say we would have to use symlinks?

  6. jamiebuilds commented on Jun 9, 2016

    @jamiebuilds
    Contributor

    Because you would need to symlink it into each package.

  7. rygine commented on Jun 14, 2016

    @rygine
    Contributor

    this would be fixed using the updated bootstrapping process i've created, as long as they share the same version of the external dependency.

    more info here: #215

  8. charlieschwabacher commented on Jun 19, 2016

    @charlieschwabacher
    Author

    @thejameskyle what I mean is why symlinks here vs proxies for cross linking the local packages?

  9. added 7 commits that reference this issue on Jun 20, 2016
    cdfc36c
    7e6e249
    f59addd
    394df91
    a3e234f
    4c669b5
    c3e31bd
  10. 16 remaining items

  11. added a commit that references this issue on Sep 8, 2016
  12. gigabo commented on Sep 8, 2016

    @gigabo
    Contributor

    Oh, this didn't actually wind up getting addressed by #237.

    The functionality that was dropped is tracked in #334.

  13. ingro commented on Sep 29, 2016

    @ingro

    I run in this issue as I have multiple packages that depends on react. I used @charlieschwabacher solution with a fake react package and it works, but I hope a backed-in solution will come in future!

  14. changed the title [-]Cross linking packages breaks identity checks in external dependencies[/-] [+][Feature] Cross linking packages breaks identity checks in external dependencies[/+] on Nov 16, 2016
  15. gmmorris commented on Jan 18, 2017

    @gmmorris

    Just came across this issue myself after a whole day of debugging a problem >_<
    I made a repo for reference and was about to open a new issue when I found this one (See here: https://github.com/gmmorris/potential-symbol-bug).

    I took a look at #334 and it's been locked but left open.

    Is this something anyone here thinks might be looked at again?
    Is it something worth me looking into with a potential pull request?

    I'm getting the feeling that if the maintainers have decided not to address on purpose, any pull request would probably get rejected, so just want to double check before I invest time into this.

    Thanks for investing your time everyone, I love Lerna and appreciate the work everyone has put into it!

  16. gigabo commented on Jan 19, 2017

    @gigabo
    Contributor

    Hi @gmmorris thanks for bringing this back up. I've opened #507 to port hoisting back from Asini.

  17. gmmorris commented on Jan 19, 2017

    @gmmorris

    @gigabo My pleasure, thank you. :)
    I'll keep an eye on it. I've solved this manually for now, but obviously that's not a good long term solution.

  18. SandroMachado commented on Jun 19, 2017

    @SandroMachado

    Any updates on this issue?

  19. photusenigma commented on Jun 20, 2017

    @photusenigma

    Also looking for an update. ?

  20. evocateur commented on Aug 31, 2017

    @evocateur
    Member

    This was fixed in #507 with the introduction of --hoist.

  21. lock commented on Dec 28, 2018

    @lock

    This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  22. locked as resolved and limited conversation to collaborators on Dec 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions