Skip to content

Commit

Permalink
add back yarn pnp check with different error message (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
dario-piotrowicz authored Jul 25, 2023
1 parent 671ff82 commit 476d26a
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .changeset/strange-pianos-fry.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'@cloudflare/next-on-pages': minor
'@cloudflare/next-on-pages': patch
---

allow next-on-pages applications to be built using `yarn pnp`
clarify that Yarn Plug'n'Play can't be used simply because not supported by vercel
21 changes: 20 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/next-on-pages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"chokidar": "^3.5.3",
"cookie": "^0.5.0",
"esbuild": "^0.15.3",
"js-yaml": "^4.1.0",
"pcre-to-regexp": "^1.1.0",
"semver": "^7.5.2",
"zod": "^3.21.4",
Expand All @@ -52,6 +53,7 @@
"@cloudflare/workers-types": "^4.20230404.0",
"@tsconfig/strictest": "^2.0.0",
"@types/cookie": "^0.5.1",
"@types/js-yaml": "^4.0.5",
"@types/mock-fs": "^4.13.1",
"@types/node": "^20.1.4",
"dedent-tabs": "^0.10.3",
Expand Down
20 changes: 20 additions & 0 deletions packages/next-on-pages/src/buildApplication/packageManagerUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { execFileSync, spawn } from 'child_process';
import { readFile } from 'fs/promises';
import YAML from 'js-yaml';
import { cliError } from '../cli';
import { validateFile } from '../utils';

Expand Down Expand Up @@ -28,6 +30,24 @@ export async function getCurrentPackageManager(): Promise<PackageManager> {
});
});
if (!yarnV.startsWith('1.')) {
const yarnrc = await readFile('.yarnrc.yml', 'utf-8');
const { nodeLinker } = YAML.load(yarnrc) as {
nodeLinker: string;
};
if (nodeLinker !== 'node-modules') {
cliError(
`
Error: Yarn Plug'n'Play not supported
The vercel cli doesn't currently support Plug'n'Play features from yarn berry.
Since @cloudflare/next-on-pages uses the vercel cli to build the target application,
if you want to use the adapter with yarn berry, you need to add "nodeLinker: node-modules"
to your .yarnrc.yml
`,
{ spaced: true },
);
process.exit(1);
}
return 'yarn (berry)';
} else {
return 'yarn (classic)';
Expand Down

0 comments on commit 476d26a

Please sign in to comment.