Skip to content

feat: speed up attw on native packages by ignoring *.node files - #282

Open
sxlijin wants to merge 1 commit into
arethetypeswrong:mainfrom
sxlijin:agent/ignore-native-addons
Open

feat: speed up attw on native packages by ignoring *.node files#282
sxlijin wants to merge 1 commit into
arethetypeswrong:mainfrom
sxlijin:agent/ignore-native-addons

Conversation

@sxlijin

@sxlijinsxlijin commented Aug 19, 2026

Copy link
Copy Markdown

When running attw on a native package - i.e. one that implements the library logic in C++ or Rust or something via N-API - attw today will read the entire library-aarch64-apple-darwin.node binary artifact, which can easily be 100MiB+, but do nothing with it because there's no type information in the binary artifact.

We ran into this in
BoundaryML/baml#4481 and are working around this by invoking attw through a wrapper that ignores dist/*.node, but this felt like a good thing to upstream :)

(Used my coding agent to open the PR, but I've rewritten the PR title and description to be hopefully useful.)

@changeset-bot

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8318a9e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
NameType
@arethetypeswrong/corePatch
@arethetypeswrong/cliPatch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@sxlijinsxlijin changed the title Ignore native addon files during analysisfeat: speed up attw on native packages by ignoring *.node filesAug 19, 2026
@sxlijin

Copy link
Copy Markdown
Author

Original agent PR description:

Summary

  • exclude native addon files ending in .node from the core package filesystem
  • add regression coverage showing the native binary is ignored while package metadata, JavaScript, declarations, similarly named files, and analysis results are unchanged
  • add a patch Changeset for @arethetypeswrong/core

Motivation

BoundaryML/baml#4481 is the motivating real-world example. BAML's ATTW CI currently stages a package without a very large opaque native .node binary because ATTW checks the JavaScript/declaration surface and the native binary is shipped separately in per-platform packages. Filtering *.node upstream would make that staging workaround unnecessary or simpler.

This link is context only; this PR does not close BoundaryML/baml#4481.

Validation

  • pnpm format
  • pnpm exec prettier --check packages/core/src/createPackage.ts packages/core/test/createPackage.test.ts .changeset/ignore-native-addons.md
  • pnpm tsgo
  • pnpm build
  • FORCE_HYPERLINK=0 TERM_PROGRAM= CI=1 pnpm test (59 core tests and 30 CLI tests)
  • pnpm check-dts

The repository does not define a lint script.

@andrewbranch

Copy link
Copy Markdown
Collaborator

Thank you! Where exactly is the work being saved here? Something still reads the Uint8Array from the tarball and passes it to the Package constructor; I’m assuming the actual savings come from something else triggering tryReadFile on quickly returning undefined rather than decoding to string. I would be interested to know what’s trying to do tryReadFile, because the TS compiler itself shouldn’t ever be reading those contents.

@sxlijin

Copy link
Copy Markdown
Author

I'm not totally sure, unfortunately: we had an external contributor send in the attw wrapper improvement to us, which dropped our attw step from 60s to 5s, which seems pretty plausible time savings for cutting out a 630MiB file read.

I will admit that I'm not sure if the implementation that codex put together is the correct one, and I don't actually know what the expensive io op is that this change saves, but this repo seemed low activity enough that upstreaming the issue by opening the PR instead of a GH issue. If I'm reading your comment correctly, are you suggesting that the correct fix should be somewhere else?

@andrewbranch

Copy link
Copy Markdown
Collaborator

Yeah, that’s what I’m guessing, but it’s been a long time since I’ve been in the weeds of this code. I will take a closer look.

@sxlijin

Copy link
Copy Markdown
Author

Sounds good, thanks! Would love if we could drop our wrapper script and just use attw directly :)

Sign up for freeto 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

@sxlijin@andrewbranch