fix: add nodeLinker field to node_modules/.modules.yaml

This commit is contained in:
Zoltan Kochan
2022-01-04 04:43:45 +02:00
parent 8fe8f5e55e
commit 7375396dbe
5 changed files with 13 additions and 0 deletions

View File

@@ -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`.

View File

@@ -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,

View File

@@ -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 () => {

View File

@@ -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,

View File

@@ -18,6 +18,7 @@ export interface Modules {
hoistPattern?: string[]
included: IncludedDependencies
layoutVersion: number
nodeLinker?: 'hoisted' | 'isolated' | 'pnp'
packageManager: string
pendingBuilds: string[]
prunedAt: string