From 2f490dd94573ea06d1469c3f100e191696f423f7 Mon Sep 17 00:00:00 2001 From: Nikita Skovoroda Date: Fri, 22 Nov 2024 09:51:43 +0300 Subject: [PATCH] feat: add yarnpkg/nm/hoist export (#6611) ## What's the problem this PR addresses? Bundling `@yarnpkg/nm` (due to subdeps) is large and not needed when one needs only a few exports from `./hoist` file: https://github.com/yarnpkg/berry/blob/b3dfa91abd591a3d572daadfdba54c671c7d882b/packages/yarnpkg-nm/sources/buildNodeModulesTree.ts#L1-L4 But `hoist.ts` is a zero-dep lib: https://github.com/yarnpkg/berry/blob/b3dfa91abd591a3d572daadfdba54c671c7d882b/packages/yarnpkg-nm/sources/hoist.ts#L1-L3 It's already built/distrubuted separately (see https://www.npmjs.com/package/@yarnpkg/nm?activeTab=code), just an entry in package.json was missing Both its exports (and types) are already re-exported: https://github.com/yarnpkg/berry/blob/b3dfa91abd591a3d572daadfdba54c671c7d882b/packages/yarnpkg-nm/sources/index.ts#L23-L24 So this is not increasing public API surface, just adds a more convenient way to import it without pulling in the whole of `@yarnpkg/core` and `@yarnpkg/pnp` ## How did you fix it? Added `./hoist` to exports to point to `./lib/hoist.js` ## 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. --- .yarn/versions/ce211f43.yml | 6 ++++++ packages/yarnpkg-nm/package.json | 2 ++ 2 files changed, 8 insertions(+) create mode 100644 .yarn/versions/ce211f43.yml diff --git a/.yarn/versions/ce211f43.yml b/.yarn/versions/ce211f43.yml new file mode 100644 index 000000000000..624c7922984a --- /dev/null +++ b/.yarn/versions/ce211f43.yml @@ -0,0 +1,6 @@ +releases: + "@yarnpkg/nm": patch + +declined: + - "@yarnpkg/plugin-nm" + - "@yarnpkg/pnpify" diff --git a/packages/yarnpkg-nm/package.json b/packages/yarnpkg-nm/package.json index e647430c849f..f180faf16910 100644 --- a/packages/yarnpkg-nm/package.json +++ b/packages/yarnpkg-nm/package.json @@ -5,6 +5,7 @@ "main": "./sources/index.ts", "exports": { ".": "./sources/index.ts", + "./hoist": "./sources/hoist.ts", "./package.json": "./package.json" }, "sideEffects": false, @@ -23,6 +24,7 @@ "main": "./lib/index.js", "exports": { ".": "./lib/index.js", + "./hoist": "./lib/hoist.js", "./package.json": "./package.json" } },