Skip to content

FR: When using workspaces, create symlinks in workspace node_modules to root node_modules #5469

@dannycochran

Description

@dannycochran

Do you want to request a feature or report a bug?

Feature (may be a dupe of #5332, I cannot tell).

What is the current behavior?

Currently when using workspaces without "nohoist", all common node_modules of workspaces end up in the project root.

This is fine for node which will traverse parent directories until it finds the right module, but react-native's build system (and many third party libraries for react-native) often expect node_modules to exist in the workspace node_modules directory with hard-coded paths.

One could use the new "nohoist" feature in the react native workspace, but this starts to defeat the purpose of de-duping dependencies. For instance, I have an adjacent workspace that uses things like react and react-dom, so I'll need to still have two copies of those libraries even though they could be shared.It also would mean any adjacent workspaces that are react-native projects would not be able to de-dupe their dependencies via hoisting.

I've also found that workspaces which use webpack have a hard time with hoisted modules. My existing webpack config doesn't work when modules get hoisted.

I've managed to get everything working but it requires a lot of configuration and manipulating the "nohoist" option to such an extent that I'm not actually saving any time when running yarn install. So, I scrapped it altogether because the complexity was not worth it.

What is the desired behavior?

If sym links existed for each node_module in each workspace (and each node_module dependency), everything could just work. E.g:

  • projectRoot/
    • node_modules/
      - react-native
      - react
    • workspaces/
      • reactNativeApp/
        • node_modules/
          • react-native->(symlink to ../../node_modules/react-native)
          • react->(symlink to ../../node_modules/react)
      • reactWebApp/
        • node_modules/
          • react->(symlink to ../../node_modules/react)

Please mention your node.js, yarn and operating system version.

Node: 8.9.4
Yarn: 1.5.1

Related

#5332

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions