npm / npm/rfcs

Multi-app Monorepo Followup

Open
#477 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
777
Forks
267
PR merge metrics
No merged PRs in 30d

Description

Bringing this over from https://github.com/npm/feedback/discussions/582 per @MylesBorins direction (also, hi Myles!)


Following up on https://github.com/npm/rfcs/issues/463 and https://github.com/npm/rfcs/issues/470 (and the meeting notes here) … I'm a little unclear on the status of what's left to do here. I'm willing to help if I can!

There were a few action items created as part of that meeting:

Actions:

  • land npm-packlist in cli (@wraithgar)
  • RFC about running prepare scripts for linked bundled deps
  • RFC about workspace layout (@ljharb)

Taking the second action item first, is that something I should take on? I think it might be blocked by the first item on the list because right now the suggested workaround (below) isn't working with npm@8 or npm@7 … yet?

{
  "name": "lambda-a",
  "dependencies": {
    "b": "file:../b"
  },
  "bundleDependencies": [
    "b"
  ],
  "scripts": {
    "prepare": "cd ../b; npm run prepare"
  }
}

Is there any eta on landing npm-packlist in the cli? I've created a demo repo here to test out the workaround and see if I could come up with a "hacky" implementation of running prepare scripts on local bundled deps, but currently when I run npm pack --dry-run --json -w apps/app-a in that repo, I get this output:

[
  {
    "id": "@multi-app-monorepo/app-a@1.0.0",
    "name": "@multi-app-monorepo/app-a",
    "version": "1.0.0",
    "size": 500,
    "unpackedSize": 838,
    "shasum": "4bd38bbbcc89e412082d48ef45849e53a3512f92",
    "integrity": "sha512-+sHhXSMqS8BCZjuirZwAs2rgs1UU2O+mr+nGlBYSQadIWV9nSNA8NAhO6QW2IUYS6XM5TT5+uSQ2k03Y7+FaWg==",
    "filename": "@multi-app-monorepo/app-a-1.0.0.tgz",
    "files": [
      {
        "path": "index.js",
        "size": 133,
        "mode": 420
      },
      {
        "path": "package.json",
        "size": 705,
        "mode": 420
      }
    ],
    "entryCount": 2,
    "bundled": []
  }
]

I'd expect the package.json and index.js from pkgs/pkg-c to show up in the packed output of app-a (maybe under that "bundled" key?) … indeed I believe this is the point of the npm-packlist action item. Just wanting to make sure I'm not missing something.

cc/ @isaacs who offered the workaround at the meeting and might have some ideas? 🤞

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 with RFCs 463 and 470 and the 2021-10-06 meeting notes, then review the npm-packlist action item and the linked multi-app-monorepo demo. Reproduce npm pack --dry-run --json -w apps/app-a and compare its output with the expected bundled files. Done requires determining the remaining workspace-layout or local-bundled-dependency work and documenting a concrete next step.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.