fix: tolerate node engine warnings in lint-fix#4535
Conversation
✅ Deploy Preview for module-federation-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
…arning # Conflicts: # tools/scripts/lint-fix.mjs
|
@module-federation/devtools
@module-federation/cli
create-module-federation
@module-federation/data-prefetch
@module-federation/dts-plugin
@module-federation/enhanced
@module-federation/error-codes
@module-federation/esbuild
@module-federation/managers
@module-federation/manifest
@module-federation/metro
@module-federation/metro-plugin-rnc-cli
@module-federation/metro-plugin-rnef
@module-federation/modern-js
@module-federation/modern-js-v3
@module-federation/native-federation-tests
@module-federation/native-federation-typescript
@module-federation/nextjs-mf
@module-federation/node
@module-federation/retry-plugin
@module-federation/rsbuild-plugin
@module-federation/rspack
@module-federation/rspress-plugin
@module-federation/runtime
@module-federation/runtime-core
@module-federation/runtime-tools
@module-federation/sdk
@module-federation/storybook-addon
@module-federation/third-party-dts-extractor
@module-federation/treeshake-frontend
@module-federation/treeshake-server
@module-federation/typescript
@module-federation/utilities
@module-federation/webpack-bundler-runtime
@module-federation/bridge-react
@module-federation/bridge-react-webpack-plugin
@module-federation/bridge-shared
@module-federation/bridge-vue3
@module-federation/inject-external-runtime-core-plugin
commit: |
Bundle Size Report9 package(s) changed, 31 unchanged. Package dist + ESM entry
Bundle targets
Consumer scenarios
Total dist (raw): 10.63 MB (no change) Bundle sizes are generated with rslib (Rspack). Package-root metrics preserve the historical report. Tracked subpath exports such as |
|
Summary
When this repo is run under a non-supported Node version, pnpm emits an engine warning before some command output. That warning currently breaks
pnpm run lint-fixbecause the script assumespnpm exec turbo ls --output=jsonreturns clean JSON on stdout.This is most visible in the pre-commit hook, where
lint-fixshould still do its work or at least fail only on real lint errors. Instead, the warning text can cause the workspace package discovery step to throw before linting decisions are made.Root Cause
tools/scripts/lint-fix.mjsparsed Turbo package discovery withJSON.parse(result.stdout || "{}"). If pnpm prepends an engine warning to stdout, that raw output is no longer valid JSON and the script exits even though Turbo itself succeeded.Fix
Use the existing shared Turbo output parser so
lint-fixcan recover the JSON payload from noisy command output. The behavior for real Turbo failures is unchanged; this only hardens the JSON parsing step against warning preambles.Validation
pnpm install --frozen-lockfileunder Nodev22.22.1and observed the engine warning.pnpm run lint-fixunder Nodev22.22.1; it completed successfully and did not fail on the warning.pnpm exec prettier --check tools/scripts/lint-fix.mjs.node --input-type=module -e "import { parseJsonFromTurboOutput } from ./tools/scripts/turbo-script-utils.mjs"equivalent parser validation with a synthetic engine-warning preamble and confirmed it parsed the JSON payload.