Skip to content

fix(create-pds): Autocopy allowBuilds when using PNPM - #202

Open
helloimalastair wants to merge 1 commit into
ascorbic:mainfrom
helloimalastair:pnpm-whitelist-builds
Open

fix(create-pds): Autocopy allowBuilds when using PNPM#202
helloimalastair wants to merge 1 commit into
ascorbic:mainfrom
helloimalastair:pnpm-whitelist-builds

Conversation

@helloimalastair

Copy link
Copy Markdown

Hit this small papercut myself.

Per Block risky postinstall scripts, pnpm now doesn't run postinstall scripts automatically. This change adds the config required to ensure workerd and esbuild have their postinstall scripts run, and only performs this work when applicable(i.e., when using pnpm).

@ascorbic ascorbic left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks — the "Ignored build scripts" warning on a fresh scaffold is annoying and I'd like to get rid of it. One real problem: a pnpm-workspace.yaml with no packages: key makes pnpm 9 abort the install (reproduced on 9.15.9, which is what corepack users get since the template has no packageManager). Also worth being accurate that this silences a warning rather than fixing a breakage — workerd and esbuild resolve their binaries via optionalDependencies. Details inline; needs a changeset too.

@ascorbic ascorbic left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline notes for the review above.

@@ -0,0 +1,4 @@
allowBuilds:

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pnpm 9 treats any pnpm-workspace.yaml as a workspace manifest and, with no packages: key, aborts with ERROR packages field missing or empty — reproduced on 9.15.9. The template has no packageManager field so that's what corepack resolves to. pnpm 9 doesn't block build scripts at all, so for those users this file is pure downside: install fails and create-pds reports "Failed to install dependencies".

Two ways out: gate the copy on the pnpm major (it's in npm_config_user_agent), or spell it as onlyBuiltDependencies: [esbuild, workerd], which every pnpm 10 understands — allowBuilds only arrived partway through 10.x so early 10 users silently get nothing from this either way. I'd avoid adding packageManager to the template since that breaks npm/yarn/bun under corepack.

@@ -0,0 +1,4 @@
allowBuilds:
esbuild: true
sharp: false

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sharp isn't in a scaffolded project's tree (it comes from docs/ in this monorepo), so this entry is noise.

let destName = entry.name;

// Skip pnpm-specific files if not using pnpm
if (destName === "pnpm-workspace.yaml" && pm !== "pnpm") continue;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This branch isn't covered — test/e2e.test.ts asserts a fixed file list. Would be good to run both (--package-manager pnpm gets the file, npm doesn't) since the CLI already supports the flag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants