Skip to content

JavaScript: make prettier a devDependency to fix flaky npmBuild#7735

Merged
jkschneider merged 1 commit into
mainfrom
js-prettier-devdep
May 19, 2026
Merged

JavaScript: make prettier a devDependency to fix flaky npmBuild#7735
jkschneider merged 1 commit into
mainfrom
js-prettier-devdep

Conversation

@jkschneider
Copy link
Copy Markdown
Member

Summary

  • :rewrite-javascript:npmBuild failed on main with 9 TS2307: Cannot find module 'prettier' errors (run 26104109474).
  • Root cause: prettier was in optionalDependencies only. npm normally installs optional deps, but silently skips them on transient install failures. The successful run earlier the same day installed 81 packages in 29s; the failing run installed 80 in 45s — prettier was the one quietly dropped. Reproducible locally with rm -rf node_modules/prettier && npm run build.
  • Fix: also list prettier in devDependencies so it's always installed for the build. Kept it in optionalDependencies so end-user installs of @openrewrite/rewrite still pull it in (with the existing bundled-prettier fallback if they --omit=optional).

Test plan

  • npm run build passes
  • npm run typecheck passes
  • Confirmed previous failure mode: removing node_modules/prettier before this change reproduces the exact 9 TS2307 errors from CI; after this change, prettier is reinstalled by npm install as a devDep so the failure can't recur

…s on npm honoring the optional install

`prettier` was in `optionalDependencies` only. npm normally installs
optional deps, but silently skips them on any transient install failure
(registry blip, integrity retry, etc.). When that happened on a CI
runner, `tsc --build` failed with TS2307 because the source uses
`typeof import('prettier')` and needs the types at compile time.

Keep `prettier` in `optionalDependencies` too — that's how end-user
installs of `@openrewrite/rewrite` still pull prettier in by default
(with the existing bundled-prettier fallback if they skip it).
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite May 19, 2026
@jkschneider jkschneider merged commit c362037 into main May 19, 2026
1 check failed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite May 19, 2026
@jkschneider jkschneider deleted the js-prettier-devdep branch May 19, 2026 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant