Skip to content

Nested directory support #11

Closed
Closed

Description

@patrickheeney

I currently access packages like this import { foo } from 'foo/bar';. It seems the current bootstrap only creates node_modules/foo/index.js with module.exports = require('/full/path/packages/foo');. Thus when accessing foo/bar, it Error: Cannot find module.

What would be the best path forward for supporting this? The only thing I can think of is to find all *.js paths and then create that path with matching exports.

Activity

  1. jamiebuilds commented on Jan 28, 2016

    @jamiebuilds
    Contributor

    @kittens any reason we don't just symlink everything?

  2. jamiebuilds commented on Feb 1, 2016

    @jamiebuilds
    Contributor

    This should be fixed by #34, but be warned that we're not sure if this will cause other issues and we might revert it with another major bump.

  3. jamiebuilds commented on Feb 2, 2016

    @jamiebuilds
    Contributor

    Symlinking causes other issues with npm, we'll have to figure something else out.

  4. patrickheeney commented on Feb 11, 2016

    @patrickheeney
    Author

    This seems to be outside the scope of the project, closing this.

  5. jamiebuilds commented on Feb 11, 2016

    @jamiebuilds
    Contributor

    It's not, we need to figure it out in another way

  6. evocateur commented on Feb 23, 2016

    @evocateur
    Member

    I've hit this too, it's especially nasty when you're trying to test stuff that is trying to import a subpath generated by Babel (const foo = require('my-sibling-package/lib/foo');). An approach like npm-sync can work for simple use cases, but clearly doesn't scale for a lerna-based monorepo.

    Symlinking is it's own ball of wax, since node's require() always calls realpath on the requested module path and thus it resolves the symlinks and now everything breaks because symlinks are. the. worst.

    Maybe expand the createLinkedDepFiles method to loop over non-npmignored files and require those as well?

  7. jamiebuilds commented on Feb 23, 2016

    @jamiebuilds
    Contributor

    I want to narrow down the issue in npm and see if it can be patched.

  8. patrickheeney commented on Feb 23, 2016

    @patrickheeney
    Author

    @evocateur I thought of the same as well and prototyped locally. One issue I ran into that you need a watcher when adding new files as they would need that shim to link the dependency files.

    @thejameskyle I am not sure that npm is the issue here or what the goal would be? The module code is frozen in npm so introducing new behavior to load files locally isn't something they are going to accept (don't have the link ready to cite this but its in a discussion about linking local modules).

  9. jamiebuilds commented on Feb 24, 2016

    @jamiebuilds
    Contributor

    @patrickheeney I tried symlinking previously however npm install has weird behavior around installing recursively through symlinks which I don't think is intentional.

  10. dchambers commented on Feb 24, 2016

    @dchambers

    Sorry, just another me too message, but just to say that Lerna is unusable for my use-case at present without this feature.

    If there are issues with sym-linking the directory, is it not possible to use the current approach of adding module.export = require() files, but for all files?

  11. 65 remaining items

  12. k3n commented on Feb 8, 2017

    @k3n

    Is there a summary of what was actually implemented anywhere? I've read through this issue, the changes, and the docs, but I'm unclear what the net-net is.

    My specific question is: in my root package.json I have a dependency foo. This dependency is also present as packages/foo. I would like the app to install whichever version of foo is currently present at packages/foo. Additionally, I'd like to be able to modify packages/foo and have the changes reflected in node_modules/foo.

    Should I use a simple file: link, or is there something else that I should do?

    Thanks in advance.

  13. hzoo commented on Feb 8, 2017

    @hzoo
    Contributor

    Uhh well one of the changes is that bootstrap uses symlinks + you can use the packages key to specify the folders that will be packages https://github.com/lerna/lerna#lernajson including root (.)

    made #589

  14. k3n commented on Feb 9, 2017

    @k3n

    Thank you, though I'm still battling through my problem.

  15. k3n commented on Feb 10, 2017

    @k3n

    Ok, I think my issue is that I was trying to have a 'top-level' module. Once I made everything a package, it works as expected.

  16. aeweidne commented on May 17, 2017

    @aeweidne

    I'm still experiencing issues symlinking when running lerna bootstrap. I have 2 packages, one depends on the other, both are under packages/, lerna boostrap reports that it has symlinked the two, but packages/a/node_modules/b is not a symlink to packages/b, so changes are not propagated.

  17. aga5tya commented on May 30, 2017

    @aga5tya

    I have the exact problem as @shimmerjs and @k3n,, i have to manually run lerna bootstrap to get the changes across, anything i am missing out on here ?

  18. aeweidne commented on May 30, 2017

    @aeweidne

    @aga5tya I fixed this by specifying the dependencies with explicit versions (instead of latest) and then lerna bootstrap realized they needed to be linked. Moving forward, publish will keep them in sync. This is confusing behavior granted npm itself no longer is this strict about linking, but definitely workable. Cheers.

  19. liuchong commented on Oct 15, 2017

    @liuchong

    I'm also want a feature which let me "require/install/link a package without publish"

  20. evocateur commented on Oct 15, 2017

    @evocateur
    Member

    @liuchong If you’re not publishing any packages, don’t use lerna. Relative imports are not bad.

    That said, you can add ”private”: true to the package.json of any package you do not want lerna to publish. Ensure that the private package is not a runtime dependency of anything you do publish, or the dependents will be broken when consumed outside your monorepo.

  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