From 7375396dbe310839fc0e42002d28f8155ab6381e Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Tue, 4 Jan 2022 04:43:45 +0200 Subject: [PATCH] fix: add nodeLinker field to node_modules/.modules.yaml --- .changeset/weak-clouds-train.md | 7 +++++++ packages/core/src/install/index.ts | 1 + packages/core/test/hoistedNodeLinker/install.ts | 3 +++ packages/headless/src/index.ts | 1 + packages/modules-yaml/src/index.ts | 1 + 5 files changed, 13 insertions(+) create mode 100644 .changeset/weak-clouds-train.md diff --git a/.changeset/weak-clouds-train.md b/.changeset/weak-clouds-train.md new file mode 100644 index 0000000000..74098bb6da --- /dev/null +++ b/.changeset/weak-clouds-train.md @@ -0,0 +1,7 @@ +--- +"@pnpm/core": patch +"@pnpm/headless": patch +"@pnpm/modules-yaml": patch +--- + +Save the value of the active `nodeLinker` to `node_modules/.modules.yaml`. diff --git a/packages/core/src/install/index.ts b/packages/core/src/install/index.ts index 214112846f..04dd6e7b55 100644 --- a/packages/core/src/install/index.ts +++ b/packages/core/src/install/index.ts @@ -897,6 +897,7 @@ const _installInContext: InstallFunction = async (projects, ctx, opts) => { hoistPattern: ctx.hoistPattern, included: ctx.include, layoutVersion: LAYOUT_VERSION, + nodeLinker: opts.nodeLinker, packageManager: `${opts.packageManager.name}@${opts.packageManager.version}`, pendingBuilds: ctx.pendingBuilds, publicHoistPattern: ctx.publicHoistPattern, diff --git a/packages/core/test/hoistedNodeLinker/install.ts b/packages/core/test/hoistedNodeLinker/install.ts index 1ba54b997a..62e9c0258f 100644 --- a/packages/core/test/hoistedNodeLinker/install.ts +++ b/packages/core/test/hoistedNodeLinker/install.ts @@ -3,6 +3,7 @@ import path from 'path' import { addDependenciesToPackage, install, mutateModules } from '@pnpm/core' import { prepareEmpty } from '@pnpm/prepare' import { sync as loadJsonFile } from 'load-json-file' +import { sync as readYamlFile } from 'read-yaml-file' import { addDistTag, testDefaults } from '../utils' test('installing with hoisted node-linker', async () => { @@ -22,6 +23,8 @@ test('installing with hoisted node-linker', async () => { expect(fs.realpathSync('node_modules/has-flag')).toEqual(path.resolve('node_modules/has-flag')) expect(fs.realpathSync('node_modules/ms')).toEqual(path.resolve('node_modules/ms')) expect(fs.existsSync('node_modules/send/node_modules/ms')).toBeTruthy() + + expect(readYamlFile<{ nodeLinker: string }>('node_modules/.modules.yaml').nodeLinker).toBe('hoisted') }) test('installing with hoisted node-linker and no lockfile', async () => { diff --git a/packages/headless/src/index.ts b/packages/headless/src/index.ts index 39a0e119a7..11f61b1158 100644 --- a/packages/headless/src/index.ts +++ b/packages/headless/src/index.ts @@ -448,6 +448,7 @@ export default async (opts: HeadlessOptions) => { hoistPattern: opts.hoistPattern, included: opts.include, layoutVersion: LAYOUT_VERSION, + nodeLinker: opts.nodeLinker, packageManager: `${opts.packageManager.name}@${opts.packageManager.version}`, pendingBuilds: opts.pendingBuilds, publicHoistPattern: opts.publicHoistPattern, diff --git a/packages/modules-yaml/src/index.ts b/packages/modules-yaml/src/index.ts index d158779c95..f53667e49a 100644 --- a/packages/modules-yaml/src/index.ts +++ b/packages/modules-yaml/src/index.ts @@ -18,6 +18,7 @@ export interface Modules { hoistPattern?: string[] included: IncludedDependencies layoutVersion: number + nodeLinker?: 'hoisted' | 'isolated' | 'pnp' packageManager: string pendingBuilds: string[] prunedAt: string