Skip to content

Adds support for package map generation - #7184

Merged
arcanis merged 8 commits into
masterfrom
mael/package-maps
Jun 15, 2026
Merged

arcanis merged 8 commits into
masterfrom
mael/package-maps

Conversation

@arcanis

@arcanis arcanis commented Jun 14, 2026

Copy link
Copy Markdown
Member

This PR implements support for generating package maps.

Checklist

  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

@arcanis
arcanis merged commit c7ac150 into master Jun 15, 2026
32 checks passed
@arcanis
arcanis deleted the mael/package-maps branch June 15, 2026 07:36
@adrian-gierakowski

Copy link
Copy Markdown

Does this mean in the future custom .pnp loader will not be necessary? I guess the only missing bit would be loading files from zip archives

@arcanis

arcanis commented Jun 15, 2026

Copy link
Copy Markdown
Member Author

Yes, that's what I want to reach. Archived packages are an issue, but we could have a mode where Yarn installs packages in a global store on disk (unpacked). It would have some drawbacks, but the compatibility would still go way up.

arcanis added a commit to yarnpkg/zpm that referenced this pull request Jun 22, 2026
Counterpart of yarnpkg/berry#7184 for the Rust
implementation.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Touches install linking, generated artifacts, and `NODE_OPTIONS` for
all scripts; behavior changes module resolution when package maps are
enabled, though defaults keep the feature off.
> 
> **Overview**
> Adds **Node.js experimental package map** support for `nodeLinker:
node-modules` and `nodeLinker: pnpm` (Rust zpm counterpart to Berry
#7184).
> 
> New settings **`nodeExperimentalPackageMap`** (inject
`--experimental-package-map=…` into `NODE_OPTIONS` when enabled) and
**`nodePackageMapType`** (`standard` vs `loose` dependency edges).
During link, the **node-modules** and **pnpm** linkers build and write
**`node_modules/.package-map.json`** (per-workspace for node-modules
islands), tracking installed layout and declared vs hoisted
dependencies. **`script` environments** refresh/strip package-map flags
alongside PnP loaders, using island-aware map paths when cwd is in a
node-modules island.
> 
> Supporting changes: new **`linker/package_map`** module,
**`Project::package_map_path`**, PnP linker cleanup removes stale maps,
**`Path::without_trailing_separators`**, and acceptance tests for maps,
loose mode, and island injection.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
889778e. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Cursor Agent <[email protected]>
ReDrUm pushed a commit to ReDrUm/yarn-berry that referenced this pull request Jul 10, 2026
This PR implements support for generating [package
maps](https://nodejs.org/download/nightly//v27.0.0-nightly202606134383f67279/docs/api/packages.html#package-maps).

## Checklist

<!--- Don't worry if you miss something, chores are automatically
tested. -->
<!--- This checklist exists to help you remember doing the chores when
you submit a PR. -->
<!--- Put an `x` in all the boxes that apply. -->
- [x] I have read the [Contributing
Guide](https://yarnpkg.com/advanced/contributing).

<!-- See
https://yarnpkg.com/advanced/contributing#preparing-your-pr-to-be-released
for more details. -->
<!-- Check with `yarn version check` and fix with `yarn version check
-i` -->
- [x] I have set the packages that need to be released for my changes to
be effective.

<!-- The "Testing chores" workflow validates that your PR follows our
guidelines. -->
<!-- If it doesn't pass, click on it to see details as to what your PR
might be missing. -->
- [x] I will check that all automated PR checks pass before the PR gets
reviewed.
const packageLocations = packageLocationsByNodeModulesPath.get(nodeModulesPath);

if (typeof packageLocations !== `undefined`) {
for (const [dependencyName, dependencyLocation] of Array.from(packageLocations).sort(([a], [b]) => compareStrings(a, b))) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ‘‹ Sorry for jumping into merged PR, but is this operation necessary?
For us it takes about 50s

Please see #7223 as potential solution.

pull Bot pushed a commit to Hawthorne001/berry that referenced this pull request Jul 17, 2026
## What's the problem this PR addresses?

Our tools detected a significant perf regression after updating from
4.13 to 4.17 and I was able to narrow down the impact to yarnpkg#7184

This change removes likely redundant sorting operation, speeding up (in
my case) linking step by 97%, from 50s to 2s

## How did you fix it?

First I've tried to cache sorting operation, but later challenged its
very existence. Tests and snapshots are happy and see no difference.


...

## Checklist

- [x] I have read the [Contributing
Guide](https://yarnpkg.com/advanced/contributing).

- [x] I have set the packages that need to be released for my changes to
be effective.

- [x] I will check that all automated PR checks pass before the PR gets
reviewed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants