Skip to content

Stop packing what only the compiler needs - #38

Merged
Harted merged 1 commit into
mainfrom
chore/stop-packing-node-gyp
Aug 28, 2026
Merged

Stop packing what only the compiler needs#38
Harted merged 1 commit into
mainfrom
chore/stop-packing-node-gyp

Conversation

@Harted

@Harted Harted commented Aug 28, 2026

Copy link
Copy Markdown
Member

The packed app carried node-gyp and its whole tree. That is where the tar, glob and cacache alerts live, and it is most of what was in the asar.

node-gyp compiles a native module at install time. A shipped app compiles nothing: node-gyp-build is what finds the prebuilt binding at runtime. It arrives because @serialport/bindings-cpp declares it.

The list is derived, not written

Every package reachable from the production dependencies only through node-gyp, computed from yarn.lock. A name that disappears makes its pattern match nothing; a name that appears later is packed until the list is derived again. The comment in electron-builder.yml says so.

What the asar holds now

$ npx asar list dist/mac/Modbux.app/Contents/Resources/app.asar \
    | grep -oE "^/node_modules/(@[^/]+/)?[^/]+" | sort -u
/node_modules/@serialport/binding-mock
/node_modules/@serialport/bindings-cpp
/node_modules/@serialport/bindings-interface
/node_modules/@serialport/parser-byte-length
...
/node_modules/deepmerge
/node_modules/lodash
/node_modules/luxon
/node_modules/modbus-serial
/node_modules/node-addon-api
/node_modules/node-gyp-build
/node_modules/serialport
/node_modules/uuid
/node_modules/zod

The serialport family, modbus-serial, and the five the app imports itself. No tar, no glob, no cacache, no node-gyp.

What proves it

The specs that use a serial port, run against the packaged app: 16-client-rtu, 23-server-rtu, 25-disconnect-messages and the navigation spec, green on macOS Intel. Those are the ones that fail first if the binding cannot be loaded.

The full matrix runs on this branch, packaged mode included, which is the mode that matters here.

What this does not do

It does not close the alerts. Dependabot reads the lockfile, and those packages stay in the tree because the install still needs them. #37 is the other half: it holds tar at a version past every fix the open alerts name.

node-gyp compiles a native module at install time, and a shipped app
compiles nothing: node-gyp-build is what loads the prebuilt binding at
runtime. It arrives because @serialport/bindings-cpp declares it, and it
brings a tree that was most of what got packed. tar, glob and cacache
were all in the asar this way, which is also where the alerts filed
against them come from.

The names are every package reachable from the production dependencies
only through node-gyp, derived from yarn.lock rather than written out by
hand. What the asar holds afterwards is the serialport family,
modbus-serial, and the five the app imports itself.

The serial specs pass against the packaged app, which is what proves the
binding still loads.
@Harted
Harted marked this pull request as ready for review August 28, 2026 15:55
@Harted
Harted merged commit e150b01 into main Aug 28, 2026
7 checks passed
@Harted
Harted deleted the chore/stop-packing-node-gyp branch August 28, 2026 15:55
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.

1 participant