Skip to content

fix: keep nested .clang-format files out of the package with npm 12 - #2976

Merged
Tommy Nguyen (tido64) merged 1 commit into
microsoft:trunkfrom
YevheniiKotyrlo:fix/pack-test-npm-12-json-shape
Oct 19, 2026
Merged

Tommy Nguyen (tido64) merged 1 commit into
microsoft:trunkfrom
YevheniiKotyrlo:fix/pack-test-npm-12-json-shape

Conversation

@YevheniiKotyrlo

Copy link
Copy Markdown
Contributor

Description

npm 12 ships npm-packlist 11, which reads files as globs anchored to the package root, so a slashless negation such as !.clang-format now matches only at the root (npm-packlist 11.0.0). Packed with npm 12, the package therefore includes windows/.clang-format. !**/.clang-format excludes it at every depth with npm 11 and npm 12 alike.

npm 12 also keys npm pack --json by package name instead of by index, so npm pack › includes all files failed with TypeError: Cannot read properties of undefined (reading 'files') before comparing anything. The test now takes its one tarball with Object.values, which reads both shapes.

Platforms affected

  • Android
  • iOS
  • macOS
  • visionOS
  • Windows

Test plan

node --no-warnings --test test/pack.test.mts in packages/app, on Windows with Node 26.5.0:

npm 11.17.0 npm 12.0.1
trunk pass TypeError
the test change alone pass fail: windows/.clang-format is packed
this PR pass pass

yarn lint:js, yarn generate:code and yarn generate:schema leave nothing to change. yarn test:js passes apart from the test-app-util.gradle cases, which fail identically on trunk on my machine because cmd there doesn't run gradlew.bat from the working directory.

npm 12 ships npm-packlist 11, which anchors a slashless negation in
`files` to the package root, so `!.clang-format` no longer excludes
`windows/.clang-format`, and npm 12 packs it. `!**/.clang-format`
excludes it at every depth with npm 11 and npm 12 alike.

npm 12 also keys `npm pack --json` by package name instead of by index,
so the pack test now takes its one tarball with `Object.values`.

@tido64 Tommy Nguyen (tido64) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@tido64
Tommy Nguyen (tido64) merged commit 94d094b into microsoft:trunk Oct 19, 2026
26 checks passed
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