vercel / vercel/ncc

Bug: asset relocation doesn't work with yarn monorepos because `filterAssetBase` is set to `cwd`

Open
#951 5 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
9.8k
Forks
326
PR merge metrics
No merged PRs in 30d

Description

Steps to reproduce:

  • have a yarn workspaces monorepo
  • have 2 packages in the monorepo
  • package A has an asset dependency
  • package B uses package A
  • build package B with ncc

Expected result:

  • the asset is relocated

Actual result:

  • the asset is not relocated because filterAssetBase is set to cwd and the two packages are symlinked

My workaround:

  • the build script changes directory to root package before building

Proposed solution:

  • I don't understand why filterAssetBase should be set to anything other than /. Why does it matter where the asset is located? if it's referenced in original code, it should be relocated. So filterAssetBase should be set to /
  • (this is related) There are many options exposed by ncc in javascript but not via the cli command. Have a jest/webpack style configuration javascript file, that would export all the properties in the ncc interface. This object would be merged to override the default configuration passed by cli.js.

I can create a PR that would address these two issues if I get the green light from you (the maintainers)

Contributor guide

No contributing guide indexed for this repository

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 reproducing the Yarn workspaces case described, then trace how filterAssetBase is set and used during asset relocation. Read cli.js to see how ncc options are passed, and verify that building package B relocates package A's asset; treat the proposed JavaScript configuration file as a separate scope decision.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
build-system, cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.