npm / npm/cli

[FEATURE REQUEST] workspaces: Configure directory which is linked during installation

Open
#6,614 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
10.1k
Forks
4.7k
Avg merge
2d 2h
Merged PRs (30d)
19

Description

Simplyfied I've got the following project structure:

workspace/
├─ package.json                  <-- With npm workspaces (see below)
├─ packages/
│  ├─ angular/                   <-- Angular Workspace
│  │  ├─ projects/
│  │  │  ├─ a/                   <-- Angular Library A Source
│  │  │  │  ├─ package.json
│  │  │  ├─ b/                   <-- Angular Library B Source
│  │  │  │  ├─ package.json
│  │  ├─ dist/
│  │  │  ├─ a/                   <-- Built Angular Library A
│  │  │  ├─ b/                   <-- Built Angular Library B
│  ├─ webcomponents/             <-- Stencil.js Webcomponents
│  │  ├─ package.json
│  │  ├─ dist/
│  ├─ demo-app/                  <-- This package depends on all of the above
|  │  ├─ package.json/

In the root package.json I've got the following workspaces config:

"workspaces": [
  "packages/*",
  "packages/angular/projects/*"
]

When I run npm install all dependecies are installed and local packages are linked as expected. The problem is, that Angular builds libraries by default within a dist folder outside of the actual workspace and creates a new package.json in it. So this directory is meant to be packed and published.

In the demo-app however, the source folders of the Angular libraries are linked, since this is configured in the workspaces of course. I haven't found any hint on how I can tell npm to link another directory then the actual workspace.

I used to use Lerna before and it respected the publishConfig.directory setting within the package's package.json for linking.

So my request would be that npm either respects this property as well or finds another way to configure a different directory to link duing the install phase.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the root package.json workspaces configuration and the behavior of npm install when linking workspace packages. Compare that behavior with publishConfig.directory and determine how a configured directory should be selected for linking; done means the requested directory is linked without breaking normal workspace installation.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, javascript, nodejs
Domain
build-system, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.