mirror of
https://github.com/pnpm/pnpm.git
synced 2026-01-06 22:18:17 -05:00
9
.changeset/olive-starfishes-reflect.md
Normal file
9
.changeset/olive-starfishes-reflect.md
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
"@pnpm/headless": major
|
||||
"@pnpm/plugin-commands-script-runners": major
|
||||
"@pnpm/lockfile-to-pnp": minor
|
||||
"supi": minor
|
||||
"@pnpm/mount-modules": patch
|
||||
---
|
||||
|
||||
`.pnp.js` renamed to `.pnp.cjs` in order to force CommonJS.
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -6,7 +6,7 @@ npm-debug.log*
|
||||
# Dependency directory
|
||||
**/node_modules/**
|
||||
_node_modules
|
||||
.pnp.js
|
||||
.pnp.cjs
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
@@ -351,7 +351,7 @@ export default async (opts: HeadlessOptions) => {
|
||||
}
|
||||
let extraEnv: Record<string, string> | undefined
|
||||
if (opts.enablePnp) {
|
||||
extraEnv = makeNodeRequireOption(path.join(opts.lockfileDir, '.pnp.js'))
|
||||
extraEnv = makeNodeRequireOption(path.join(opts.lockfileDir, '.pnp.cjs'))
|
||||
}
|
||||
await buildModules(graph, Array.from(directNodes), {
|
||||
childConcurrency: opts.childConcurrency,
|
||||
|
||||
@@ -727,7 +727,7 @@ test('installing in a workspace', async () => {
|
||||
test('installing with no symlinks but with PnP', async () => {
|
||||
const prefix = path.join(fixtures, 'simple')
|
||||
await rimraf(path.join(prefix, 'node_modules'))
|
||||
await rimraf(path.join(prefix, '.pnp.js'))
|
||||
await rimraf(path.join(prefix, '.pnp.cjs'))
|
||||
|
||||
await headless(await testDefaults({
|
||||
enablePnp: true,
|
||||
@@ -741,13 +741,13 @@ test('installing with no symlinks but with PnP', async () => {
|
||||
const project = assertProject(prefix)
|
||||
expect(await project.readCurrentLockfile()).toBeTruthy()
|
||||
expect(await project.readModulesManifest()).toBeTruthy()
|
||||
expect(await exists(path.join(prefix, '.pnp.js'))).toBeTruthy()
|
||||
expect(await exists(path.join(prefix, '.pnp.cjs'))).toBeTruthy()
|
||||
})
|
||||
|
||||
test('installing with no modules directory', async () => {
|
||||
const prefix = path.join(fixtures, 'simple')
|
||||
await rimraf(path.join(prefix, 'node_modules'))
|
||||
await rimraf(path.join(prefix, '.pnp.js'))
|
||||
await rimraf(path.join(prefix, '.pnp.cjs'))
|
||||
|
||||
await headless(await testDefaults({
|
||||
enableModulesDir: false,
|
||||
|
||||
@@ -14,7 +14,7 @@ import * as R from 'ramda'
|
||||
|
||||
export async function lockfileToPnp (lockfileDir: string) {
|
||||
const lockfile = await readWantedLockfile(lockfileDir, { ignoreIncompatible: true })
|
||||
if (!lockfile) throw new Error('Cannot generate a .pnp.js without a lockfile')
|
||||
if (!lockfile) throw new Error('Cannot generate a .pnp.cjs without a lockfile')
|
||||
const importerNames: { [importerId: string]: string } = {}
|
||||
await Promise.all(
|
||||
Object.keys(lockfile.importers)
|
||||
@@ -54,7 +54,7 @@ export async function writePnpFile (
|
||||
packageRegistry,
|
||||
shebang: undefined,
|
||||
})
|
||||
await fs.writeFile(path.join(opts.lockfileDir, '.pnp.js'), loaderFile, 'utf8')
|
||||
await fs.writeFile(path.join(opts.lockfileDir, '.pnp.cjs'), loaderFile, 'utf8')
|
||||
}
|
||||
|
||||
export function lockfileToPackageRegistry (
|
||||
|
||||
@@ -22,7 +22,7 @@ const STAT_DEFAULT = {
|
||||
|
||||
export default async function createFuseHandlers (lockfileDir: string, cafsDir: string) {
|
||||
const lockfile = await readWantedLockfile(lockfileDir, { ignoreIncompatible: true })
|
||||
if (!lockfile) throw new Error('Cannot generate a .pnp.js without a lockfile')
|
||||
if (!lockfile) throw new Error('Cannot generate a .pnp.cjs without a lockfile')
|
||||
return createFuseHandlersFromLockfile(lockfile, lockfileDir, cafsDir)
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ export async function handler (
|
||||
const chunks = opts.sort
|
||||
? sortPackages(opts.selectedProjectsGraph)
|
||||
: [Object.keys(opts.selectedProjectsGraph).sort()]
|
||||
const existsPnp = existsInDir.bind(null, '.pnp.js')
|
||||
const existsPnp = existsInDir.bind(null, '.pnp.cjs')
|
||||
const workspacePnpPath = opts.workspaceDir && await existsPnp(opts.workspaceDir)
|
||||
|
||||
for (const chunk of chunks) {
|
||||
|
||||
@@ -164,7 +164,7 @@ so you may run "pnpm -w ${scriptName}"`,
|
||||
stdio: 'inherit',
|
||||
unsafePerm: true, // when running scripts explicitly, assume that they're trusted.
|
||||
}
|
||||
const existsPnp = existsInDir.bind(null, '.pnp.js')
|
||||
const existsPnp = existsInDir.bind(null, '.pnp.cjs')
|
||||
const pnpPath = (opts.workspaceDir && await existsPnp(opts.workspaceDir)) ??
|
||||
await existsPnp(dir)
|
||||
if (pnpPath) {
|
||||
|
||||
@@ -48,7 +48,7 @@ export default async (
|
||||
opts.workspaceConcurrency === 1 ||
|
||||
packageChunks.length === 1 && packageChunks[0].length === 1
|
||||
) ? 'inherit' : 'pipe'
|
||||
const existsPnp = existsInDir.bind(null, '.pnp.js')
|
||||
const existsPnp = existsInDir.bind(null, '.pnp.cjs')
|
||||
const workspacePnpPath = opts.workspaceDir && await existsPnp(opts.workspaceDir)
|
||||
|
||||
for (const chunk of packageChunks) {
|
||||
|
||||
@@ -451,7 +451,7 @@ export async function mutateModules (
|
||||
|
||||
if (!opts.ignoreScripts) {
|
||||
if (opts.enablePnp) {
|
||||
scriptsOpts.extraEnv = makeNodeRequireOption(path.join(opts.lockfileDir, '.pnp.js'))
|
||||
scriptsOpts.extraEnv = makeNodeRequireOption(path.join(opts.lockfileDir, '.pnp.cjs'))
|
||||
}
|
||||
await runLifecycleHooksConcurrently(['install', 'postinstall', 'prepublish', 'prepare'],
|
||||
projectsToBeInstalled,
|
||||
@@ -775,7 +775,7 @@ async function installInContext (
|
||||
|
||||
let extraEnv: Record<string, string> | undefined
|
||||
if (opts.enablePnp) {
|
||||
extraEnv = makeNodeRequireOption(path.join(opts.lockfileDir, '.pnp.js'))
|
||||
extraEnv = makeNodeRequireOption(path.join(opts.lockfileDir, '.pnp.cjs'))
|
||||
}
|
||||
await buildModules(dependenciesGraph, rootNodes, {
|
||||
childConcurrency: opts.childConcurrency,
|
||||
|
||||
@@ -1217,7 +1217,7 @@ test('installing with no symlinks with PnP', async () => {
|
||||
|
||||
expect(await project.readCurrentLockfile()).toBeTruthy()
|
||||
expect(await project.readModulesManifest()).toBeTruthy()
|
||||
expect(await exists(path.resolve('.pnp.js'))).toBeTruthy()
|
||||
expect(await exists(path.resolve('.pnp.cjs'))).toBeTruthy()
|
||||
})
|
||||
|
||||
test('installing with no modules directory', async () => {
|
||||
|
||||
Reference in New Issue
Block a user